Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,13 @@ AC_INIT
AC_CONFIG_SRCDIR([src/cf-promises.c])
AC_CANONICAL_TARGET

define([svnversion], [r]esyscmd([sh -c "svnversion --no-newline || echo exported | tr -d '\n'" 2>/dev/null]))dnl

define([revision], esyscmd([sh -c "git describe --always || echo unknown | tr -d '\n'" 2>/dev/null]))dnl

dnl
dnl The version in the next line is the only one to set
dnl
dnl 'svnversion' need to be removed before release and added back after.
dnl

AM_INIT_AUTOMAKE(cfengine, 3.4.0a1.svnversion) dnl remember to set version
AM_INIT_AUTOMAKE(cfengine, 3.4.0a1.revision)
AM_MAINTAINER_MODE([enable])

AC_DEFINE(BUILD_YEAR, esyscmd([date +%Y | tr -d '\n']), "Software build year")
Expand Down
68 changes: 29 additions & 39 deletions release.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
#!/bin/sh
set -e

#
# This script is only useful for git-svn-maintained repository.
#

SVN_URL=https://c.cfengine.com/svn/core

usage()
{
echo
Expand Down Expand Up @@ -70,32 +64,21 @@ branch()
echo "In order to create stable branch you have to be on trunk!"
exit 1
fi
svn copy $SVN_URL/trunk/ $SVN_URL/branches/$BRANCH -m "Create $BRANCH from trunk"
git svn fetch
git checkout -b $BRANCH remotes/$BRANCH
git checkout -b $BRANCH
else
detect_current_branch
fi
}

dist()
{
mkdir ../_dist
cd ../_dist
svn co $SVN_URL/branches/$BRANCH core
cd core
remove_svnversion

CURR_VERSION=$(sed -ne 's/AM_INIT_AUTOMAKE(cfengine, \(.*\)).*/\1/p' configure.ac)

if [ -z "$CURR_VERSION" ]; then
echo "Unable to parse current version from configure.ac"
grep AM_INIT_AUTOMAKE configure.ac
exit 1
fi
mkdir -p ../_dist/core
cd ../_dist/core
git init
git fetch $REPO tag $CURR_VERSION
git checkout $CURR_VERSION

NO_CONFIGURE=1 NO_SUBPROJECTS=1 ./autogen.sh
./configure
NO_SUBPROJECTS=1 ./autogen.sh
make dist
}

Expand All @@ -108,28 +91,35 @@ check()
make check -j8
}

remove_svnversion()
remove_revision()
{
sed -i -e 's/AM_INIT_AUTOMAKE(cfengine, \(.*\)\.svnversion)/AM_INIT_AUTOMAKE(cfengine, \1)/' configure.ac
sed -i -e 's/AM_INIT_AUTOMAKE(cfengine, \(.*\)\.revision)/AM_INIT_AUTOMAKE(cfengine, \1)/' configure.ac

if grep AM_INIT_AUTOMAKE configure.ac | grep -q svnversion; then
echo "Unable to remove 'svnversion' from version in configure.ac"
if grep AM_INIT_AUTOMAKE configure.ac | grep -q revision; then
echo "Unable to remove 'revision' from version in configure.ac"
grep AM_INIT_AUTOMAKE configure.ac
exit 1
fi
}

do_svn_tag()
do_tag()
{
svn copy $SVN_URL/branches/$BRANCH $SVN_URL/tags/$CURR_VERSION -m "Tagging $CURR_VERSION"
git svn fetch
CURR_VERSION=$(sed -ne 's/AM_INIT_AUTOMAKE(cfengine, \(.*\)).*/\1/p' configure.ac)

if [ -z "$CURR_VERSION" ]; then
echo "Unable to parse current version from configure.ac"
grep AM_INIT_AUTOMAKE configure.ac
exit 1
fi

git tag -s $CURR_VERSION -m "Tagging $CURR_VERSION"
}

bump_version()
{
sed -i -e 's/AM_INIT_AUTOMAKE(cfengine, \(.*\))/AM_INIT_AUTOMAKE(cfengine, '"$NEXT_VERSION"'.svnversion)/' configure.ac
sed -i -e 's/AM_INIT_AUTOMAKE(cfengine, \(.*\))/AM_INIT_AUTOMAKE(cfengine, '"$NEXT_VERSION"'.revision)/' configure.ac

if ! grep AM_INIT_AUTOMAKE configure.ac | grep -q svnversion; then
if ! grep AM_INIT_AUTOMAKE configure.ac | grep -q revision; then
echo "Unable to bump version in configure.ac"
grep AM_INIT_AUTOMAKE configure.ac
exit 1
Expand All @@ -139,21 +129,21 @@ bump_version()
commit_version() {
git add configure.ac
git commit -m "$1"
git svn dcommit
}

tag()
{
remove_svnversion
remove_revision
commit_version "Pre-release version bump"
do_svn_tag
do_tag
bump_version
commit_version "Post-release version bump"
}

REPO=$(git rev-parse --show-toplevel)

opts "$@"
branch
CURDIR=$(pwd)
dist && check
cd ${CURDIR}
tag
dist
check