|
| 1 | +#!/usr/bin/env bash |
| 2 | +# |
| 3 | +# This script checks if we appear ready to build and publish a new release. |
| 4 | +# See the release instructions in README.md for the steps to make this pass. |
| 5 | + |
| 6 | +set -eEfuo pipefail |
| 7 | +trap 'printf "%s: Check failed. Stopping.\n" "$0" >&2' ERR |
| 8 | + |
| 9 | +readonly version_path='VERSION' |
| 10 | +readonly changes_path='doc/source/changes.rst' |
| 11 | + |
| 12 | +printf 'Checking current directory.\n' |
| 13 | +test "$(cd -- "$(dirname -- "$0")" && pwd)" = "$(pwd)" # Ugly, but portable. |
| 14 | + |
| 15 | +printf 'Checking that %s and %s exist and have no committed changes.\n' \ |
| 16 | + "$version_path" "$changes_path" |
| 17 | +test -f "$version_path" |
| 18 | +test -f "$changes_path" |
| 19 | +git status -s -- "$version_path" "$changes_path" |
| 20 | +test -z "$(git status -s -- "$version_path" "$changes_path")" |
| 21 | + |
| 22 | +# This section can be commented out, if absolutely necessary. |
| 23 | +printf 'Checking that ALL changes are committed.\n' |
| 24 | +git status -s |
| 25 | +test -z "$(git status -s)" |
| 26 | + |
| 27 | +printf 'Gathering current version, latest tag, and current HEAD commit info.\n' |
| 28 | +version_version="$(cat "$version_path")" |
| 29 | +changes_version="$(awk '/^[0-9]/ {print $0; exit}' "$changes_path")" |
| 30 | +config_opts="$(printf ' -c versionsort.suffix=-%s' alpha beta pre rc RC)" |
| 31 | +latest_tag="$(git $config_opts tag -l '[0-9]*' --sort=-v:refname | head -n1)" |
| 32 | +head_sha="$(git rev-parse HEAD)" |
| 33 | +latest_tag_sha="$(git rev-parse "$latest_tag")" |
| 34 | + |
| 35 | +# Display a table of all the current version, tag, and HEAD commit information. |
| 36 | +printf '%-14s = %s\n' 'VERSION file' "$version_version" \ |
| 37 | + 'changes.rst' "$changes_version" \ |
| 38 | + 'Latest tag' "$latest_tag" \ |
| 39 | + 'HEAD SHA' "$head_sha" \ |
| 40 | + 'Latest tag SHA' "$latest_tag_sha" |
| 41 | + |
| 42 | +# Check that latest tag matches version and is the current HEAD we're releasing |
| 43 | +test "$version_version" = "$changes_version" |
| 44 | +test "$latest_tag" = "$version_version" |
| 45 | +test "$head_sha" = "$latest_tag_sha" |
| 46 | +printf 'OK, everything looks good.\n' |
0 commit comments