2016-02-01 19:25:55 +00:00
|
|
|
#!/usr/bin/env bash
|
2013-12-19 19:22:08 +00:00
|
|
|
set -e
|
|
|
|
|
2016-11-03 00:27:49 +00:00
|
|
|
# Get the version from the environment, or try to figure it out from the build tags.
|
|
|
|
# We process the files in the same order Go does to find the last matching tag.
|
|
|
|
if [ -z $VERSION ]; then
|
|
|
|
for file in $(ls version/version_*.go | sort); do
|
2017-03-24 05:52:39 +00:00
|
|
|
for tag in "$GOTAGS"; do
|
2016-11-03 00:27:49 +00:00
|
|
|
if grep -q "// +build $tag" $file; then
|
|
|
|
VERSION=$(awk -F\" '/Version =/ { print $2; exit }' <$file)
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
fi
|
2014-04-16 23:53:26 +00:00
|
|
|
if [ -z $VERSION ]; then
|
2016-11-03 00:27:49 +00:00
|
|
|
echo "Please specify a version (couldn't find one based on build tags)."
|
2014-04-16 23:53:26 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2016-11-03 00:27:49 +00:00
|
|
|
echo "==> Building version $VERSION..."
|
2014-04-16 23:53:26 +00:00
|
|
|
|
2013-12-19 19:22:08 +00:00
|
|
|
# Get the parent directory of where this script is.
|
|
|
|
SOURCE="${BASH_SOURCE[0]}"
|
|
|
|
while [ -h "$SOURCE" ] ; do SOURCE="$(readlink "$SOURCE")"; done
|
|
|
|
DIR="$( cd -P "$( dirname "$SOURCE" )/.." && pwd )"
|
|
|
|
|
2016-02-18 07:16:47 +00:00
|
|
|
# Change into that dir because we expect that.
|
2013-12-19 19:22:08 +00:00
|
|
|
cd $DIR
|
|
|
|
|
2016-02-18 07:16:47 +00:00
|
|
|
# Generate the tag.
|
2015-10-22 18:16:01 +00:00
|
|
|
if [ -z $NOTAG ]; then
|
|
|
|
echo "==> Tagging..."
|
|
|
|
git commit --allow-empty -a --gpg-sign=348FFC4C -m "Release v$VERSION"
|
|
|
|
git tag -a -m "Version $VERSION" -s -u 348FFC4C "v${VERSION}" master
|
|
|
|
fi
|
2014-05-20 19:48:17 +00:00
|
|
|
|
2016-02-18 07:16:47 +00:00
|
|
|
# Do a hermetic build inside a Docker container.
|
|
|
|
if [ -z $NOBUILD ]; then
|
|
|
|
docker build -t hashicorp/consul-builder scripts/consul-builder/
|
2017-03-24 05:52:39 +00:00
|
|
|
docker run --rm -e "GOTAGS=$GOTAGS" -v "$(pwd)":/gopath/src/github.com/hashicorp/consul hashicorp/consul-builder ./scripts/dist_build.sh
|
2015-10-22 18:16:01 +00:00
|
|
|
fi
|
2014-05-01 18:01:54 +00:00
|
|
|
|
2016-02-18 07:16:47 +00:00
|
|
|
# Zip all the files.
|
2015-10-22 18:16:01 +00:00
|
|
|
rm -rf ./pkg/dist
|
|
|
|
mkdir -p ./pkg/dist
|
|
|
|
for FILENAME in $(find ./pkg -mindepth 1 -maxdepth 1 -type f); do
|
|
|
|
FILENAME=$(basename $FILENAME)
|
|
|
|
cp ./pkg/${FILENAME} ./pkg/dist/consul_${VERSION}_${FILENAME}
|
2013-12-19 19:22:08 +00:00
|
|
|
done
|
|
|
|
|
2016-02-18 07:16:47 +00:00
|
|
|
# Make the checksums.
|
2015-10-22 18:16:01 +00:00
|
|
|
pushd ./pkg/dist
|
|
|
|
shasum -a256 * > ./consul_${VERSION}_SHA256SUMS
|
|
|
|
if [ -z $NOSIGN ]; then
|
|
|
|
echo "==> Signing..."
|
|
|
|
gpg --default-key 348FFC4C --detach-sig ./consul_${VERSION}_SHA256SUMS
|
|
|
|
fi
|
2013-12-19 19:22:08 +00:00
|
|
|
popd
|
|
|
|
|
2015-10-26 21:30:29 +00:00
|
|
|
exit 0
|