Update publish workflow to use npm for publishing #57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Publish Package to npm | |
| on: | |
| push: | |
| branches: | |
| - main | |
| pull_request: | |
| branches: | |
| - main | |
| permissions: write-all | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - run: bun i | |
| - run: bun test --coverage | |
| - run: bun lint | |
| - run: bun run build | |
| changepacks: | |
| name: changepacks | |
| runs-on: ubuntu-latest | |
| permissions: | |
| # create pull request comments | |
| pull-requests: write | |
| # Actions > General > Workflow permissions for creating pull request | |
| # Create brench to create pull request | |
| contents: write | |
| needs: | |
| - check | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: changepacks/action@main | |
| id: changepacks | |
| outputs: | |
| changepacks: ${{ steps.changepacks.outputs.changepacks }} | |
| publish: | |
| runs-on: ubuntu-latest | |
| needs: | |
| - changepacks | |
| if: contains(needs.changepacks.outputs.changepacks, 'package.json') | |
| permissions: | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v5 | |
| - uses: oven-sh/setup-bun@v2 | |
| with: | |
| bun-version: latest | |
| - run: bun i | |
| - run: bun test --coverage --coverage-reporter=lcov | |
| - run: bun run build | |
| - name: Upload to codecov.io | |
| uses: codecov/codecov-action@v5 | |
| with: | |
| token: ${{ secrets.CODECOV_TOKEN }} | |
| fail_ci_if_error: true | |
| files: ./coverage/lcov.info | |
| # npm (not bun) does the actual publish: bun cannot perform the npm OIDC | |
| # token exchange. Trusted Publishing needs npm >= 11.5.1. | |
| - uses: actions/setup-node@v6 | |
| with: | |
| node-version: "24" | |
| registry-url: "https://registry.npmjs.org" | |
| - name: Ensure npm >= 11.5.1 (OIDC Trusted Publishing) | |
| run: npm install -g npm@latest | |
| - run: npm publish --access public --ignore-scripts |