Skip to content

Commit 8ff385f

Browse files
HuanCheng65claude
andcommitted
ci(release): build CLI artifacts inline with release-please
When release-please-action creates the GitHub Release using the default GITHUB_TOKEN, the resulting tag push does NOT fire downstream workflows listening on `on: push: tags` — GitHub's anti-recursion guard. The repo worked around this by setting RELEASE_PLEASE_TOKEN to a PAT for v0.1.0 through v0.1.4, but that token has apparently expired: v0.1.5 was cut on 2026-05-14 with no artifacts attached. Move the GoReleaser job into release-please.yml as a second job gated on the action's `release_created` output. Now artifacts ship in the same workflow that cut the release — no cross-workflow token dance, no PAT maintenance burden. Keep release-cli.yml as a fallback path with both `push: tags` and a new `workflow_dispatch` (with a `tag` input). The dispatch path makes it trivial to backfill artifacts on a release that missed them. Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
1 parent f0434fa commit 8ff385f

2 files changed

Lines changed: 55 additions & 1 deletion

File tree

.github/workflows/release-cli.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,23 @@
11
name: Release CLI
22

3+
# Fallback / manual entry point for building CLI release artifacts.
4+
# The primary build path is now release-please.yml's goreleaser job, which
5+
# runs inline when release-please creates a Release. This workflow exists
6+
# to handle:
7+
# - manually-pushed v* tags (someone tags by hand, bypassing release-please)
8+
# - rebuilds via workflow_dispatch (e.g. backfilling a release whose
9+
# artifacts went missing for any reason)
10+
311
on:
412
push:
513
tags:
614
- "v*"
15+
workflow_dispatch:
16+
inputs:
17+
tag:
18+
description: "Tag to build (e.g. v0.1.5)"
19+
required: true
20+
type: string
721

822
permissions:
923
contents: write
@@ -15,6 +29,7 @@ jobs:
1529
- uses: actions/checkout@v4
1630
with:
1731
fetch-depth: 0
32+
ref: ${{ inputs.tag || github.ref_name }}
1833

1934
- uses: actions/setup-go@v5
2035
with:
@@ -33,4 +48,3 @@ jobs:
3348
env:
3449
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3550
GOFLAGS: -mod=readonly
36-

.github/workflows/release-please.yml

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,49 @@ permissions:
2020
jobs:
2121
release-please:
2222
runs-on: ubuntu-latest
23+
outputs:
24+
release_created: ${{ steps.release.outputs.release_created }}
25+
tag_name: ${{ steps.release.outputs.tag_name }}
2326
steps:
2427
- uses: googleapis/release-please-action@v4
28+
id: release
2529
with:
2630
token: ${{ secrets.RELEASE_PLEASE_TOKEN || github.token }}
2731
config-file: .release-please-config.json
2832
manifest-file: .release-please-manifest.json
33+
34+
# When the release-please-action above creates a new GitHub Release, the
35+
# tag it pushes is authored by the default GITHUB_TOKEN, which GitHub's
36+
# anti-recursion guard prevents from firing `on: push: tags` workflows.
37+
# That's why a separate release-cli.yml listening on `v*` tag pushes
38+
# silently fails for release-please-created tags. To avoid depending on a
39+
# PAT/App token in `RELEASE_PLEASE_TOKEN` (which has historically expired
40+
# and broken releases), we build artifacts in this same workflow,
41+
# conditional on release-please's `release_created` output.
42+
goreleaser:
43+
needs: release-please
44+
if: needs.release-please.outputs.release_created == 'true'
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v4
48+
with:
49+
fetch-depth: 0
50+
ref: ${{ needs.release-please.outputs.tag_name }}
51+
52+
- uses: actions/setup-go@v5
53+
with:
54+
go-version-file: go.mod
55+
cache: true
56+
57+
- name: Run CLI tests
58+
run: go test -mod=readonly ./apps/cli/...
59+
60+
- name: Run GoReleaser
61+
uses: goreleaser/goreleaser-action@v6
62+
with:
63+
distribution: goreleaser
64+
version: latest
65+
args: release --clean --config .goreleaser-cli.yml
66+
env:
67+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
68+
GOFLAGS: -mod=readonly

0 commit comments

Comments
 (0)