Skip to content

Commit 6daa3da

Browse files
authored
Merge pull request #2 from proxymesh/test-all-modules-and-fix-failures
ci: publish to npm on GitHub Release
2 parents cbcb0f7 + 0403910 commit 6daa3da

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

.github/workflows/release-npm.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Publish to npm on GitHub Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
permissions:
8+
contents: read
9+
id-token: write
10+
11+
jobs:
12+
publish:
13+
runs-on: ubuntu-latest
14+
steps:
15+
- name: Checkout
16+
uses: actions/checkout@v4
17+
18+
- name: Setup Node
19+
uses: actions/setup-node@v4
20+
with:
21+
node-version: 20
22+
registry-url: https://registry.npmjs.org
23+
cache: npm
24+
25+
- name: Ensure release tag matches package.json version
26+
shell: bash
27+
run: |
28+
set -euo pipefail
29+
PKG_VERSION="$(node -p "require('./package.json').version")"
30+
TAG_NAME="${{ github.event.release.tag_name }}"
31+
if [[ "$TAG_NAME" != "v$PKG_VERSION" && "$TAG_NAME" != "$PKG_VERSION" ]]; then
32+
echo "Release tag '$TAG_NAME' does not match package.json version '$PKG_VERSION' (expected '$PKG_VERSION' or 'v$PKG_VERSION')."
33+
exit 1
34+
fi
35+
36+
- name: Install dependencies
37+
run: npm ci
38+
39+
- name: Publish
40+
env:
41+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
42+
run: npm publish --access public --provenance

0 commit comments

Comments
 (0)