-
Notifications
You must be signed in to change notification settings - Fork 2
85 lines (71 loc) · 2.36 KB
/
Copy pathrelease.yml
File metadata and controls
85 lines (71 loc) · 2.36 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
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
jobs:
test:
name: Test before release
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Run tests
run: go test -v -race ./...
release:
name: Release
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: go.mod
- name: Get version info
id: version
run: |
# Extract version from tag (remove 'v' prefix)
VERSION=${GITHUB_REF_NAME#v}
COMMIT=$(git rev-parse --short HEAD)
DATE=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
echo "version=$VERSION" >> $GITHUB_OUTPUT
echo "commit=$COMMIT" >> $GITHUB_OUTPUT
echo "date=$DATE" >> $GITHUB_OUTPUT
echo "Version: $VERSION, Commit: $COMMIT, Date: $DATE"
- name: Update version.go
run: |
VERSION="${{ steps.version.outputs.version }}"
COMMIT="${{ steps.version.outputs.commit }}"
DATE="${{ steps.version.outputs.date }}"
# Update version.go with release values
sed -i "s/Version = \"dev\"/Version = \"$VERSION\"/" internal/version/version.go
sed -i "s/Commit = \"none\"/Commit = \"$COMMIT\"/" internal/version/version.go
sed -i "s/Date = \"unknown\"/Date = \"$DATE\"/" internal/version/version.go
sed -i "s/BuildSource = \"source\"/BuildSource = \"release\"/" internal/version/version.go
echo "Updated version.go:"
cat internal/version/version.go
- name: Vendor dependencies
run: go mod vendor
- name: Install Syft
uses: anchore/sbom-action/download-syft@v0
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v2"
args: release --clean --skip=validate
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}