Skip to content

Commit 69a8bd6

Browse files
authored
feat: tag release with vX (major) (#35)
Github Actions/Workflow are usually tagged with v(major) alongside the primary version v(major).(minor).(patch) v(major) always follows the latest v(major).(minor).(patch) version. We have this in other workflows, but was missing here.
1 parent 9ca6ea1 commit 69a8bd6

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Release Tagger
2+
on:
3+
release:
4+
types:
5+
- released
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.ref }}
8+
cancel-in-progress: true
9+
jobs:
10+
tag:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- name: Checkout
14+
uses: actions/checkout@v4
15+
- name: Setup Git
16+
run: |
17+
git config --local user.email "actions@github.com"
18+
git config --local user.name "GitHub Actions"
19+
- name: Remove old tag and tag main with vX
20+
run: |
21+
git fetch --all
22+
git checkout main
23+
# Extract vX from vX.Y.Z
24+
NEW_TAG=$(echo "${{ github.event.release.tag_name }}" | cut -d'.' -f1)
25+
# Check if tag already exists and delete if it does
26+
if git show-ref --tags $NEW_TAG; then
27+
git tag -d $NEW_TAG
28+
git push --delete origin $NEW_TAG
29+
fi
30+
# Create new tag
31+
git tag $NEW_TAG
32+
git push origin refs/tags/$NEW_TAG

0 commit comments

Comments
 (0)