open-consul/scripts/dist.sh

60 lines
1.8 KiB
Bash
Raw Normal View History

#!/usr/bin/env bash
2013-12-19 19:22:08 +00:00
set -e
# 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
for tag in "$BUILD_TAGS"; do
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
echo "Please specify a version (couldn't find one based on build tags)."
2014-04-16 23:53:26 +00:00
exit 1
fi
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 )"
# Change into that dir because we expect that.
2013-12-19 19:22:08 +00:00
cd $DIR
# 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
# Do a hermetic build inside a Docker container.
if [ -z $NOBUILD ]; then
docker build -t hashicorp/consul-builder scripts/consul-builder/
docker run --rm -e "BUILD_TAGS=$BUILD_TAGS" -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
# 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
# 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