Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c435d20

Browse files
committed
feat: promote npm edge tag to latest when prerelease is promoted
Adds a 'released' trigger to the release workflow with a lightweight 'promote' job that runs npm dist-tag to move 'latest' to the current version when a prerelease is promoted to a full release. The existing publish pipeline remains gated to 'published' events only.
1 parent be60d4d commit c435d20

1 file changed

Lines changed: 25 additions & 1 deletion

File tree

.github/workflows/release.yml

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,33 @@ name: Publish to NPM
33
on:
44
release:
55
types:
6-
- created
6+
- published
7+
- released
78
jobs:
9+
# When a prerelease is promoted to a full release, update the npm latest tag
10+
promote:
11+
if: github.event.action == 'released'
12+
runs-on: ubuntu-24.04
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v6
16+
- name: Install node 20
17+
uses: actions/setup-node@v6
18+
with:
19+
node-version: '20'
20+
registry-url: https://registry.npmjs.org
21+
- name: Promote edge to latest
22+
run: |
23+
VERSION=$(echo "$TAG_NAME" | sed 's/^v//')
24+
PACKAGE=$(node -p "require('./package.json').name")
25+
npm dist-tag add "$PACKAGE@$VERSION" latest
26+
echo "::notice title=Promoted $VERSION to latest::The latest tag now points to $VERSION (was edge-only)"
27+
env:
28+
TAG_NAME: ${{ github.event.release.tag_name }}
29+
NODE_AUTH_TOKEN: ${{secrets.NPM_DEPLOY_TOKEN}}
30+
831
deploy:
32+
if: github.event.action == 'published'
933
runs-on: ${{ matrix.os }}
1034
env:
1135
TERM: xterm

0 commit comments

Comments
 (0)