Skip to content

Commit f3c875b

Browse files
ci: add release workflow to auto-update major version tag on publish
Co-Authored-By: Niels Swimberghe <3382717+Swimburger@users.noreply.github.com>
1 parent 2106203 commit f3c875b

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
tag-major:
9+
runs-on: ubuntu-latest
10+
permissions:
11+
contents: write
12+
steps:
13+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
14+
15+
- name: Move major version tag
16+
if: ${{ !github.event.release.prerelease }}
17+
env:
18+
GH_TOKEN: ${{ github.token }}
19+
run: |
20+
VERSION="${{ github.event.release.tag_name }}"
21+
22+
# Only move the major tag if this is the latest release for the repo
23+
LATEST=$(gh release view --repo "${{ github.repository }}" --json tagName -q .tagName)
24+
if [ "$LATEST" != "$VERSION" ]; then
25+
echo "Skipping: $VERSION is not the latest release (latest is $LATEST)"
26+
exit 0
27+
fi
28+
29+
MAJOR="v$(echo "$VERSION" | sed 's/^v//' | cut -d. -f1)"
30+
git tag -f "$MAJOR"
31+
git push origin "refs/tags/$MAJOR" --force

0 commit comments

Comments
 (0)