Skip to content

Commit 48f8975

Browse files
committed
ci: add v2 maintenance release line
Mirror the v1 maintenance pattern from ai-tool-set: cut the v2 branch as a separate release line for the previous major once v3 becomes latest. - ci.yml: add a release-v2 job (gated to the v2 branch, target-branch v2, default config/manifest, manually merged) and trigger CI on pushes to v2 - release.yml: publish under the legacy dist-tag and force-push the floating v2.x tag, so v2 releases never move latest off the current major
1 parent b17bcef commit 48f8975

2 files changed

Lines changed: 39 additions & 11 deletions

File tree

.github/workflows/ci.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ on:
55
branches:
66
- main
77
- next
8+
- v2
89
pull_request:
910

1011
concurrency:
@@ -105,3 +106,23 @@ jobs:
105106
env:
106107
GH_TOKEN: ${{ secrets.RELEASE_PLEASE_TOKEN }}
107108
run: gh pr merge --squash --auto -R "${{ github.repository }}" "${{ fromJSON(steps.release.outputs.pr).number }}"
109+
110+
# Stable maintenance line for the previous major, cut from the `v2` branch.
111+
# Uses the default release-please-config.json / .release-please-manifest.json,
112+
# which on this branch track the 2.x line. The release PR is reviewed and
113+
# merged manually; on merge it tags + creates a GitHub Release, which
114+
# release.yml (on this branch) publishes under the `legacy` dist-tag so it
115+
# stays off `latest`.
116+
release-v2:
117+
name: Release v2
118+
runs-on: ubuntu-latest
119+
needs: [lint, test]
120+
if: github.ref == 'refs/heads/v2'
121+
steps:
122+
# https://github.com/googleapis/release-please-action
123+
- name: Release Please
124+
uses: googleapis/release-please-action@v5
125+
with:
126+
# https://github.com/googleapis/release-please-action?tab=readme-ov-file#github-credentials
127+
token: ${{ secrets.RELEASE_PLEASE_TOKEN }}
128+
target-branch: v2

.github/workflows/release.yml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ on:
1212

1313
permissions:
1414
id-token: write # needed for npm publish with provenance
15+
contents: write # needed to force-push the floating major version tag
1516

1617
jobs:
1718
release:
@@ -30,14 +31,20 @@ jobs:
3031
cache: 'pnpm'
3132
- run: pnpm install
3233
- run: pnpm build
33-
# A prerelease release (cut from the `next` branch) is flagged
34-
# `prerelease: true` by release-please, so publish it under the `next`
35-
# dist-tag to keep `latest` pointing at the stable line. A normal release
36-
# publishes to `latest`. workflow_dispatch has no release payload, so the
37-
# prerelease flag is falsy and it publishes to `latest`.
38-
- name: Publish to npm (latest)
39-
if: ${{ !github.event.release.prerelease }}
40-
run: pnpm publish --provenance --no-git-checks
41-
- name: Publish to npm (next)
42-
if: ${{ github.event.release.prerelease }}
43-
run: pnpm publish --provenance --no-git-checks --tag next
34+
# This is the v2 maintenance line. It always publishes under the `legacy`
35+
# dist-tag so it never moves `latest` off the current major.
36+
# (npm rejects `v2` as a dist-tag since it parses as a SemVer range.)
37+
- name: Publish to npm (legacy)
38+
run: pnpm publish --provenance --no-git-checks --tag legacy
39+
# Move the floating v2.x tag onto this release commit so version-pinned
40+
# links like /tree/v2.x always resolve to the newest v2 release. Pushed
41+
# with the default GITHUB_TOKEN, whose pushes do not re-trigger workflows.
42+
# Gated to `release` since workflow_dispatch has no tag payload.
43+
- name: Update major version tag
44+
if: ${{ github.event_name == 'release' }}
45+
env:
46+
TAG: ${{ github.event.release.tag_name }} # e.g. v2.2.0
47+
run: |
48+
major="${TAG%%.*}" # v2.2.0 -> v2
49+
git tag -f "${major}.x" # tag the checked-out release commit -> v2.x
50+
git push -f origin "${major}.x"

0 commit comments

Comments
 (0)