-
Notifications
You must be signed in to change notification settings - Fork 8
431 lines (387 loc) · 15.7 KB
/
release.yml
File metadata and controls
431 lines (387 loc) · 15.7 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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
name: Release
on:
push:
tags:
- 'v*'
concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false
permissions: {}
jobs:
security:
name: Security scan
uses: ./.github/workflows/security.yml
permissions:
contents: read
security-events: write
pull-requests: read
test:
name: Test before release
runs-on: ubuntu-latest
permissions:
contents: read
env:
BASECAMP_NO_KEYRING: "1"
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 # zizmor: ignore[cache-poisoning] -- cache is branch-isolated; fork PRs cannot write to the cache used by tag-push workflows
with:
go-version-file: 'go.mod'
- name: Install golangci-lint
uses: golangci/golangci-lint-action@1e7e51e771db61008b38414a730f564565cf7c20 # v9.2.0
with:
version: v2.9.0
install-only: true
- name: Cache BATS
id: cache-bats
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5.0.4 # zizmor: ignore[cache-poisoning] -- cache is branch-isolated; fork PRs cannot write to the cache used by tag-push workflows
with:
path: ~/.local
key: bats-1.11.0-home
- name: Install BATS
if: steps.cache-bats.outputs.cache-hit != 'true'
run: |
git clone --depth 1 --branch v1.11.0 https://github.com/bats-core/bats-core.git /tmp/bats-core
/tmp/bats-core/install.sh ~/.local
- name: Add BATS to PATH
run: echo "$HOME/.local/bin" >> "$GITHUB_PATH"
- name: Run release quality gate
run: |
make fmt-check vet lint test test-e2e provenance-check check-naming check-surface
go test -tags dev -race -count=1 ./...
- name: Run govulncheck
run: |
go install golang.org/x/vuln/cmd/govulncheck@latest
GOFLAGS=-tags=dev govulncheck ./...
- name: Check CLI surface compatibility
run: |
# Generate current snapshot
make build
scripts/check-cli-surface.sh ./bin/basecamp /tmp/current-surface.txt
# Generate baseline from previous tag in isolated worktree
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
if [ -n "$PREV_TAG" ]; then
SCRIPT_DIR="$(pwd)/scripts"
WORKTREE_DIR=/tmp/baseline-tree
trap 'git worktree remove "$WORKTREE_DIR" --force 2>/dev/null || true' EXIT
git worktree add "$WORKTREE_DIR" "$PREV_TAG"
cd "$WORKTREE_DIR"
make build
if "$SCRIPT_DIR/check-cli-surface.sh" ./bin/basecamp /tmp/baseline-surface.txt 2>/dev/null; then
cd -
git worktree remove "$WORKTREE_DIR" --force
trap - EXIT
scripts/check-cli-surface-diff.sh /tmp/baseline-surface.txt /tmp/current-surface.txt
else
echo "Baseline ($PREV_TAG) does not support --help --agent — skipping surface diff"
cd -
git worktree remove "$WORKTREE_DIR" --force
trap - EXIT
fi
else
echo "First release — no baseline to compare against"
fi
release:
name: Release
needs: [test, security]
runs-on: ubuntu-latest
timeout-minutes: 45
environment: release
permissions:
contents: write
id-token: write
models: read
attestations: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 0
persist-credentials: false
- name: Generate token for Homebrew tap
id: sdk-token
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
with:
app-id: ${{ vars.RELEASE_CLIENT_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
owner: basecamp
repositories: homebrew-tap
permission-contents: write
- name: Set up Go
uses: actions/setup-go@4a3601121dd01d1626a1e23e37211e3254c1c06c # v6.4.0 # zizmor: ignore[cache-poisoning] -- cache is branch-isolated; fork PRs cannot write to the cache used by tag-push workflows
with:
go-version-file: 'go.mod'
- name: Verify tag is on main
run: |
git fetch origin main
git merge-base --is-ancestor "$GITHUB_SHA" origin/main
- name: Install Cosign
uses: sigstore/cosign-installer@ba7bc0a3fef59531c69a25acd34668d6d3fe6f22 # v4.1.0
- name: Install Syft
uses: anchore/sbom-action/download-syft@e22c389904149dbc22b58101806040fa8d37a610 # v0.24.0
- name: Build changelog context
run: |
PREV_TAG=$(git describe --tags --abbrev=0 HEAD^ 2>/dev/null || echo "")
DIFF_FILE=/tmp/diff.txt
if [ -z "$PREV_TAG" ]; then
COMMITS=$(git log --oneline --no-decorate)
git diff --stat 4b825dc642cb6eb9a060e54bf899d69f82a3ef17 HEAD > "$DIFF_FILE"
else
COMMITS=$(git log --oneline --no-decorate "${PREV_TAG}..HEAD")
git diff "${PREV_TAG}..HEAD" -- '*.go' 'go.mod' > "$DIFF_FILE"
fi
{
echo "Commits:"
echo "$COMMITS"
echo ""
echo "Diff summary:"
head -c 80000 "$DIFF_FILE"
} > /tmp/user-message.txt
# Splice into prompt YAML
python3 -c "
with open('.github/prompts/summarize-changelog.prompt.yml') as f:
lines = f.readlines()
with open('/tmp/user-message.txt') as f:
user_msg = f.read()
insert_at = len(lines)
for i, line in enumerate(lines):
if i == 0: continue
if line.strip() and not line[0].isspace():
insert_at = i
break
entry = [' - role: user\n', ' content: |\n']
for ln in user_msg.splitlines():
entry.append(' ' + ln + '\n')
lines[insert_at:insert_at] = entry
with open('/tmp/prompt.yml', 'w') as f:
f.writelines(lines)
try:
import yaml
doc = yaml.safe_load(open('/tmp/prompt.yml'))
assert doc['messages'][-1]['role'] == 'user', 'prompt splice failed'
except ImportError:
pass
"
continue-on-error: true
- name: Generate AI changelog
id: ai-changelog
uses: actions/ai-inference@e09e65981758de8b2fdab13c2bfb7c7d5493b0b6 # v2.0.7
continue-on-error: true
with:
prompt-file: /tmp/prompt.yml
- name: Set changelog path
id: changelog
env:
RESPONSE_FILE: ${{ steps.ai-changelog.outputs.response-file }}
run: |
if [ -n "$RESPONSE_FILE" ] && [ -f "$RESPONSE_FILE" ]; then
sed -i '/^```\(markdown\)\?$/d' "$RESPONSE_FILE"
echo "file=$RESPONSE_FILE" >> "$GITHUB_OUTPUT"
fi
- name: Verify macOS signing secrets
if: github.repository == 'basecamp/basecamp-cli'
run: |
missing=()
for var in MACOS_SIGN_P12 MACOS_SIGN_PASSWORD MACOS_NOTARY_KEY MACOS_NOTARY_KEY_ID MACOS_NOTARY_ISSUER_ID; do
if [ -z "${!var}" ]; then
missing+=("$var")
fi
done
if [ ${#missing[@]} -gt 0 ]; then
echo "::error::Missing macOS signing secrets: ${missing[*]}"
exit 1
fi
echo "All macOS signing secrets present"
env:
MACOS_SIGN_P12: ${{ secrets.MACOS_SIGN_P12 }}
MACOS_SIGN_PASSWORD: ${{ secrets.MACOS_SIGN_PASSWORD }}
MACOS_NOTARY_KEY: ${{ secrets.MACOS_NOTARY_KEY }}
MACOS_NOTARY_KEY_ID: ${{ secrets.MACOS_NOTARY_KEY_ID }}
MACOS_NOTARY_ISSUER_ID: ${{ secrets.MACOS_NOTARY_ISSUER_ID }}
- name: Install quill for macOS signing
run: |
go install github.com/anchore/quill/cmd/quill@v0.7.1
echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH"
- name: Prepare signing credentials
env:
MACOS_SIGN_P12: ${{ secrets.MACOS_SIGN_P12 }}
MACOS_NOTARY_KEY: ${{ secrets.MACOS_NOTARY_KEY }}
run: |
umask 077
echo "$MACOS_SIGN_P12" | base64 -d > "$RUNNER_TEMP/codesign.p12"
echo "$MACOS_NOTARY_KEY" | base64 -d > "$RUNNER_TEMP/notary.p8"
- name: Install GoReleaser
uses: goreleaser/goreleaser-action@ec59f474b9834571250b370d4735c50f8e2d1e29 # v7.0.0
with:
distribution: goreleaser
version: 'v2.14.1'
install-only: true
- name: Run GoReleaser
env:
CHANGELOG_FILE: ${{ steps.changelog.outputs.file }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_TAP_TOKEN: ${{ steps.sdk-token.outputs.token }}
QUILL_SIGN_P12: ${{ runner.temp }}/codesign.p12
QUILL_SIGN_PASSWORD: ${{ secrets.MACOS_SIGN_PASSWORD }}
run: |
RELEASE_CHANGELOG=""
if [ -n "$CHANGELOG_FILE" ] && [ -f "$CHANGELOG_FILE" ]; then
RELEASE_CHANGELOG=$(cat "$CHANGELOG_FILE")
fi
export RELEASE_CHANGELOG
goreleaser release --clean --skip=notarize
- name: Notarize macOS binaries
env:
MACOS_NOTARY_ISSUER_ID: ${{ secrets.MACOS_NOTARY_ISSUER_ID }}
MACOS_NOTARY_KEY_ID: ${{ secrets.MACOS_NOTARY_KEY_ID }}
run: |
for bin in dist/basecamp_darwin_*/basecamp; do
echo "Notarizing $bin..."
quill notarize "$bin" \
--notary-issuer "$MACOS_NOTARY_ISSUER_ID" \
--notary-key-id "$MACOS_NOTARY_KEY_ID" \
--notary-key "$RUNNER_TEMP/notary.p8" \
--wait
done
- name: Clean up signing credentials
if: always()
run: rm -f "$RUNNER_TEMP/codesign.p12" "$RUNNER_TEMP/notary.p8"
- name: Attest build provenance
uses: actions/attest-build-provenance@a2bbfa25375fe432b6a289bc6b6cd05ecd0c4c32 # v4.1.0
with:
subject-checksums: ./dist/checksums.txt
- name: Publish to AUR
env:
AUR_KEY: ${{ secrets.AUR_KEY }}
run: |
VERSION="${GITHUB_REF_NAME#v}"
mkdir -p ~/.ssh
echo "$AUR_KEY" > ~/.ssh/aur
chmod 600 ~/.ssh/aur
echo -e "Host aur.archlinux.org\n IdentityFile ~/.ssh/aur\n User aur\n StrictHostKeyChecking accept-new" >> ~/.ssh/config
git config --global user.name "37signals"
git config --global user.email "dev@37signals.com"
scripts/publish-aur.sh "$VERSION"
macos-verify:
name: Verify macOS signing
needs: [release]
if: startsWith(github.ref, 'refs/tags/v')
runs-on: macos-latest
timeout-minutes: 10
permissions:
contents: read
strategy:
matrix:
arch: [amd64, arm64]
steps:
- name: Download release binary
env:
GH_TOKEN: ${{ github.token }}
run: |
mkdir -p /tmp/verify
gh release download "$GITHUB_REF_NAME" \
--repo "$GITHUB_REPOSITORY" \
--pattern "basecamp_*_darwin_${{ matrix.arch }}.tar.gz" \
--dir /tmp/verify
tar -xzf /tmp/verify/basecamp_*_darwin_${{ matrix.arch }}.tar.gz -C /tmp/verify
- name: Verify TeamIdentifier
run: |
TEAM_ID=$(codesign -dv --verbose=4 /tmp/verify/basecamp 2>&1 | grep TeamIdentifier= | cut -d= -f2)
echo "TeamIdentifier (${{ matrix.arch }}): $TEAM_ID"
if [ "$TEAM_ID" != "2WNYUYRS7G" ]; then
echo "::error::TeamIdentifier mismatch (${{ matrix.arch }}): expected 2WNYUYRS7G, got $TEAM_ID"
exit 1
fi
- name: Verify hardened runtime
run: |
FLAGS=$(codesign -dv --verbose=4 /tmp/verify/basecamp 2>&1 | grep 'flags=' | head -1)
echo "Flags (${{ matrix.arch }}): $FLAGS"
if ! echo "$FLAGS" | grep -q 'runtime'; then
echo "::error::Hardened runtime flag not set (${{ matrix.arch }}): $FLAGS"
exit 1
fi
- name: Check notarization status
run: |
# Best-effort: notarization ticket propagation can lag, so this is
# telemetry, not a gate. TeamIdentifier and hardened runtime above
# are the hard assertions.
spctl -a -vvv -t install /tmp/verify/basecamp 2>&1 | tee /tmp/verify/spctl.out
if grep -q 'accepted\|Notarized Developer ID' /tmp/verify/spctl.out; then
echo "Notarization accepted for ${{ matrix.arch }}"
else
echo "::warning::Notarization not yet accepted for ${{ matrix.arch }} (ticket propagation may lag)"
fi
nix-verify:
name: Verify Nix flake
needs: [release]
if: startsWith(github.ref, 'refs/tags/v')
continue-on-error: true
runs-on: ubuntu-latest
timeout-minutes: 15
permissions:
contents: read
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Install Nix
uses: cachix/install-nix-action@1ca7d21a94afc7c957383a2d217460d980de4934 # v31.10.1
- name: Build and verify
run: |
STORE_PATH=$(nix build --no-link --print-out-paths)
"$STORE_PATH/bin/basecamp" --version
sync-skills:
name: Sync skills
needs: [release]
if: startsWith(github.ref, 'refs/tags/v')
continue-on-error: true
concurrency:
group: sync-skills
cancel-in-progress: false
runs-on: ubuntu-latest
timeout-minutes: 10
environment: release
permissions:
contents: read
issues: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
persist-credentials: false
- name: Generate token for skills repo
id: skills-token
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
with:
app-id: ${{ vars.RELEASE_CLIENT_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
owner: basecamp
repositories: skills
permission-contents: write
- name: Sync skills to distribution repo
id: sync
env:
SKILLS_TOKEN: ${{ steps.skills-token.outputs.token }}
RELEASE_TAG: ${{ github.ref_name }}
SOURCE_SHA: ${{ github.sha }}
run: scripts/sync-skills.sh
- name: Notify on sync failure
if: failure()
env:
GH_TOKEN: ${{ github.token }}
REF_NAME: ${{ github.ref_name }}
RUN_ID: ${{ github.run_id }}
run: |
TITLE="Skills sync failure"
BODY="The automatic skills sync for [${REF_NAME}](https://github.com/${{ github.repository }}/actions/runs/${RUN_ID}) failed. Check the workflow run for details."
# Check for existing open issue before creating a new one
existing=$(gh issue list --repo ${{ github.repository }} --state open --search "in:title $TITLE" --json number,title --jq '[.[] | select(.title == "'"$TITLE"'")][0].number // empty' 2>/dev/null || true)
if [ -n "$existing" ]; then
gh issue comment --repo ${{ github.repository }} "$existing" --body "$BODY" || true
else
gh issue create --repo ${{ github.repository }} --title "$TITLE" --body "$BODY" || true
fi
# Always emit annotation so the failure is visible in the workflow summary
echo "::error::Skills sync to basecamp/skills failed for ${REF_NAME}. See https://github.com/${{ github.repository }}/actions/runs/${RUN_ID}"