Skip to content

Commit 73eaa00

Browse files
bomly-guyclaude
andcommitted
ci(release): fail fast when the winget PAT is expired or revoked
The v0.18.2 release run (29567349939) failed 14 minutes into GoReleaser with 401 Bad Credentials on the winget publisher — after the draft release was created and the Homebrew/Scoop PRs were opened — because WINGET_GITHUB_TOKEN (a 30-day PAT set on 2026-06-17) expired that morning, minutes after the v0.18.1 run squeaked through. Add a preflight job that validates the token against the bomly-dev/winget-pkgs fork before validate/release run, failing within seconds with an actionable rotation message, and emits a warning when the token is within 14 days of its expiration date so the next expiry is caught before it breaks a release. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 96de352 commit 73eaa00

1 file changed

Lines changed: 39 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,44 @@ concurrency:
1414
cancel-in-progress: false
1515

1616
jobs:
17+
preflight:
18+
# Fail within seconds if WINGET_GITHUB_TOKEN is expired or revoked,
19+
# instead of 14 minutes into GoReleaser — after it has already created
20+
# the draft release and opened the Homebrew/Scoop PRs — which strands
21+
# the release in a half-published state (see the v0.18.2 run). The
22+
# winget publisher is the only one on a long-lived PAT: the release-bot
23+
# app token cannot open PRs on microsoft/winget-pkgs, where the app is
24+
# not installed.
25+
runs-on: ubuntu-latest
26+
timeout-minutes: 5
27+
steps:
28+
- name: Check winget token validity and expiry
29+
env:
30+
WINGET_GITHUB_TOKEN: ${{ secrets.WINGET_GITHUB_TOKEN }}
31+
run: |
32+
set -euo pipefail
33+
34+
headers_file="$(mktemp)"
35+
status="$(curl -sS -o /dev/null -D "$headers_file" -w '%{http_code}' \
36+
-H "Authorization: Bearer ${WINGET_GITHUB_TOKEN}" \
37+
https://api.github.com/repos/bomly-dev/winget-pkgs)"
38+
if [ "$status" != "200" ]; then
39+
echo "::error::WINGET_GITHUB_TOKEN cannot read bomly-dev/winget-pkgs (HTTP ${status}). The PAT has likely expired or been revoked — mint a new one (public_repo scope, it must be able to open PRs on microsoft/winget-pkgs) and update the secret: gh secret set WINGET_GITHUB_TOKEN -R bomly-dev/bomly-cli"
40+
exit 1
41+
fi
42+
43+
expiry="$(grep -i '^github-authentication-token-expiration:' "$headers_file" | cut -d' ' -f2- | tr -d '\r' || true)"
44+
if [ -n "$expiry" ]; then
45+
expiry_epoch="$(date -u -d "$expiry" +%s)"
46+
days_left=$(( (expiry_epoch - $(date -u +%s)) / 86400 ))
47+
echo "WINGET_GITHUB_TOKEN expires ${expiry} UTC (${days_left} days from now)."
48+
if [ "$days_left" -lt 14 ]; then
49+
echo "::warning::WINGET_GITHUB_TOKEN expires in ${days_left} days (${expiry} UTC). Rotate it soon: gh secret set WINGET_GITHUB_TOKEN -R bomly-dev/bomly-cli"
50+
fi
51+
else
52+
echo "WINGET_GITHUB_TOKEN has no expiration date."
53+
fi
54+
1755
validate:
1856
runs-on: ubuntu-latest
1957
timeout-minutes: 30
@@ -36,7 +74,7 @@ jobs:
3674
run: go vet ./...
3775

3876
release:
39-
needs: validate
77+
needs: [preflight, validate]
4078
runs-on: ubuntu-latest
4179
timeout-minutes: 45
4280
permissions:

0 commit comments

Comments
 (0)