From eb1b1c434d09687c8d9763733f5b6d80423c7214 Mon Sep 17 00:00:00 2001 From: JT Olio Date: Mon, 24 Jun 2019 11:53:17 -0600 Subject: [PATCH] scripts/tag-release.sh: libuplink release tagging (#2256) * scripts/tag-release.sh: libuplink release tagging a couple of arch review meetings ago we discussed how to make sure that it is much easier to get the release defaults for binaries, libraries, and so on. we already imperfectly solved the binary problem with the release.sh script, but (until now!) have not solved the problem of getting release defaults for people building from source. the solution we seemed to all prefer was to make sure our tagged version commits check the release state into the source code. this script aides in tagging commits with version tags and updating the source defaults. it still plays nicely with release.sh and our other build processes. after this is merged we should configure github/go modules to prefer people use one of our tags instead of master (which will keep dev defaults). Change-Id: I36c5c33a1bc90ec1685f59b05dde779090e252b6 * gofmt release.go Change-Id: I6e968eff86230496e9cbddecd767ca8d8ff36ba4 * regex for version tag Change-Id: Icaa6d753ffc962115d961bcabe9daed89b16430c * added some docs Change-Id: Ide624fab794ce849e3a3e7254fb038251bba0c71 --- scripts/tag-release.sh | 59 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100755 scripts/tag-release.sh diff --git a/scripts/tag-release.sh b/scripts/tag-release.sh new file mode 100755 index 000000000..cb7872ad8 --- /dev/null +++ b/scripts/tag-release.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash + +## This script: +# +# 1) Makes sure the current git working tree is clean +# 2) Creates a release file that changes the build defaults to include +# a timestamp, a commit hash, a version number, and set the release +# flag to true. +# 3) commits that release file and tags it with the release version +# 4) resets the working tree back +# +# This script should be used instead of 'git tag' for Storj releases, +# so downstream users developing with Go 1.11+ style modules find code +# with our release defaults set instead of our dev defaults set. +# + +set -eu +set -o pipefail + +VERSION="${1-}" + +if ! [[ "$VERSION" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "usage: $0 vMAJOR.MINOR.PATCH" + exit 1 +fi + +cd "$(git rev-parse --show-toplevel)" + +if [[ "$(git diff --stat)" != '' ]] || [[ -n "$(git status -s)" ]]; then + echo "git working tree unclean" + exit 1 +fi + +TIMESTAMP=$(date +%s) +COMMIT=$(git rev-parse HEAD) + +cat > ./internal/version/release.go </dev/null +git commit -m "release $VERSION" >/dev/null +if git tag $VERSION; then + echo successfully created tag $VERSION +fi +git reset --hard $COMMIT >/dev/null