|
| 1 | +#!/bin/bash -eu |
| 2 | +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")"; pwd)" # Figure out where the script is running |
| 3 | +. "$SCRIPT_DIR"/lib/robust-bash.sh |
| 4 | + |
| 5 | +require_env_var CI "This script must be run from CI. If you are running locally, note that it stamps your repo git settings." |
| 6 | +require_env_var GITHUB_ACTOR |
| 7 | +require_env_var NODE_AUTH_TOKEN |
| 8 | + |
| 9 | +# Setup git for github actions |
| 10 | +git config user.email "${GITHUB_ACTOR}@users.noreply.github.com" |
| 11 | +git config user.name "${GITHUB_ACTOR}" |
| 12 | + |
| 13 | +# It's easier to read the release notes |
| 14 | +# from the standard version tool before it runs |
| 15 | +RELEASE_NOTES="$(npx standard-version --dry-run | awk 'BEGIN { flag=0 } /^---$/ { if (flag == 0) { flag=1 } else { flag=2 }; next } flag == 1')" |
| 16 | +# Don't release if there are no changes |
| 17 | +if [ "$(echo "$RELEASE_NOTES" | wc -l)" -eq 1 ] ; then |
| 18 | + echo "ERROR: This release would have no release notes. Does it include changes?" |
| 19 | + echo " - You must have at least one fix / feat commit to generate release notes" |
| 20 | + echo "*** STOPPING RELEASE PROCESS ***" |
| 21 | + exit 1 |
| 22 | +fi |
| 23 | +# This is github actions' method for emitting multi-line values |
| 24 | +RELEASE_NOTES="${RELEASE_NOTES//'%'/'%25'}" |
| 25 | +RELEASE_NOTES="${RELEASE_NOTES//$'\n'/'%0A'}" |
| 26 | +RELEASE_NOTES="${RELEASE_NOTES//$'\r'/'%0D'}" |
| 27 | +echo "::set-output name=notes::$RELEASE_NOTES" |
| 28 | + |
| 29 | +"$SCRIPT_DIR"/build-and-test.sh |
| 30 | +npm run release |
| 31 | + |
| 32 | +# Emit version to next step |
| 33 | +VERSION="$("$SCRIPT_DIR/lib/get-version.sh")" |
| 34 | +echo "::set-output name=version::$VERSION" |
| 35 | + |
| 36 | +"$SCRIPT_DIR"/lib/publish.sh |
| 37 | + |
| 38 | +# Push the new commit back to the repo. |
| 39 | +git push --follow-tags |
0 commit comments