From d3884b4135684d60c096336cde11168dabff53e9 Mon Sep 17 00:00:00 2001 From: BenKalsky Date: Fri, 1 May 2026 18:13:43 +0300 Subject: [PATCH] ci: add npm publish workflow --- .github/workflows/publish-npm.yml | 67 +++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/publish-npm.yml 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 }}