Skip to content

Commit 567171e

Browse files
committed
ci: promote-latest tag flips the npm dist-tag
Re-pointing latest previously required local npm credentials; a promote-latest-v<version> tag now does it through CI with the same NPM_TOKEN as the release workflow. Verifies the version exists first — this never publishes.
1 parent 0d9db55 commit 567171e

1 file changed

Lines changed: 39 additions & 0 deletions

File tree

.github/workflows/promote.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Promote dist-tag
2+
3+
# Flip the npm `latest` dist-tag to an already-published version without
4+
# cutting a new release: push a tag named promote-latest-v<version>, e.g.
5+
#
6+
# git tag promote-latest-v2.0.0-pre.67 && git push origin promote-latest-v2.0.0-pre.67
7+
#
8+
# Uses the same NPM_TOKEN as release.yml. The version must already exist
9+
# on the registry — this never publishes, only re-points the tag.
10+
11+
on:
12+
push:
13+
tags:
14+
- "promote-latest-v*"
15+
16+
permissions:
17+
contents: read
18+
19+
jobs:
20+
promote:
21+
name: Point latest at the tagged version
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/setup-node@v4
25+
with:
26+
node-version: "20"
27+
registry-url: "https://registry.npmjs.org/"
28+
29+
- name: Verify the version exists on npm
30+
run: |
31+
VERSION="${GITHUB_REF_NAME#promote-latest-v}"
32+
npm view "codebase-cli@$VERSION" version
33+
34+
- name: Re-point latest
35+
run: |
36+
VERSION="${GITHUB_REF_NAME#promote-latest-v}"
37+
npm dist-tag add "codebase-cli@$VERSION" latest
38+
env:
39+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

0 commit comments

Comments
 (0)