1- name : CI and Release
1+ name : Release Workflow
22
33on :
44 push :
5- branches : [main]
5+ branches :
6+ - main
67 pull_request :
7- branches : [main]
8+ branches :
9+ - main
10+
11+ permissions :
12+ contents : write
813
914jobs :
10- check-version :
11- name : Check VERSION.txt updated in PR
15+ release :
1216 runs-on : ubuntu-latest
13- if : github.event_name == 'pull_request'
1417 steps :
1518 - name : Checkout code
16- uses : actions/checkout@v3
17- with :
18- fetch-depth : 0
19-
20- - name : Ensure VERSION.txt is updated
21- run : |
22- git fetch origin main
23- CHANGED=$(git diff --name-only origin/main...HEAD)
24- if ! echo "$CHANGED" | grep -qx VERSION.txt; then
25- echo "Error: VERSION.txt must be updated in this pull request."
26- exit 1
27- fi
28-
29- build :
30- name : Build Go project
31- runs-on : ubuntu-latest
32- steps :
33- - uses : actions/checkout@v3
19+ uses : actions/checkout@v4
3420
3521 - name : Set up Go
36- uses : actions/setup-go@v4
22+ uses : actions/setup-go@v5
3723 with :
38- go-version : 1.20
39-
40- - name : Download dependencies
41- run : go mod tidy
24+ go-version : ' 1.23'
4225
43- - name : Build binary
44- run : go build -o listener
26+ - name : Install GoReleaser
27+ run : go install github.com/goreleaser/goreleaser@latest
4528
46- release :
47- - name : Check version
29+ - name : Check version
4830 run : |
4931 VERSION=$(cat VERSION.txt)
5032 echo "version=$VERSION" >> $GITHUB_ENV
5133 echo "Version: $VERSION"
5234
35+ - name : Run build using goreleaser on local
36+ run : goreleaser release --snapshot --skip=publish --clean
37+
5338 - name : Create Tag
5439 if : |
5540 (github.event_name == 'push' && github.ref == 'refs/heads/main') ||
@@ -63,18 +48,16 @@ jobs:
6348 git tag "v${{ env.version }}"
6449 git push origin "v${{ env.version }}"
6550
66- - name : Create GitHub Release
51+ - name : Run GoReleaser Release
6752 if : |
6853 (github.event_name == 'push' && github.ref == 'refs/heads/main') ||
6954 (github.event_name == 'pull_request' &&
7055 github.event.action == 'closed' &&
7156 github.event.pull_request.merged == true &&
7257 github.event.pull_request.base.ref == 'main')
73- uses : softprops/action-gh-release@v2
74- with :
75- tag_name : v${{ env.version }}
76- name : Release v${{ env.version }}
77- files : build/monitor.bpf.o
78- # generate_release_notes: true
58+ run : |
59+ export GORELEASER_CURRENT_TAG="v${{ env.version }}"
60+ export GITHUB_TOKEN=${{ secrets.GITHUB_TOKEN }}
61+ goreleaser release --clean --rm-dist
7962 env :
80- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
63+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
0 commit comments