Skip to content
Open
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
32 changes: 32 additions & 0 deletions .github/workflows/update-major-version-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Update Major Version Tag

on:
release:
types: [published]

permissions:
contents: write

jobs:
update-tag:
# Skip pre-releases
if: ${{ !github.event.release.prerelease }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true

- name: Update major version tag
env:
TAG: ${{ github.event.release.tag_name }}
run: |
MAJOR=$(echo "$TAG" | grep -oP '^v\d+')

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Ensure only valid semver tags are matched.
  • Do not run if tag contains prerelease e.g 2.0.1-rc1
  • Check all tags and verify that this is the highest tag for this version e.g. if 2.7.3 exists, and this is 2.6.9, do not update the major tag.

if [ -z "$MAJOR" ]; then
echo "::error::Could not extract major version from tag '$TAG'"
exit 1
fi
echo "Updating floating tag $MAJOR to point to $TAG"
git tag -f "$MAJOR" "$TAG"
git push -f origin "$MAJOR"