Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 52 additions & 8 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,25 @@ on:
release:
types: [published]

permissions: {}

jobs:
publish:
build:
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read

steps:
- uses: actions/checkout@v4
with:
persist-credentials: false

- name: Setup Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '18'
node-version: '24'
cache: 'npm'
registry-url: 'https://registry.npmjs.org'

- name: Validate version
run: |
Expand Down Expand Up @@ -55,7 +61,45 @@ jobs:
- name: Build widget
run: npm run build:widget

- name: Publish to npm
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
- name: Pack npm artifact
run: |
mkdir -p "$RUNNER_TEMP/npm-package"
npm pack --ignore-scripts --pack-destination "$RUNNER_TEMP/npm-package"

- name: Upload npm artifact
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: npm-package
path: ${{ runner.temp }}/npm-package/*.tgz
if-no-files-found: error
retention-days: 1

publish:
needs: build
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
id-token: write
steps:
# Keep package code and caches out of the job with publishing authority.
- name: Set up Node.js
uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
package-manager-cache: false

- name: Download npm artifact
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
with:
name: npm-package
path: .release

- name: Publish npm artifact
run: |
tarballs=(.release/*.tgz)
if [[ ${#tarballs[@]} -ne 1 || ! -f "${tarballs[0]}" ]]; then
echo "::error::Expected exactly one npm package tarball."
exit 1
fi
npm publish "${tarballs[0]}" --access public --ignore-scripts
Loading