Skip to content

Commit ed32fb7

Browse files
committed
refactor: use semantic-release for auto-tagging and release
1 parent f76b394 commit ed32fb7

2 files changed

Lines changed: 24 additions & 20 deletions

File tree

.github/workflows/release.yml

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,43 +8,36 @@ on:
88

99
permissions:
1010
contents: write
11+
issues: write
12+
pull-requests: write
1113

1214
jobs:
13-
goreleaser:
15+
release:
1416
runs-on: ubuntu-latest
1517
steps:
1618
- name: Checkout
1719
uses: actions/checkout@v4
1820
with:
1921
fetch-depth: 0
2022

23+
- name: Set up Node.js
24+
uses: actions/setup-node@v4
25+
with:
26+
node-version: "lts/*"
27+
2128
- name: Set up Go
2229
uses: actions/setup-go@v4
2330
with:
2431
go-version: "1.21"
2532

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-
43-
- name: Run GoReleaser
33+
- name: Install GoReleaser
4434
uses: goreleaser/goreleaser-action@v6
4535
with:
4636
distribution: goreleaser
4737
version: "~> v2"
48-
args: release --clean
38+
install-only: true
39+
40+
- name: Run semantic-release
41+
run: npx semantic-release
4942
env:
5043
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.releaserc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"branches": ["main"],
3+
"plugins": [
4+
"@semantic-release/commit-analyzer",
5+
"@semantic-release/release-notes-generator",
6+
"@semantic-release/git",
7+
["@semantic-release/exec", {
8+
"publishCmd": "echo \"${nextRelease.notes}\" > /tmp/release-notes.md && goreleaser release --clean --release-notes /tmp/release-notes.md"
9+
}]
10+
]
11+
}

0 commit comments

Comments
 (0)