Skip to content

Publish to npm

Publish to npm #2

Workflow file for this run

name: Publish to npm
on:
release:
types: [published]
workflow_dispatch:
permissions:
contents: read
id-token: write
jobs:
publish:
if: github.repository == 'deckflow/html-editor'
runs-on: ubuntu-latest
steps:
- name: Check out the release
uses: actions/checkout@v6
- name: Set up Node.js
uses: actions/setup-node@v6
with:
node-version: '24'
registry-url: 'https://registry.npmjs.org'
package-manager-cache: false
- name: Install dependencies
run: npm ci
- name: Verify release tag
env:
RELEASE_TAG: ${{ github.event.release.tag_name }}
run: >-
node --input-type=module -e '
import { readFileSync } from "node:fs";
const { version } = JSON.parse(readFileSync("package.json", "utf8"));
const tag = process.env.RELEASE_TAG;
if (tag && tag !== version && tag !== `v${version}`) {
throw new Error(`Release tag ${tag} does not match package version ${version}`);
}
console.log(`Publishing @deckflow/html-editor@${version}`);
'
- name: Test package
run: npm test
- name: Inspect package contents
run: npm pack --dry-run
- name: Publish package
run: npm publish --access public --provenance
env:
# Used only to bootstrap the first release. Once npm Trusted
# Publishing is configured, OIDC takes precedence and this secret
# can be deleted from GitHub and revoked on npmjs.com.
NODE_AUTH_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }}