Skip to content

Commit ac511fd

Browse files
committed
semver addition
1 parent 5b53fa1 commit ac511fd

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

.github/workflows/release.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Release on merge of versioned branch into main
2+
3+
on:
4+
pull_request:
5+
types: [closed]
6+
branches:
7+
- main
8+
9+
jobs:
10+
release:
11+
if: github.event.pull_request.merged == true && startsWith(github.event.pull_request.head.ref, 'v')
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- name: Checkout code
16+
uses: actions/checkout@v4
17+
18+
- name: Extract version from branch name
19+
run: echo "VERSION=${GITHUB_HEAD_REF}" >> $GITHUB_ENV
20+
21+
- name: Set up Go
22+
uses: actions/setup-go@v5
23+
with:
24+
go-version: '1.24.4'
25+
26+
- name: Build with version
27+
run: go build -ldflags "-X main.Version=${VERSION}" -o req
28+
29+
- name: Tag main with version
30+
run: |
31+
git config user.name "github-actions"
32+
git config user.email "github-actions@github.com"
33+
git fetch --unshallow --tags
34+
git tag "${VERSION}"
35+
git push origin "${VERSION}"
36+
37+
- name: Create GitHub Release
38+
uses: softprops/action-gh-release@v2
39+
with:
40+
tag_name: ${{ env.VERSION }}
41+
files: req
42+
env:
43+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ var (
3535
DB *sql.DB
3636
)
3737

38+
var Version = "dev"
39+
3840
func initPaths() error {
3941
// setup paths using OS-appropriate cache directory
4042
userHomeDir, err := os.UserHomeDir()

0 commit comments

Comments
 (0)