Skip to content

Commit 2866514

Browse files
authored
Use npm trusted publishing (#22)
* update node to 24 * update publish workflow to run automatically on release * use npm publish
1 parent 314c389 commit 2866514

2 files changed

Lines changed: 27 additions & 11 deletions

File tree

.github/workflows/publish.yaml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,40 @@
1-
21
on:
3-
push:
4-
branches: [ main ]
5-
2+
release:
3+
types: [created]
4+
5+
permissions:
6+
id-token: write # Required for OIDC
7+
contents: read
8+
69
jobs:
710
build:
811
runs-on: ubuntu-latest
912
steps:
1013
- uses: actions/checkout@v3
1114
- uses: actions/setup-node@v3
1215
with:
16+
registry-url: 'https://registry.npmjs.org'
1317
node-version-file: '.nvmrc'
1418
cache: 'yarn'
15-
19+
1620
- name: install
1721
run: yarn install
1822

19-
- name: Publish
20-
if: github.ref == 'refs/heads/main'
21-
uses: Github-Actions-Community/merge-release@v6.0.7
23+
- name: Update package.json version to match tag
24+
run: |
25+
TAG_VERSION="${GITHUB_REF#refs/tags/}"
26+
# Remove leading 'v' if present in tag
27+
if [[ "$TAG_VERSION" == v* ]]; then
28+
TAG_VERSION="${TAG_VERSION:1}"
29+
fi
30+
node -e "
31+
const fs = require('fs');
32+
const pkg = require('./package.json');
33+
pkg.version = process.env.TAG_VERSION;
34+
fs.writeFileSync('./package.json', JSON.stringify(pkg, null, 2) + '\n');
35+
"
2236
env:
23-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24-
NPM_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
37+
TAG_VERSION: ${{ github.ref_name }}
38+
39+
- name: publish
40+
run: npm publish

.nvmrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v18.15.0
1+
v24.15.0

0 commit comments

Comments
 (0)