diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml new file mode 100644 index 0000000..f638e7c --- /dev/null +++ b/.github/workflows/publish-npm.yml @@ -0,0 +1,67 @@ +name: Publish to npm + +on: + workflow_dispatch: + inputs: + dry_run: + description: "Run npm publish as a dry run" + required: false + default: "false" + type: choice + options: + - "false" + - "true" + +permissions: + contents: read + +concurrency: + group: publish-npm-${{ github.ref }} + cancel-in-progress: false + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - uses: pnpm/action-setup@v4 + with: + version: 10.26.0 + + - uses: actions/setup-node@v4 + with: + node-version: 22 + registry-url: https://registry.npmjs.org + cache: pnpm + + - name: Install + run: pnpm install --frozen-lockfile + + - name: Typecheck + run: pnpm typecheck + + - name: Test + run: pnpm test + + - name: Build + run: pnpm build + + - name: Pack check + run: npm pack --dry-run + + - name: Verify npm token + run: npm whoami + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} + + - name: Publish public package + run: | + if [ "${{ inputs.dry_run }}" = "true" ]; then + npm publish --access public --dry-run + else + npm publish --access public + fi + env: + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}