11
11
- 'main'
12
12
paths:
13
13
- '.github/workflows/build-release.yml'
14
+ - 'cmd/**'
15
+ - 'pkg/**'
16
+ - 'internal/**'
17
+ - 'go.mod'
18
+ - 'go.sum'
14
19
- 'templates/**'
15
20
- 'tests/**'
16
21
- 'manifest.yaml'
17
22
- 'stencil.yaml'
23
+ - '.goreleaser.yaml'
24
+ - '.mise.toml'
18
25
19
26
env:
20
27
GH_ROLE_ARN: arn:aws:iam::602046956384:role/GithubActions-github-actions-services-repos-Role
56
63
with:
57
64
persist-credentials: false
58
65
token: { { " ${{ steps.generate_token.outputs.token }}" } }
66
+ # These two required for builds to successfully amend commits
67
+ ref: { { " ${{ github.head_ref }}" } }
68
+ fetch-depth: 2
59
69
- name: Install Tool Versions
60
70
uses: jdx/mise-action@052520c41a328779551db19a76697ffa34f3eabc
61
71
with:
@@ -67,13 +77,46 @@ jobs:
67
77
with:
68
78
github-token: { { " ${{ github.token }}" } }
69
79
version: 'latest'
80
+ { {- if stencil.Arg " nativeModule" } }
81
+ - name: Get Go directories
82
+ id: go
83
+ run: |
84
+ echo "cache_dir=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
85
+ echo "mod_cache_dir=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
86
+ - uses: actions/cache@v4
87
+ with:
88
+ path: { { " ${{ steps.go.outputs.cache_dir }}" } }
89
+ key: { { " ${{ github.workflow }}-${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }}" } }
90
+ - uses: actions/cache@v4
91
+ with:
92
+ path: { { " ${{ steps.go.outputs.mod_cache_dir }}" } }
93
+ key: { { " ${{ github.workflow }}-${{ runner.os }}-go-mod-cache-${{ hashFiles('go.sum') }}" } }
94
+ - name: Lint
95
+ uses: golangci/golangci-lint-action@v4
96
+ with:
97
+ version: latest
98
+ # We already use setup-go's pkg cache and actions/cache's build cache, so don't double-up
99
+ skip-pkg-cache: true
100
+ skip-build-cache: true
101
+ args: --timeout=6m
102
+ - name: Build Go binary
103
+ run: mise run build
104
+ - name: Run Go Tests
105
+ run: go run gotest.tools/gotestsum@v1.11.0
106
+ ## <<Stencil::Block (gotestvars) >>
107
+ { { file.Block " gotestvars" } }
108
+ ## <</Stencil::Block >>
109
+ { {- end } }
70
110
## <<Stencil::Block (buildtestauth) >>
71
111
{ { file.Block " buildtestauth" } }
72
112
## <</Stencil::Block >>
73
113
- name: Build Test repo
74
114
run: mise run buildtest
75
115
env:
76
116
GITHUB_TOKEN: { { " ${{ steps.generate_token.outputs.token }}" } }
117
+ ## <<Stencil::Block (buildTestEnvVars) >>
118
+ { { file.Block " buildTestEnvVars" } }
119
+ ## <</Stencil::Block >>
77
120
- name: Run Tests
78
121
run: mise run runtest
79
122
env:
@@ -95,16 +138,70 @@ jobs:
95
138
- name: Checkout
96
139
uses: actions/checkout@v4
97
140
with:
141
+ fetch-depth: 0
142
+ fetch-tags: true
98
143
token: { { " ${{ secrets.GITHUB_TOKEN }}" } }
144
+ - name: Set git User
145
+ run: |
146
+ git config user.name github-actions
147
+ git config user.email github-actions@github.com
99
148
- name: Install Tool Versions
100
149
uses: jdx/mise-action@052520c41a328779551db19a76697ffa34f3eabc
101
150
with:
102
151
experimental: true
103
152
env:
104
153
GH_TOKEN: { { " ${{ secrets.GITHUB_TOKEN }}" } }
154
+ { {- if stencil.Arg " nativeModule" } }
155
+ - name: Get Go directories
156
+ id: go
157
+ run: |
158
+ echo "cache_dir=$(go env GOCACHE)" >> "$GITHUB_OUTPUT"
159
+ echo "mod_cache_dir=$(go env GOMODCACHE)" >> "$GITHUB_OUTPUT"
160
+ - uses: actions/cache@v4
161
+ with:
162
+ path: { { " ${{ steps.go.outputs.cache_dir }}" } }
163
+ key: { { " ${{ github.workflow }}-${{ runner.os }}-go-build-cache-${{ hashFiles('**/go.sum') }}" } }
164
+ - uses: actions/cache@v4
165
+ with:
166
+ path: { { " ${{ steps.go.outputs.mod_cache_dir }}" } }
167
+ key: { { " ${{ github.workflow }}-${{ runner.os }}-go-mod-cache-${{ hashFiles('go.sum') }}" } }
168
+ - name: Retrieve goreleaser version
169
+ run: |-
170
+ echo "version=$(mise current goreleaser)" >> "$GITHUB_OUTPUT"
171
+ id: goreleaser
172
+ - name: Get next version
173
+ id: next_version
174
+ run: |-
175
+ get-next-version --target github-action
176
+ - name: Create Tag
177
+ if: { { " ${{ steps.next_version.outputs.hasNextVersion == 'true' }}" } }
178
+ run: |-
179
+ git tag -a { { " \" v${{ steps.next_version.outputs.version }}\" -m \" Release v${{ steps.next_version.outputs.version }}\" " } }
180
+ - name: Generate CHANGELOG
181
+ if: { { " ${{ steps.next_version.outputs.hasNextVersion == 'true' }}" } }
182
+ run: |-
183
+ mise run changelog
184
+ - name: Create release artifacts and Github Release
185
+ if: { { " ${{ steps.next_version.outputs.hasNextVersion == 'true' }}" } }
186
+ uses: goreleaser/goreleaser-action@v6
187
+ with:
188
+ distribution: goreleaser
189
+ version: { { " v${{ steps.goreleaser.outputs.version }}" } }
190
+ args: release --release-notes CHANGELOG.md --clean
191
+ env:
192
+ GITHUB_TOKEN: { { " ${{ secrets.GITHUB_TOKEN }}" } }
193
+ ## <<Stencil::Block (goreleaserEnvVars) >>
194
+ { { file.Block " goreleaserEnvVars" } }
195
+ ## <</Stencil::Block >>
196
+ { {- else } }
105
197
- name: Install Semantic-Release
106
198
run: yarn install
107
199
- name: Release
108
200
env:
109
201
GITHUB_TOKEN: { { " ${{ secrets.GITHUB_TOKEN }}" } }
110
202
run: npx semantic-release
203
+ { {- end } }
204
+
205
+ ## <<Stencil::Block (extraActions) >>
206
+ { { file.Block " extraActions" } }
207
+ ## <</Stencil::Block >>
0 commit comments