Skip to content

Commit 24819a9

Browse files
author
Luca Esposito
committed
feat: adding new auto-tag-creation.yml workflow
1 parent 3fd1ded commit 24819a9

1 file changed

Lines changed: 21 additions & 6 deletions

File tree

.github/workflows/auto-tag-creation.yml

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
2+
- name: Create new tag and push
3+
run: |
4+
NEW_TAG=${{ steps.bump_tag.outputs.new_tag }}
5+
git config user.name "github-actions[bot]"
6+
git config user.email "github-actions[bot]@lesposito87.noreply.github.com"
7+
git tag "$NEW_TAG"
8+
git push origin "$NEW_TAG"
9+
110
name: Auto Tag on Main Push
211

312
on:
@@ -15,12 +24,11 @@ jobs:
1524
- name: Checkout code
1625
uses: actions/checkout@v4
1726
with:
18-
fetch-depth: 0 # important to get all tags
27+
fetch-depth: 0 # needed to fetch tags and full history
1928

2029
- name: Get latest tag
2130
id: get_tag
2231
run: |
23-
# Get latest tag (v* format) or default to v1.0.0
2432
TAG=$(git tag --sort=-v:refname | grep -E '^v[0-9]+\.[0-9]+\.[0-9]+$' | head -n 1)
2533
echo "Latest tag: $TAG"
2634
@@ -34,18 +42,25 @@ jobs:
3442
id: bump_tag
3543
run: |
3644
TAG=${{ steps.get_tag.outputs.tag }}
37-
echo "Current tag: $TAG"
38-
3945
VERSION=${TAG#v}
4046
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
4147
NEW_TAG="v$MAJOR.$MINOR.$((PATCH + 1))"
4248
4349
echo "new_tag=$NEW_TAG" >> $GITHUB_OUTPUT
4450
45-
- name: Create new tag and push
51+
- name: Get last commit message (PR title)
52+
id: commit_msg
53+
run: |
54+
MSG=$(git log -1 --pretty=%s)
55+
echo "msg=$MSG" >> $GITHUB_OUTPUT
56+
57+
- name: Create new tag with PR title
4658
run: |
4759
NEW_TAG=${{ steps.bump_tag.outputs.new_tag }}
60+
MESSAGE=${{ steps.commit_msg.outputs.msg }}
61+
4862
git config user.name "github-actions[bot]"
4963
git config user.email "github-actions[bot]@lesposito87.noreply.github.com"
50-
git tag "$NEW_TAG"
64+
65+
git tag -a "$NEW_TAG" -m "$MESSAGE"
5166
git push origin "$NEW_TAG"

0 commit comments

Comments
 (0)