Skip to content

Commit

Permalink
use gh release view to determine previous release version
Browse files Browse the repository at this point in the history
  • Loading branch information
aryairani committed Mar 21, 2024
1 parent d25e0ef commit b7d5d41
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 71 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ on:
description: Release version; e.g. `0.5.19`. We'll create tag `release/${version}`.
required: true
type: string
prev_version:
description: Previous release to generate notes since; e.g. `0.5.18`
required: true
type: string
target:
description: Git ref to use for this release; defaults to `trunk`.
required: true
Expand Down Expand Up @@ -50,14 +46,15 @@ jobs:
run: |
version="${{inputs.version}}"
target="${{inputs.target}}"
prev_version="${{inputs.prev_version}}"
prev_tag="$(gh release view --json tagName -t '{{printf .tagName}}')"
if [ -z "$prev_tag" ]; then echo "No previous release found"; exit 1; fi
echo "Creating a release from these artifacts:"
ls -R /tmp/ucm
gh release create "release/${version}" \
--target "${target}" \
--generate-notes \
--notes-start-tag "release/${prev_version}" \
--notes-start-tag "${prev_tag}" \
\
/tmp/ucm/**/*.{zip,tar.gz}
34 changes: 19 additions & 15 deletions scripts/make-release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,31 @@

set -e

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

prev_tag="$(gh release view --json tagName -t '{{printf .tagName}}')"

usage() {
echo "NOTE: must be run from the root of the project."
echo "Usage: $0 VERSION [TARGET]"
echo "VERSION: The version you're releasing, e.g. M4a"
echo "TARGET: The revision to make the release from, defaults to 'origin/trunk'"
prev_version="${prev_tag#release/}"
prefix="${prev_version%.*}"
next_version="${prefix}.$(( ${prev_version##*.} + 1 ))"
echo "usage: $0 <version> [target]"
echo ""
echo "E.g."
echo "$0 M4a"
echo "version: The new version number"
echo "target: The Git revision to make the release from, defaults to 'origin/trunk'"
echo ""
echo "I think the latest release is: $(git tag --list 'release/*' | grep -v M | sort -rV | head -n 1 | sed 's/release\///')"
echo "Try: $0 $next_version"
}

if [[ -z "$1" ]] ; then
usage
exit 1
fi

if ! command -V "gh" >/dev/null 2>&1; then
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
Expand All @@ -38,19 +38,23 @@ if ! [[ "$1" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] ; then
fi

version="${1}"
prev_version=$("${script_dir}/previous-tag.sh" "$version")
target=${2:-origin/trunk}
tag="release/${version}"
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 "Creating release in unison-local-ui."
gh release create "release/${version}" \
--repo unisonweb/unison-local-ui \
--target main \
--generate-notes --notes-start-tag "$prev_tag"

echo "Kicking off release workflow in unisonweb/unison"
# Make sure our origin/trunk ref is up to date, since that's usually what gets tagged.
git fetch origin trunk
git tag "${tag}" "${target}"
git push origin "${tag}"
gh workflow run release --repo unisonweb/unison --field "version=${version}"
gh workflow run release --repo unisonweb/unison \
--field "version=${version}" \
--field "target=${target}"

echo "Kicking off Homebrew update task"
gh workflow run release --repo unisonweb/homebrew-unison --field "version=${version}"
Expand Down
50 changes: 0 additions & 50 deletions scripts/previous-tag.sh

This file was deleted.

0 comments on commit b7d5d41

Please sign in to comment.