Skip to content
Closed
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
73 changes: 73 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: publish

on:
release:
types: [published]

permissions:
contents: read
id-token: write
attestations: write
artifact-metadata: write

jobs:
check:
name: check npm package version
if: github.event.release.prerelease == false
runs-on: ubuntu-latest
outputs:
should_publish: ${{ steps.publish_status.outputs.exists == '0' }}

steps:
- name: checkout
uses: actions/checkout@v6

- name: setup node 24
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: https://registry.npmjs.org

- name: check npm package version
id: publish_status
uses: tehpsalmist/npm-publish-status-action@01cb25946b194a7a5468f22c8e74db04c283f121

publish:
name: publish to npmjs
needs: check
if: needs.check.outputs.should_publish == 'true'
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v6

- name: setup node 24
uses: actions/setup-node@v6
with:
node-version: 24
registry-url: https://registry.npmjs.org
cache: npm

- name: install dependencies
run: npm ci

- name: pack package
id: pack
run: |
mkdir -p dist
npm pack --json --pack-destination dist > dist/pack.json
tarball="$(find dist -maxdepth 1 -name '*.tgz' -print -quit)"
test -n "$tarball"
echo "tarball=$tarball" >> "$GITHUB_OUTPUT"

- name: attest npm package artifact
uses: actions/attest@v4
with:
subject-path: ${{ steps.pack.outputs.tarball }}

- name: publish package
run: npm publish "$TARBALL" --provenance --access public
env:
TARBALL: ${{ steps.pack.outputs.tarball }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}