Publish to NPM #182
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 to NPM | |
| on: | |
| workflow_call: | |
| inputs: | |
| ref: | |
| description: Git ref to publish (branch, tag, or commit SHA) | |
| required: true | |
| type: string | |
| dist-tag: | |
| description: NPM dist-tag (prod or next) | |
| required: false | |
| type: string | |
| default: 'prod' | |
| workflow_dispatch: | |
| inputs: | |
| ref: | |
| description: Git ref to publish (branch, tag, or commit SHA) | |
| required: true | |
| type: string | |
| dist-tag: | |
| description: NPM dist-tag (prod or next) | |
| required: false | |
| type: string | |
| default: 'prod' | |
| concurrency: | |
| group: publish-to-npm | |
| cancel-in-progress: false | |
| permissions: | |
| id-token: write # Required for OIDC | |
| contents: write # Required to push updates | |
| jobs: | |
| publish_to_npm: | |
| name: Publish to NPM (${{ inputs.dist-tag }}) | |
| runs-on: ubuntu-22.04 | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ inputs.ref }} | |
| token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Use Node.js 24 | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 24 | |
| package-manager-cache: false | |
| - name: Turbo cache | |
| id: turbo-cache | |
| uses: actions/cache@v5 | |
| with: | |
| path: .turbo | |
| key: turbo-${{ github.job }}-${{ github.ref_name }}-${{ github.sha }} | |
| restore-keys: | | |
| turbo-${{ github.job }}-${{ github.ref_name }}- | |
| - uses: apify/workflows/pnpm-install@main | |
| - name: Build packages | |
| run: pnpm ci:build | |
| - name: Bump canary versions | |
| if: inputs.dist-tag != 'prod' | |
| run: | | |
| pnpm turbo copy --force -- --canary=major --preid=beta | |
| - name: Commit changes | |
| if: inputs.dist-tag != 'prod' | |
| uses: EndBug/add-and-commit@v10 | |
| id: commit | |
| with: | |
| author_name: Apify Release Bot | |
| author_email: noreply@apify.com | |
| message: 'chore: bump canary versions [skip ci]' | |
| push: false | |
| - name: Publish to NPM (@latest) | |
| if: inputs.dist-tag == 'prod' | |
| uses: nick-fields/retry@v4 | |
| with: | |
| timeout_minutes: 10 | |
| max_attempts: 5 | |
| retry_wait_seconds: 30 | |
| command: git checkout . && pnpm publish:prod | |
| env: | |
| GH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }} | |
| - name: Publish to NPM (@next) | |
| if: inputs.dist-tag != 'prod' | |
| uses: nick-fields/retry@v4 | |
| with: | |
| timeout_minutes: 10 | |
| max_attempts: 5 | |
| retry_wait_seconds: 30 | |
| command: git checkout . && pnpm publish:next | |
| env: | |
| GH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }} |