Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,40 @@ on:
types: [published]

jobs:
tag-major:
tag-aliases:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

- name: Move major version tag
- name: Move major and minor version tags
if: ${{ !github.event.release.prerelease }}
env:
GH_TOKEN: ${{ github.token }}
run: |
VERSION="${{ github.event.release.tag_name }}"

# Only move the major tag if this is the latest release for the repo
# Only move tags if this is the latest release for the repo
LATEST=$(gh release view --repo "${{ github.repository }}" --json tagName -q .tagName)
if [ "$LATEST" != "$VERSION" ]; then
echo "Skipping: $VERSION is not the latest release (latest is $LATEST)"
exit 0
fi

MAJOR="v$(echo "$VERSION" | sed 's/^v//' | cut -d. -f1)"
STRIPPED="${VERSION#v}"
PARTS="$(echo "$STRIPPED" | tr '.' '\n' | wc -l)"
MAJOR="v$(echo "$STRIPPED" | cut -d. -f1)"

# Always move the major tag (e.g. v1)
echo "Updating major tag: $MAJOR"
git tag -f "$MAJOR"
git push origin "refs/tags/$MAJOR" --force

# Move the minor tag only if version has 3+ parts (e.g. v1.1.0 → v1.1)
if [ "$PARTS" -ge 3 ]; then
MINOR="v$(echo "$STRIPPED" | cut -d. -f1).$(echo "$STRIPPED" | cut -d. -f2)"
echo "Updating minor tag: $MINOR"
git tag -f "$MINOR"
git push origin "refs/tags/$MINOR" --force
fi