Skip to content

Commit 64bf1c2

Browse files
Pin GoReleaser to requested release tag (#112)
## Problem When a prerelease and final tag point at one commit, GoReleaser auto-detects the prerelease tag. Production workflow runs then build prerelease-named assets and fail before distribution publication. ## Change Set GORELEASER_CURRENT_TAG from the reusable workflow tag input in binary, Windows, Public ECR, and Lambda GoReleaser invocations. Add a workflow test that guards every invocation. ## Security impact Artifact names, release metadata, and image digest files now derive from the verified workflow tag even when several tags identify the same source commit. ## Verification - make test workflow-validate ## Release recovery The failed v0.0.42 and v0.5.1 attempts remain unused in dist. Replacement releases use new patch versions after this shared workflow patch is published. Co-authored-by: Paul Querna <paul.querna@conductorone.com> Co-authored-by: c1-squire-dev[bot] <c1-squire-dev[bot]@users.noreply.github.com>
1 parent bd3e154 commit 64bf1c2

4 files changed

Lines changed: 29 additions & 0 deletions

File tree

.github/workflows/release.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ jobs:
425425
args: release --clean --config ../_workflows/_generated/.goreleaser.binaries.yaml
426426
env:
427427
GITHUB_TOKEN: ${{ secrets.RELENG_GITHUB_TOKEN }}
428+
GORELEASER_CURRENT_TAG: ${{ inputs.tag }}
428429
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
429430
AC_PROVIDER: ${{ secrets.AC_PROVIDER }}
430431

@@ -751,6 +752,7 @@ jobs:
751752
args: release --clean --skip=publish --config ../_workflows/_generated/.goreleaser.windows.yaml
752753
env:
753754
GITHUB_TOKEN: ${{ secrets.RELENG_GITHUB_TOKEN }}
755+
GORELEASER_CURRENT_TAG: ${{ inputs.tag }}
754756
GORELEASER_KEY: ${{ secrets.GORELEASER_PRO_KEY }}
755757

756758
- name: Flatten MSI directory structure
@@ -1077,6 +1079,7 @@ jobs:
10771079
args: release --clean --config ../_workflows/_generated/.goreleaser.docker.yaml
10781080
env:
10791081
GITHUB_TOKEN: ${{ secrets.RELENG_GITHUB_TOKEN }}
1082+
GORELEASER_CURRENT_TAG: ${{ inputs.tag }}
10801083
COSIGN_EXPERIMENTAL: "1"
10811084

10821085
- name: Set up Go for Public ECR helper
@@ -1130,6 +1133,7 @@ jobs:
11301133
args: release --clean --config ../_workflows/_generated/.goreleaser.lambda.yaml
11311134
env:
11321135
GITHUB_TOKEN: ${{ secrets.RELENG_GITHUB_TOKEN }}
1136+
GORELEASER_CURRENT_TAG: ${{ inputs.tag }}
11331137

11341138
- name: Set up Go for workflows
11351139
if: inputs.docker == true || inputs.lambda == true

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ test-scripts:
2121
bash scripts/test-derive-iam-role-name.sh
2222
bash scripts/test-normalize-release-options.sh
2323
python3 scripts/test-release-config-templates.py
24+
bash scripts/test-release-workflow-tag-pin.sh
2425
bash scripts/test-s3-release-uploads.sh
2526
if command -v pwsh >/dev/null 2>&1; then pwsh -NoProfile -File scripts/test-s3-release-uploads.ps1; else echo "pwsh not found; skipping PowerShell S3 release upload tests"; fi
2627

docs/release-workflow.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ checked-out commit matches the tag target before building artifacts or recording
136136
registry metadata. This prevents a release run from publishing artifacts for one
137137
commit while labeling them as a different tag.
138138

139+
Every GoReleaser invocation receives `GORELEASER_CURRENT_TAG` from the workflow input. This pins archive names, release metadata, and image digest files to the requested tag when multiple tags identify the same commit.
140+
139141
### Keyless Signing
140142

141143
All signatures use Sigstore's keyless signing:
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
workflow="${script_dir}/../.github/workflows/release.yaml"
6+
expected='${{ inputs.tag }}'
7+
8+
assert_tag_pin() {
9+
local job="$1"
10+
local step="$2"
11+
local got
12+
got="$(yq -r ".jobs.\"${job}\".steps[] | select(.name == \"${step}\").env.GORELEASER_CURRENT_TAG" "$workflow")"
13+
if [ "$got" != "$expected" ]; then
14+
echo "${job}/${step}: GORELEASER_CURRENT_TAG = ${got@Q}, want ${expected@Q}" >&2
15+
exit 1
16+
fi
17+
}
18+
19+
assert_tag_pin goreleaser-binaries "Run GoReleaser"
20+
assert_tag_pin goreleaser-windows "Run GoReleaser for Windows"
21+
assert_tag_pin goreleaser-docker "Run GoReleaser for Docker OCI"
22+
assert_tag_pin goreleaser-docker "Run GoReleaser for Lambda"

0 commit comments

Comments
 (0)