-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (75 loc) · 2.57 KB
/
Copy pathrelease.yml
File metadata and controls
89 lines (75 loc) · 2.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v7
with:
fetch-depth: 0
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Go
uses: actions/setup-go@v7
with:
go-version: '1.25'
- name: Extract version from tag
id: version
run: |
VERSION=${GITHUB_REF#refs/tags/}
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "Version: $VERSION"
- name: Verify tag format
run: |
if [[ ! "${{ steps.version.outputs.version }}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-.*)?$ ]]; then
echo "Error: Tag must follow semantic versioning (vMAJOR.MINOR.PATCH)"
exit 1
fi
- name: Run tests
run: |
make deps
make test
env:
CI: true
- name: Update README version badge
run: |
VERSION="${{ steps.version.outputs.version }}"
# Update the "Latest Release" line in README.md
sed -i "s|> \*\*Latest Release\*\*: \[v[0-9.]\+\](https://github.com/IceTweak/hyperacc/releases/tag/v[0-9.]\+)|> **Latest Release**: [$VERSION](https://github.com/IceTweak/hyperacc/releases/tag/$VERSION)|" README.md
- name: Commit README update
run: |
if git diff --quiet README.md; then
echo "No README changes needed"
else
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add README.md
git commit -m "docs: update README version to ${{ steps.version.outputs.version }} [skip ci]"
git push
fi
- name: Generate changelog
id: changelog
uses: metcalfc/changelog-generator@v4.7.0
with:
myToken: ${{ secrets.GITHUB_TOKEN }}
excludeTypes: '["other"]'
- name: Create Release
uses: softprops/action-gh-release@v3
with:
name: Release ${{ steps.version.outputs.version }}
body: |
## Changes in ${{ steps.version.outputs.version }}
${{ steps.changelog.outputs.changelog }}
## Installation
```bash
go get github.com/IceTweak/hyperacc@${{ steps.version.outputs.version }}
```
draft: false
prerelease: ${{ contains(steps.version.outputs.version, '-') }}
generate_release_notes: true