1
0
forked from bip/bip
bip/scripts/bip-release

84 lines
1.9 KiB
Bash
Executable File

#!/bin/sh
set -e
if [ ! -d src ] || [ ! -f NEWS ] ; then
echo "Please run me in bip sources root." >&2
exit 1
fi
release_version="$1"
release_name="$2"
: ${MAKEOPTS:=-j -l4}
set_version() {
local release_version
release_version="${1}"
sed -i -e '/^AC_INIT/s/\(,\[\)[^]]*/\1'${release_version}'/' configure.ac
}
get_version() {
grep -e '^AC_INIT' configure.ac | cut -d [ -f 3 | cut -d ] -f 1
}
make_distcheck() {
# prepare sources
autoreconf -i -Wall
# Create makefile, use all possible options
./configure
# run distcheck
if ! make ${MAKEOPTS} distcheck; then
echo "'make distcheck' fails, please try again." >&2
return 1
else
true
fi
}
git log > ChangeLog
if [ -n "$release_version" ]; then
# Don't forget to update NEWS file before a release
expected="$(date --rfc-3339=date) (${release_version})"
if [ -n "${release_name}" ]; then
expected="${expected} \"${release_name}\""
fi
head -n 1 NEWS | grep -q "^${expected}$" || (echo "NEWS file doesn't match the expected format (${expected})" && exit 1)
set_version "${release_version}"
make_distcheck || exit 1
git commit -a --gpg-sign -m "Update version and ChangeLog for bip-${release_version} release."
TAG_COMMENT="Release ${release_version}"
if [ -n "${release_name}" ]; then
TAG_COMMENT="${TAG_COMMENT} '${release_name}'"
fi
git tag --sign -m "${TAG_COMMENT}" release-${release_version}
set_version "${release_version}-git"
git commit -a --gpg-sign -m "Add -git to version string."
echo "See bip-${release_version}.tar.gz"
else
make_distcheck || exit 1
tarname=bip-$(get_version)
prefix=bip-$(date +%Y%m%d)
rm -rf "${tarname}" "${prefix}"
tar -xzf "${tarname}".tar.gz
rm -rf "${tarname}".tar.gz
mv "${tarname}" "${prefix}"
tar -czf "${prefix}".tar.gz "${prefix}"
rm -rf "${prefix}"
# Revert the ChangeLog.
git checkout HEAD -- ChangeLog
echo "See ${prefix}.tar.gz"
fi
# cleanup
git clean -d -i -e "bip-*.tar.gz"