Skip to content

Commit 701e1c1

Browse files
ci(release): migrate from bumpp to tagpr (#1406)
* ci(release): add tagpr release PR automation Introduce Songmu/tagpr to manage releases via an auto-generated release PR: every push to main creates or updates a PR that bumps all nine workspace package.json versions (tagpr versionFile) and syncs the Rust workspace via the new `just sync-rust-version` recipe run as postVersionCommand. Merging the PR tags the merge commit. GitHub Release creation and CHANGELOG.md generation are disabled in .tagpr because changelogithub keeps generating the release notes in the existing style. Tags pushed with GITHUB_TOKEN do not trigger `on: push: tags` workflows, so tagpr.yaml dispatches release.yaml explicitly with `gh workflow run --ref <tag>`; release.yaml gains a workflow_dispatch trigger for that purpose. * chore(release): drop bumpp local release flow Releases are now driven by tagpr in CI, so the local `just release` recipe and the bumpp dependency are no longer needed. bump.config.ts is deleted because its cargo set-version hook moved to the `just sync-rust-version` recipe that tagpr runs as postVersionCommand. * docs(skills): document tagpr release flow Replace the removed `just release` recipe in the development skill command list with a note on the tagpr release PR flow and the minor/major bump labels. * ci(release): gate release jobs to tag refs and isolate actions:write Gate release.yaml build/publish/release jobs behind startsWith(github.ref, 'refs/tags/') so a workflow_dispatch from a branch cannot bypass the tag-only release flow. tagpr dispatches with --ref <tag>, so the intended path is unaffected. Move the release dispatch out of the tagpr job into a dependent dispatch-release job that alone holds actions: write, keeping tagpr on its documented least-privilege scopes (contents/pull-requests/issues). Co-authored-by: Codesmith <[email protected]> * ci(release): consolidate release pipeline into tagpr workflow Move the build/publish/release jobs from release.yaml into tagpr.yaml, gated on the tagpr job's tag output, and delete release.yaml. Running everything in one workflow removes the workflow_dispatch chaining that worked around GITHUB_TOKEN-pushed tags not triggering `push: tags` workflows, along with the dispatch-release job and its `actions: write` grant. The release jobs check out the freshly created tag explicitly. changelogithub resolves the release tag with `git tag --points-at HEAD`, not GITHUB_REF, so it picks the right release even though the run's ref is refs/heads/main. A failed release is retried with "Re-run failed jobs"; a full re-run finds no new tag and skips the release jobs. --------- Co-authored-by: Codesmith <[email protected]>
1 parent 6676d29 commit 701e1c1

9 files changed

Lines changed: 60 additions & 143 deletions

File tree

‎.agents/skills/development/references/commands.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,13 @@ just fmt
99
just typecheck
1010
just build
1111
just check
12-
just release
1312
```
1413

14+
Releases are managed by [tagpr](https://github.com/Songmu/tagpr): merging the
15+
auto-generated release PR tags the merge commit and triggers the publish
16+
workflow. The bump is patch by default; label merged PRs with `minor` or
17+
`major` to raise it.
18+
1519
Useful main CLI commands:
1620

1721
```sh
Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,43 @@
1-
name: npm publish
1+
name: tagpr
22

33
on:
44
push:
5-
tags:
6-
- '*'
5+
branches:
6+
- main
7+
8+
concurrency: tagpr
79

810
jobs:
11+
tagpr:
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 15
14+
permissions:
15+
contents: write
16+
pull-requests: write
17+
issues: read
18+
outputs:
19+
tag: ${{ steps.tagpr.outputs.tag }}
20+
steps:
21+
# persist-credentials stays on (default) so tagpr can push the release PR and tag
22+
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
23+
with:
24+
fetch-depth: 0
25+
# postVersionCommand in .tagpr runs `nix develop`, so the Nix store cache must be ready
26+
- uses: ./.github/actions/setup-nix-cache
27+
- id: tagpr
28+
uses: Songmu/tagpr@e84001bd5dac8defa0c75b3913937d284a3b3660 # v1.20.0
29+
env:
30+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
31+
32+
# The release jobs below run in this workflow instead of a tag-triggered one
33+
# because tags pushed with GITHUB_TOKEN do not trigger `on: push: tags`
34+
# workflows. They run only when tagpr just tagged a release-PR merge, and
35+
# check out that tag explicitly. To retry a failed release, re-run only the
36+
# failed jobs: a full re-run finds no new tag and skips everything.
937
build-native-packages:
1038
name: ${{ matrix.name }}
39+
needs: tagpr
40+
if: needs.tagpr.outputs.tag != ''
1141
runs-on: ${{ matrix.os }}
1242
timeout-minutes: 30
1343
strategy:
@@ -48,6 +78,7 @@ jobs:
4878
steps:
4979
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
5080
with:
81+
ref: ${{ needs.tagpr.outputs.tag }}
5182
fetch-depth: 0
5283
persist-credentials: false
5384
- uses: ./.github/actions/build-linux-native-package
@@ -70,7 +101,9 @@ jobs:
70101

71102
npm:
72103
needs:
104+
- tagpr
73105
- build-native-packages
106+
if: needs.tagpr.outputs.tag != ''
74107
runs-on: ubuntu-24.04-arm
75108
timeout-minutes: 10
76109
permissions:
@@ -79,6 +112,7 @@ jobs:
79112
steps:
80113
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
81114
with:
115+
ref: ${{ needs.tagpr.outputs.tag }}
82116
fetch-depth: 0
83117
persist-credentials: false
84118
- uses: ./.github/actions/setup-nix-cache
@@ -105,13 +139,18 @@ jobs:
105139

106140
release:
107141
needs:
142+
- tagpr
108143
- npm
144+
if: needs.tagpr.outputs.tag != ''
109145
runs-on: blacksmith-32vcpu-ubuntu-2404-arm
110146
permissions:
111147
contents: write
112148
steps:
149+
# changelogithub resolves the release tag with `git tag --points-at HEAD`,
150+
# so checking out the tag is what makes it pick the right release
113151
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
114152
with:
153+
ref: ${{ needs.tagpr.outputs.tag }}
115154
fetch-depth: 0
116155
persist-credentials: false
117156
- uses: ./.github/actions/setup-nix-cache

‎.tagpr‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[tagpr]
2+
releaseBranch = main
3+
vPrefix = true
4+
changelog = false
5+
release = false
6+
versionFile = package.json,apps/ccusage/package.json,docs/package.json,packages/ccusage-darwin-arm64/package.json,packages/ccusage-darwin-x64/package.json,packages/ccusage-linux-arm64/package.json,packages/ccusage-linux-x64/package.json,packages/ccusage-win32-arm64/package.json,packages/ccusage-win32-x64/package.json
7+
postVersionCommand = nix develop --command just sync-rust-version

‎bump.config.ts‎

Lines changed: 0 additions & 61 deletions
This file was deleted.

‎justfile‎

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ update-models-dev-pricing:
6969
just gen-models-dev-pricing
7070
just check
7171

72-
# Bump every package version (Rust included via bump.config.ts), then commit, tag, push
73-
release: ccusage::typecheck ccusage::build
74-
pnpm bumpp -r
75-
git checkout -- $(git ls-files '*package.json')
72+
# Sync the Rust workspace version (Cargo.toml + Cargo.lock) to apps/ccusage/package.json; run by tagpr's postVersionCommand
73+
sync-rust-version:
74+
cargo set-version --manifest-path rust/Cargo.toml --workspace "$(jq -r .version apps/ccusage/package.json)"

‎nix/static-package.nix‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
# glibc-dynamic with a runpath into `/nix/store`, so it is fast for local
77
# work but NOT portable to end-user machines.
88
# * `ccusage-static` (this file) cross-compiles to musl and links fully
9-
# statically, producing the portable binary that `release.yaml` ships to
10-
# npm. The release matrix runs `nix build .#ccusage-static` for Linux;
9+
# statically, producing the portable binary that the release jobs in
10+
# `tagpr.yaml` ship to npm. The release matrix runs
11+
# `nix build .#ccusage-static` for Linux;
1112
# macOS arm64 uses the native Nix build, while macOS x64 and Windows fall
1213
# back to `cargo build` because Nix cannot target those runners.
1314
#

‎package.json‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
"dependencies": {},
1515
"devDependencies": {
1616
"@types/node": "catalog:types",
17-
"bumpp": "catalog:release",
1817
"changelogithub": "catalog:release",
1918
"pkg-pr-new": "catalog:release"
2019
},

‎pnpm-lock.yaml‎

Lines changed: 0 additions & 70 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎pnpm-workspace.yaml‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ catalogs:
1616
llm-docs:
1717
'@gunshi/docs': ^0.31.0
1818
release:
19-
bumpp: ^11.1.0
2019
changelogithub: ^14.0.0
2120
pkg-pr-new: ^0.0.75
2221
runtime:

0 commit comments

Comments
 (0)