forked from Dicklesworthstone/ntm
-
Notifications
You must be signed in to change notification settings - Fork 0
304 lines (271 loc) · 9.67 KB
/
release.yml
File metadata and controls
304 lines (271 loc) · 9.67 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
name: Release
on:
push:
tags:
- "v*"
permissions:
contents: write
packages: write
id-token: write # For cosign signing and attestations
attestations: write # For artifact attestations
env:
GO_VERSION: "1.25"
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
# ============================================================================
# RELEASE - Build and publish release artifacts
# ============================================================================
release:
name: Release
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
version: ${{ steps.version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Extract version
id: version
run: echo "version=${GITHUB_REF#refs/tags/v}" >> $GITHUB_OUTPUT
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Install Cosign
uses: sigstore/cosign-installer@v3
- name: Install Syft (for SBOM)
uses: anchore/sbom-action/download-syft@v0
- name: Run GoReleaser
id: goreleaser
uses: goreleaser/goreleaser-action@v6
with:
distribution: goreleaser
version: "~> v2"
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_GITHUB_TOKEN: ${{ secrets.HOMEBREW_TAP_GITHUB_TOKEN }}
SCOOP_GITHUB_TOKEN: ${{ secrets.SCOOP_GITHUB_TOKEN }}
- name: Upload Release Artifacts
uses: actions/upload-artifact@v4
with:
name: release-artifacts
path: dist/
retention-days: 30
# Generate attestations for release artifacts
- name: Attest build provenance
uses: actions/attest-build-provenance@v2
continue-on-error: true # Don't fail if attestation fails
with:
subject-path: |
dist/*.tar.gz
dist/*.zip
dist/checksums.txt
# ============================================================================
# DOCKER - Build and push multi-arch container images
# ============================================================================
docker:
name: Docker Images
runs-on: ubuntu-latest
timeout-minutes: 30
needs: release
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Check for Dockerfile
id: dockerfile
run: |
if [ -f Dockerfile ]; then
echo "exists=true" >> $GITHUB_OUTPUT
else
echo "exists=false" >> $GITHUB_OUTPUT
echo "No Dockerfile found, skipping Docker build"
fi
- name: Build and push
if: steps.dockerfile.outputs.exists == 'true'
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: true
sbom: true
# ============================================================================
# VERIFY - Verify release artifacts
# ============================================================================
verify:
name: Verify Release
runs-on: ubuntu-latest
timeout-minutes: 15
needs: release
steps:
- name: Download artifacts
uses: actions/download-artifact@v4
with:
name: release-artifacts
path: dist/
- name: List artifacts
run: |
echo "Release artifacts:"
ls -la dist/
echo ""
echo "Checksums:"
cat dist/checksums.txt || true
- name: Verify checksums
run: |
cd dist
if [ -f checksums.txt ]; then
echo "Verifying SHA256 checksums..."
sha256sum -c checksums.txt --ignore-missing
echo "All checksums verified successfully"
else
echo "No checksums.txt found"
exit 1
fi
- name: Verify archive contents
run: |
cd dist
echo "Verifying archive contents..."
for archive in *.tar.gz; do
if [ -f "$archive" ]; then
echo "Contents of $archive:"
tar -tzf "$archive" | head -20
echo ""
fi
done
for archive in *.zip; do
if [ -f "$archive" ]; then
echo "Contents of $archive:"
unzip -l "$archive" | head -20
echo ""
fi
done
# ============================================================================
# UPGRADE-VERIFY - Verify upgrade command works on all platforms
# This catches asset naming mismatches between upgrade.go and GoReleaser
# ============================================================================
upgrade-verify:
name: Verify Upgrade (${{ matrix.os }})
needs: release
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
goos: linux
goarch: amd64
- os: macos-latest
goos: darwin
goarch: arm64
- os: macos-13
goos: darwin
goarch: amd64
- os: windows-latest
goos: windows
goarch: amd64
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache: true
- name: Build ntm
run: go build -o ntm ./cmd/ntm
- name: Verify upgrade --check finds assets
shell: bash
run: |
echo "Testing upgrade --check on ${{ matrix.goos }}/${{ matrix.goarch }}"
# Run upgrade --check and capture output
if ./ntm upgrade --check 2>&1 | tee upgrade_output.txt; then
echo "Upgrade check passed"
else
echo "Upgrade check failed"
cat upgrade_output.txt
exit 1
fi
# Verify it found the correct asset (not "no suitable release asset")
if grep -q "no suitable release asset" upgrade_output.txt; then
echo "ERROR: upgrade --check could not find release asset for ${{ matrix.goos }}/${{ matrix.goarch }}"
echo "This indicates a mismatch between upgrade.go and .goreleaser.yaml"
exit 1
fi
echo "Asset naming contract verified for ${{ matrix.goos }}/${{ matrix.goarch }}"
# ============================================================================
# ANNOUNCE - Post-release notifications
# ============================================================================
announce:
name: Announce Release
runs-on: ubuntu-latest
timeout-minutes: 10
needs: [release, verify, upgrade-verify]
steps:
- name: Get release info
id: release
run: |
echo "tag=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
echo "Released ${GITHUB_REF#refs/tags/}"
- name: Create release summary
run: |
echo "# Release ${{ steps.release.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Installation" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo '```bash' >> $GITHUB_STEP_SUMMARY
echo "# Quick install" >> $GITHUB_STEP_SUMMARY
echo "curl -fsSL https://raw.githubusercontent.com/Dicklesworthstone/ntm/main/install.sh | bash" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "# Homebrew" >> $GITHUB_STEP_SUMMARY
echo "brew install dicklesworthstone/tap/ntm" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "# Go install" >> $GITHUB_STEP_SUMMARY
echo "go install github.com/Dicklesworthstone/ntm/cmd/ntm@${{ steps.release.outputs.tag }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "## Verification" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "All release artifacts have been verified:" >> $GITHUB_STEP_SUMMARY
echo "- SHA256 checksums validated" >> $GITHUB_STEP_SUMMARY
echo "- Upgrade command tested on Linux, macOS, and Windows" >> $GITHUB_STEP_SUMMARY
echo "- Docker images built with SBOM and provenance" >> $GITHUB_STEP_SUMMARY