Skip to content

Commit f76b394

Browse files
committed
fix: auto-tag on main push before goreleaser release
1 parent 9875a5b commit f76b394

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ name: Release
22

33
on:
44
push:
5-
tags:
6-
- "v*"
5+
branches:
6+
- main
77
workflow_dispatch:
8-
8+
99
permissions:
1010
contents: write
1111

@@ -23,6 +23,23 @@ jobs:
2323
with:
2424
go-version: "1.21"
2525

26+
- name: Auto-tag
27+
run: |
28+
latest_tag=$(git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0")
29+
version=${latest_tag#v}
30+
IFS='.' read -r major minor patch <<< "$version"
31+
feat_count=$(git log "$latest_tag"..HEAD --oneline --grep='^feat[(:]' | wc -l)
32+
if [ "$feat_count" -gt 0 ]; then
33+
minor=$((minor + 1))
34+
patch=0
35+
else
36+
patch=$((patch + 1))
37+
fi
38+
new_tag="v$major.$minor.$patch"
39+
echo "Creating tag $new_tag"
40+
git tag "$new_tag"
41+
git push origin "$new_tag"
42+
2643
- name: Run GoReleaser
2744
uses: goreleaser/goreleaser-action@v6
2845
with:

0 commit comments

Comments
 (0)