Skip to content

Commit 6025e4b

Browse files
committed
Simplify: Use official npm Trusted Publishing workflow
1 parent e6bba04 commit 6025e4b

2 files changed

Lines changed: 12 additions & 55 deletions

File tree

.github/workflows/publish.yml

Lines changed: 12 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,70 +1,29 @@
11
name: Publish Package
22

33
on:
4-
release:
5-
types:
6-
- published
4+
push:
5+
tags:
6+
- "v*"
77

88
permissions:
9+
id-token: write # Required for OIDC
910
contents: read
10-
id-token: write
1111

1212
jobs:
1313
publish:
14-
if: ${{ github.event.release.prerelease == false }}
1514
runs-on: ubuntu-latest
1615
steps:
17-
- name: Checkout repository
18-
uses: actions/checkout@v4
19-
with:
20-
fetch-depth: 0
16+
- uses: actions/checkout@v4
2117

22-
- name: Set up Node.js
23-
uses: actions/setup-node@v4
18+
- uses: actions/setup-node@v4
2419
with:
2520
node-version: "20"
2621
registry-url: "https://registry.npmjs.org"
27-
scope: "@willwade"
28-
29-
- name: Install dependencies
30-
run: npm ci
31-
32-
- name: Build
33-
run: npm run build
34-
35-
- name: Derive release version
36-
id: release_version
37-
env:
38-
RELEASE_TAG: ${{ github.event.release.tag_name }}
39-
run: |
40-
VERSION="${RELEASE_TAG#refs/tags/}"
41-
VERSION="${VERSION#v}"
42-
if [[ -z "$VERSION" ]]; then
43-
echo "Unable to determine version from release tag '${RELEASE_TAG}'" >&2
44-
exit 1
45-
fi
46-
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
47-
48-
- name: Sync package metadata
49-
run: |
50-
npm version "${{ steps.release_version.outputs.version }}" --no-git-tag-version
51-
52-
- name: Get OIDC token
53-
id: oidc
54-
uses: actions/github-script@v7
55-
with:
56-
script: |
57-
const token = await core.getIDToken('https://registry.npmjs.org');
58-
core.setOutput('token', token);
59-
60-
- name: Configure npm with OIDC token
61-
run: |
62-
npm config set //registry.npmjs.org/:_authToken "${{ steps.oidc.outputs.token }}"
63-
npm config set @willwade:registry https://registry.npmjs.org/
6422

65-
- name: Publish to npm (Trusted Publishing)
66-
run: npm publish --access public --provenance
23+
# Ensure npm 11.5.1 or later is installed for proper OIDC support
24+
- name: Update npm
25+
run: npm install -g npm@latest
6726

68-
- name: Show npm debug log on failure
69-
if: failure()
70-
run: cat ~/.npm/_logs/*-debug-0.log | tail -100
27+
- run: npm ci
28+
- run: npm run build --if-present
29+
- run: npm publish --access public

.npmrc

Lines changed: 0 additions & 2 deletions
This file was deleted.

0 commit comments

Comments
 (0)