|
| 1 | +name: Create a pre-release |
| 2 | + |
| 3 | +on: |
| 4 | + # Push to master will deploy a beta version |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - master |
| 8 | + - 'fix/ci' |
| 9 | + tags-ignore: |
| 10 | + - "**" # Ignore all tags to prevent duplicate builds when tags are pushed. |
| 11 | + |
| 12 | +concurrency: |
| 13 | + group: release |
| 14 | + cancel-in-progress: false |
| 15 | + |
| 16 | +jobs: |
| 17 | + release_metadata: |
| 18 | + if: "!startsWith(github.event.head_commit.message, 'docs') && !startsWith(github.event.head_commit.message, 'ci') && startsWith(github.repository, 'apify/')" |
| 19 | + name: Prepare release metadata |
| 20 | + runs-on: ubuntu-latest |
| 21 | + outputs: |
| 22 | + version_number: ${{ steps.release_metadata.outputs.version_number }} |
| 23 | + changelog: ${{ steps.release_metadata.outputs.changelog }} |
| 24 | + steps: |
| 25 | + - uses: apify/workflows/git-cliff-release@main |
| 26 | + name: Prepare release metadata |
| 27 | + id: release_metadata |
| 28 | + with: |
| 29 | + release_type: prerelease |
| 30 | + existing_changelog_path: CHANGELOG.md |
| 31 | + |
| 32 | + wait_for_checks: |
| 33 | + name: Wait for code checks to pass |
| 34 | + runs-on: ubuntu-latest |
| 35 | + steps: |
| 36 | + |
| 37 | + with: |
| 38 | + ref: ${{ github.ref }} |
| 39 | + repo-token: ${{ secrets.GITHUB_TOKEN }} |
| 40 | + check-name: 'Lint' |
| 41 | + wait-interval: 5 |
| 42 | + |
| 43 | + update_changelog: |
| 44 | + needs: [ release_metadata ] |
| 45 | + name: Update changelog |
| 46 | + runs-on: ubuntu-latest |
| 47 | + outputs: |
| 48 | + changelog_commitish: ${{ steps.commit.outputs.commit_long_sha || github.sha }} |
| 49 | + |
| 50 | + steps: |
| 51 | + - name: Checkout repository |
| 52 | + uses: actions/checkout@v4 |
| 53 | + with: |
| 54 | + token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }} |
| 55 | + |
| 56 | + - name: Use Node.js 22 |
| 57 | + uses: actions/setup-node@v4 |
| 58 | + with: |
| 59 | + node-version: 22 |
| 60 | + |
| 61 | + - name: Update package version in package.json |
| 62 | + run: npm version --no-git-tag-version --allow-same-version ${{ needs.release_metadata.outputs.version_number }} |
| 63 | + |
| 64 | + - name: Update CHANGELOG.md |
| 65 | + uses: DamianReeves/write-file-action@master |
| 66 | + with: |
| 67 | + path: CHANGELOG.md |
| 68 | + write-mode: overwrite |
| 69 | + contents: ${{ needs.release_metadata.outputs.changelog }} |
| 70 | + |
| 71 | + - name: Commit changes |
| 72 | + id: commit |
| 73 | + uses: EndBug/add-and-commit@v9 |
| 74 | + with: |
| 75 | + author_name: Apify Release Bot |
| 76 | + |
| 77 | + message: "chore(release): Update changelog and package version [skip ci]" |
| 78 | + |
| 79 | + publish_to_npm: |
| 80 | + name: Publish to NPM |
| 81 | + needs: [ release_metadata ] |
| 82 | + runs-on: ubuntu-latest |
| 83 | + steps: |
| 84 | + - uses: actions/checkout@v4 |
| 85 | + with: |
| 86 | + ref: ${{ needs.update_changelog.changelog_commitish }} |
| 87 | + - name: Use Node.js 22 |
| 88 | + uses: actions/setup-node@v4 |
| 89 | + with: |
| 90 | + node-version: 22 |
| 91 | + - name: Install dependencies |
| 92 | + run: | |
| 93 | + echo "access=public" >> .npmrc |
| 94 | + echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc |
| 95 | + npm install |
| 96 | + - # Check version consistency and increment pre-release version number for beta only. |
| 97 | + name: Bump pre-release version |
| 98 | + run: node ./.github/scripts/before-beta-release.cjs |
| 99 | + - name: Publish to NPM |
| 100 | + run: npm publish --tag beta |
| 101 | + |
| 102 | +env: |
| 103 | + NODE_AUTH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_NPM_TOKEN }} |
| 104 | + NPM_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_NPM_TOKEN }} |
0 commit comments