-
Notifications
You must be signed in to change notification settings - Fork 427
55 lines (44 loc) · 1.53 KB
/
release.yml
File metadata and controls
55 lines (44 loc) · 1.53 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
name: Release
on:
push:
tags:
- 'v*'
jobs:
build:
permissions: write-all
name: Build Release
runs-on: ubuntu-latest
steps:
- name: Check out code into the Go module directory
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Validate tag matches version in main.go
run: |
# Extract version from main.go
VERSION=$(grep -E '^[[:space:]]*version[[:space:]]*=' main.go | sed -E 's/.*"([^"]+)".*/\1/')
# Get the tag name (remove refs/tags/ prefix)
TAG_NAME=${GITHUB_REF#refs/tags/}
# Remove 'v' prefix from tag if present
TAG_VERSION=${TAG_NAME#v}
echo "Version in main.go: $VERSION"
echo "Tag version: $TAG_VERSION"
# Compare versions
if [ "$VERSION" != "$TAG_VERSION" ]; then
echo "ERROR: Tag version ($TAG_VERSION) does not match version in main.go ($VERSION)"
echo "Please ensure the tag matches the version defined in main.go"
exit 1
fi
echo "✅ Tag version matches main.go version: $VERSION"
- name: Set up Go 1.23
uses: actions/setup-go@v4
with:
go-version: '1.23'
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_REPO_TOKEN: ${{ secrets.BREW_TOKEN }}