Skip to content

Commit 4193619

Browse files
fix: prepare release artifacts before publishing (#111)
## Summary - Generate shell completions and man pages in an isolated, read-only preparation job before protected release publishing. - Bind prepared artifacts to the verified release commit and skip legacy GoReleaser preparation hooks when republishing historical tags. - Preserve existing archive contents, Linux packages, Homebrew output, signing/notarization configuration, attestations, and current pinned GitHub Actions versions. - Add workflow, credential-boundary, release-configuration, historical-tag, and artifact-compatibility regression coverage. ## Validation - `env GOCACHE=/Users/jbeckwith/.cache/go-build ./scripts/test -skip '^TestFilesCreateCLICancelClosesStalledFIFO$'` - `env GOCACHE=/Users/jbeckwith/.cache/go-build go test -race -parallel=1 ./... -skip '^TestFilesCreateCLICancelClosesStalledFIFO$'` - `env GOCACHE=/Users/jbeckwith/.cache/go-build go test -race ./scripts -count=1` - `./scripts/lint`, `go vet ./...`, `actionlint`, `goreleaser check`, and `./scripts/test-goreleaser-installer` - Full GoReleaser snapshot across all nine Linux/macOS/Windows archive targets, plus Linux packages and the Homebrew cask. The excluded FIFO test fails independently on the unchanged macOS baseline; Windows test cross-compilation passes.
1 parent a771913 commit 4193619

5 files changed

Lines changed: 647 additions & 1 deletion

File tree

.github/workflows/ci.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@ jobs:
5252
id: goreleaser
5353
uses: ./.github/actions/setup-goreleaser
5454

55+
- name: Verify local and historical release preflight
56+
run: go test ./scripts -run '^Test(Local|Historical)ReleasePreflight$' -count=1
57+
env:
58+
GORELEASER_EXECUTABLE: ${{ steps.goreleaser.outputs.executable }}
59+
5560
- name: Generate release inputs
5661
run: |
5762
mkdir -p completions

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
.prism.log
22
.stdy.log
33
dist/
4+
/completions/openai.bash
5+
/completions/openai.zsh
6+
/completions/openai.fish
7+
/man/man1/openai.1.gz
48
/openai
59
*.exe

docs/releasing.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,22 @@ The reviewed checksums cover Linux and macOS hosts on x86_64 and arm64. The
1111
host architecture does not limit the Linux, macOS, and Windows release targets
1212
configured in `.goreleaser.yml`.
1313

14+
Shell completions and man pages are generated in a separate, read-only job before
15+
the protected publishing job receives repository-write tokens or signing and
16+
notarization credentials. GoReleaser packages those prebuilt files without
17+
running the application. For local release or snapshot builds, first run
18+
`./scripts/generate-release-artifacts` without publishing or signing credentials.
19+
Publishing always skips GoReleaser's `before` hooks, including when an older
20+
release tag still contains the previous application-executing hooks.
21+
Rooted, exact-file ignore rules keep only the expected local completions and man
22+
page out of Git status; the publishing checkout applies the same exact-file
23+
excludes in its local Git metadata so non-snapshot releases also pass
24+
GoReleaser's clean-tree validation when historical tags predate those rules.
25+
1426
The publish workflow installs GoReleaser from its trusted workflow checkout
1527
before switching to the requested release tag. This allows existing release tags
1628
that predate the installer to be republished; the workflow checkout, not the
17-
historical tag, determines the reviewed GoReleaser version.
29+
historical tag, determines the reviewed GoReleaser version and artifact generator.
1830

1931
## Update GoReleaser
2032

scripts/generate-release-artifacts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
set -euo pipefail
4+
5+
cd "${GITHUB_WORKSPACE:-$(dirname "$0")/..}"
6+
7+
credentials=(
8+
GITHUB_TOKEN
9+
GH_TOKEN
10+
HOMEBREW_TAP_GITHUB_TOKEN
11+
MACOS_SIGN_P12
12+
MACOS_SIGN_PASSWORD
13+
MACOS_NOTARY_KEY
14+
MACOS_NOTARY_KEY_ID
15+
MACOS_NOTARY_ISSUER_ID
16+
RELEASE_APP_PRIVATE_KEY
17+
ACTIONS_ID_TOKEN_REQUEST_TOKEN
18+
)
19+
20+
for credential in "${credentials[@]}"; do
21+
if [[ -n "${!credential:-}" ]]; then
22+
echo "Release artifacts must be generated without $credential" >&2
23+
exit 1
24+
fi
25+
done
26+
27+
mkdir -p completions
28+
for shell in bash zsh fish; do
29+
go run ./cmd/openai/main.go @completion "$shell" > "completions/openai.$shell"
30+
done
31+
go run ./cmd/openai/main.go @manpages -o man

0 commit comments

Comments
 (0)