name: Publish CLI on: release: types: [published] workflow_dispatch: inputs: dry-run: description: 'Dry run (no actual publish)' required: false default: 'true' type: boolean concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true jobs: publish: name: Publish to npm runs-on: ubuntu-latest permissions: contents: read id-token: write steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: '20' registry-url: 'https://registry.npmjs.org' - name: Install dependencies run: yarn install --frozen-lockfile - name: Build run: yarn build - name: Run tests run: yarn test - name: Verify CLI run: | node lib/cli.js version node lib/cli.js --help - name: Publish (dry run) if: github.event_name == 'workflow_dispatch' && inputs.dry-run == 'true' run: npm publish --dry-run env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - name: Publish if: github.event_name == 'release' || (github.event_name == 'workflow_dispatch' && inputs.dry-run == 'false') run: npm publish --provenance --access public env: NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}