diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..8abac1b --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: MIT OR Apache-2.0 +# Copyright (c) 2025 Daemoniorum, LLC + +name: Publish + +on: + release: + types: [published] + workflow_dispatch: + inputs: + dry_run: + description: 'Dry run (skip actual publish)' + required: false + default: 'false' + type: boolean + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + registry-url: 'https://registry.npmjs.org' + + - name: Install dependencies + run: npm ci + + - name: Build + run: npm run build + + - name: Verify package + run: npm pack --dry-run + + - name: Publish to npm + if: ${{ github.event.inputs.dry_run != 'true' }} + run: npm publish --provenance --access public + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Publish (dry run) + if: ${{ github.event.inputs.dry_run == 'true' }} + run: npm publish --dry-run + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}