Skip to content

Commit 3f857d1

Browse files
authored
Merge pull request #121 from PMDevSolutions/chore/manual-npm-publish-workflow
ci: add manual publish-to-npm workflow
2 parents 0b33faf + dc39128 commit 3f857d1

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

.github/workflows/publish-npm.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Publish to npm
2+
3+
# Manual, on-demand publish of the widget to npm.
4+
#
5+
# The release-please workflow already publishes automatically when it cuts a
6+
# release. This workflow exists for the cases that one can't handle:
7+
# - bootstrapping the very first publish (the release for the current version
8+
# already exists, so re-running release-please is a no-op), and
9+
# - recovering from a failed release publish without waiting for the next
10+
# release.
11+
#
12+
# Requires the NPM_TOKEN secret to be an npm token that can publish the package
13+
# and bypasses 2FA (a classic Automation token, or a granular token with
14+
# "All packages" + read/write). Publishes with provenance (needs id-token).
15+
on:
16+
workflow_dispatch:
17+
inputs:
18+
dist-tag:
19+
description: "npm dist-tag to publish under"
20+
required: false
21+
default: "latest"
22+
23+
permissions:
24+
contents: read
25+
id-token: write # for npm provenance
26+
27+
concurrency:
28+
group: publish-npm
29+
cancel-in-progress: false
30+
31+
jobs:
32+
publish:
33+
name: Publish widget to npm
34+
runs-on: ubuntu-latest
35+
defaults:
36+
run:
37+
working-directory: widget
38+
steps:
39+
- uses: actions/checkout@v4
40+
41+
- uses: pnpm/action-setup@v4
42+
with:
43+
version: 9
44+
45+
- uses: actions/setup-node@v4
46+
with:
47+
node-version: 20
48+
registry-url: https://registry.npmjs.org
49+
cache: pnpm
50+
cache-dependency-path: widget/pnpm-lock.yaml
51+
52+
- name: Install
53+
run: pnpm install --frozen-lockfile
54+
55+
- name: Build
56+
run: pnpm build
57+
58+
- name: Publish
59+
env:
60+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
61+
run: npm publish --provenance --access public --tag "${{ inputs.dist-tag }}"

0 commit comments

Comments
 (0)