unison/scripts/make-release.sh

60 lines
1.8 KiB
Bash
Raw Normal View History

#!/bin/bash
set -e
2023-08-29 20:45:48 +03:00
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
if [[ "$1" = "--status" ]]; then
gh workflow view release --repo unisonweb/unison
gh workflow view release --repo unisonweb/homebrew-unison
fi
usage() {
echo "NOTE: must be run from the root of the project."
2023-08-08 19:10:48 +03:00
echo "Usage: $0 VERSION [TARGET]"
echo "VERSION: The version you're releasing, e.g. M4a"
2022-10-19 01:57:24 +03:00
echo "TARGET: The revision to make the release from, defaults to 'trunk'"
echo ""
echo "E.g."
echo "$0 M4a"
}
2023-08-08 19:10:48 +03:00
if [[ -z "$1" ]] ; then
usage
exit 1
fi
if ! command -V "gh" >/dev/null 2>&1; then
echo "Required command \`gh\` not found, find installation instructions here: https://cli.github.com/manual/installation"
exit 1
fi
if ! [[ "$1" =~ ^M[0-9]+[a-z]?$ ]] ; then
echo "Version tag must be of the form 'M4' or 'M4a'"
usage
exit 1
fi
version="${1}"
2023-08-29 20:45:48 +03:00
prev_version=$("${script_dir}/previous-tag.sh" "$version")
2023-08-08 19:10:48 +03:00
target=${2:-trunk}
tag="release/${version}"
echo "Creating release in unison-local-ui..."
gh release create "release/${version}" --repo unisonweb/unison-local-ui --target main --generate-notes --notes-start-tag "release/${prev_version}"
echo "Kicking off release workflow in unisonweb/unison"
git tag "${tag}" "${target}"
git push origin "${tag}"
2023-08-08 19:10:48 +03:00
gh workflow run release --repo unisonweb/unison --field "version=${version}"
echo "Kicking off Homebrew update task"
gh workflow run release --repo unisonweb/homebrew-unison --field "version=${version}"
echo "Opening relevant workflows in browser"
gh workflow view release --web --repo unisonweb/homebrew-unison || true
gh workflow view release --web --repo unisonweb/unison || true
echo "Okay! All the work has been kicked off, it may take several hours to complete."
echo "Run '$0 --status' to see job status."