eb1b1c434d
* 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
60 lines
1.4 KiB
Bash
Executable File
60 lines
1.4 KiB
Bash
Executable File
#!/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 <<EOF
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package version
|
|
|
|
func init() {
|
|
buildTimestamp = "$TIMESTAMP"
|
|
buildCommitHash = "$COMMIT"
|
|
buildVersion = "$VERSION"
|
|
buildRelease = "true"
|
|
}
|
|
EOF
|
|
|
|
gofmt -w -s ./internal/version/release.go
|
|
go install ./internal/version
|
|
|
|
git add ./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
|