|
| 1 | +#! /bin/bash |
| 2 | + |
| 3 | +set -euo pipefail |
| 4 | + |
| 5 | +echo "**** Checking environment for configuration. ****" |
| 6 | +export | grep -q GITHUB_TOKEN= || (echo "Aiee, you should set a GITHUB_TOKEN environment variable." ; exit 1) |
| 7 | + |
| 8 | +if [ "x$(git status --porcelain)" != "x" ]; then |
| 9 | + echo "Please commit changes to git before releasing." >&2 |
| 10 | + exit 1 |
| 11 | +fi |
| 12 | + |
| 13 | +CHANNEL=dev |
| 14 | + |
| 15 | +echo "**** Determining next build number for $CHANNEL channel ****" |
| 16 | + |
| 17 | +LAST_BUILD=$(curl -fs https://install.sandstorm.io/$CHANNEL) |
| 18 | + |
| 19 | +. ../sandstorm/branch.conf |
| 20 | + |
| 21 | +if (( LAST_BUILD / 1000 > BRANCH_NUMBER )); then |
| 22 | + echo "ERROR: $CHANNEL has already moved past this branch!" >&2 |
| 23 | + echo " I refuse to replace it with an older branch." >&2 |
| 24 | + exit 1 |
| 25 | +fi |
| 26 | + |
| 27 | +BASE_BUILD=$(( BRANCH_NUMBER * 1000 )) |
| 28 | +BUILD=$(( BASE_BUILD > LAST_BUILD ? BASE_BUILD : LAST_BUILD )) |
| 29 | +BUILD_MINOR="$(( $BUILD % 1000 ))" |
| 30 | +DISPLAY_VERSION="${BRANCH_NUMBER}.${BUILD_MINOR}" |
| 31 | +TAG_NAME="v${DISPLAY_VERSION}" |
| 32 | + |
| 33 | +# Verify that the changelog has been updated. |
| 34 | +EXPECTED_CHANGELOG="### $TAG_NAME ($(date '+%Y-%m-%d'))" |
| 35 | +if [ "$(head -n 1 CHANGELOG.md)" != "$EXPECTED_CHANGELOG" ]; then |
| 36 | + echo "Changelog not updated. First line should be:" >&2 |
| 37 | + echo "$EXPECTED_CHANGELOG" >&2 |
| 38 | + exit 1 |
| 39 | +fi |
| 40 | + |
| 41 | +# The Windows EXE stores the version number as an integer, e.g. 75 for |
| 42 | +# build 75 within branch 0. See Sandstorm's release.sh for more |
| 43 | +# information. |
| 44 | +WINDOWS_EXE=windows-support/dist/innosetup/vagrant-spk-setup.exe |
| 45 | + |
| 46 | +echo "**** Building Windows EXE ****" |
| 47 | +(cd windows-support && make) |
| 48 | + |
| 49 | +echo "**** Tagging this commit ****" |
| 50 | + |
| 51 | +# The git tag stores the version number as a normal-looking version |
| 52 | +# number, like 0.75 for build 75 within branch 0, or 2.121 for build |
| 53 | +# 121 within branch 2. |
| 54 | + |
| 55 | +GIT_REVISION="$(git rev-parse HEAD)" |
| 56 | +git tag "$TAG_NAME" "$GIT_REVISION" -m "Release vagrant-spk ${DISPLAY_VERSION}" |
| 57 | + |
| 58 | +echo "**** Now is your chance to interrupt the process if you need! ^D to continue, ^C to stop ****" |
| 59 | +cat |
| 60 | + |
| 61 | +echo "**** Pushing build $BUILD ****" |
| 62 | + |
| 63 | +git push origin "$TAG_NAME" |
| 64 | +github-release release --draft --tag "$TAG_NAME" -u sandstorm-io -r vagrant-spk -d "$(python -c 's = open("CHANGELOG.md").read(); print s[:s.index("\n### ")-1]')" |
| 65 | +github-release upload -u sandstorm-io -r vagrant-spk -t "$TAG_NAME" -n "vagrant-spk-setup-$TAG_NAME.exe" --file "$WINDOWS_EXE" |
0 commit comments