1+ name : Release
2+
3+ on :
4+ pull_request :
5+ push :
6+
7+ permissions :
8+ contents : write
9+ id-token : write
10+ packages : write
11+
12+ jobs :
13+ lint :
14+ name : Lint
15+ runs-on : ubuntu-latest
16+ steps :
17+ - uses : actions/checkout@v4
18+ - name : Set up Go
19+ uses : actions/setup-go@v5
20+ with :
21+ go-version-file : ' go.mod'
22+ - name : golangci-lint
23+ uses : golangci/golangci-lint-action@v8
24+ with :
25+ only-new-issues : true
26+
27+ releaser :
28+ name : Release
29+ runs-on : ubuntu-latest
30+ steps :
31+ - name : Checkout
32+ uses : actions/checkout@v4
33+ with :
34+ fetch-depth : 0
35+
36+ - name : Set up Go
37+ uses : actions/setup-go@v5
38+ with :
39+ go-version-file : ' go.mod'
40+
41+ - name : Set AUTOUPDATE_CHANNEL on tags
42+ run : echo "AUTOUPDATE_CHANNEL=stable" >> $GITHUB_ENV
43+ if : startsWith(github.ref, 'refs/tags/v')
44+
45+ - name : Prepare
46+ run : go generate ./...
47+
48+ - name : Check Git status
49+ id : git
50+ run : |
51+ RESULT=$(git status --untracked-files=no --porcelain)
52+ echo "gitstatus=$RESULT" >> $GITHUB_OUTPUT
53+
54+ - name : Check if go prepare updated generated Go code
55+ if : steps.git.outputs.gitstatus != '' && startsWith(github.ref, 'refs/tags/v')
56+ run : |
57+ echo '"go generate" changed some Go generated code, run "go generate ./" locally and make a Pull Request with the changes'
58+ git diff
59+ exit 1
60+
61+ # - name: Test
62+ # run: go test -v ./...
63+
64+ - name : Validate build
65+ run : go run .
66+
67+ # - name: Set up cosign
68+ # uses: sigstore/cosign-installer@v3
69+
70+ - name : Run GoReleaser for snapshot
71+ uses : goreleaser/goreleaser-action@v6
72+ # only for PRs and push on branches
73+ if : ${{ !startsWith(github.ref, 'refs/tags/v') }}
74+ with :
75+ version : ' ~> v2'
76+ args : release --clean --snapshot --skip=publish,sign
77+ env :
78+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
79+
80+ - name : Run GoReleaser
81+ uses : goreleaser/goreleaser-action@v6
82+ # only for tags
83+ if : startsWith(github.ref, 'refs/tags/v')
84+ with :
85+ version : ' ~> v2'
86+ args : release --clean
87+ env :
88+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
89+
90+ - name : Archive binaries
91+ uses : actions/upload-artifact@v4
92+ with :
93+ retention-days : 5
94+ name : binaries
95+ path : dist
96+
97+ - name : Archive Linux binary
98+ uses : actions/upload-artifact@v4
99+ with :
100+ retention-days : 5
101+ name : linux-binary
102+ path : dist/kyx_linux_amd64.tar.gz
0 commit comments