|
1 | 1 | name: Create a pre-release |
2 | 2 |
|
3 | 3 | on: |
4 | | - workflow_dispatch: |
5 | | - # Push to master will deploy a beta version |
6 | | - push: |
7 | | - branches: |
8 | | - - master |
9 | | - tags-ignore: |
10 | | - - "**" # Ignore all tags to prevent duplicate builds when tags are pushed. |
| 4 | + # Only trigger on PRs with "beta" label |
| 5 | + pull_request: |
| 6 | + types: [labeled, synchronize, reopened] |
11 | 7 |
|
12 | 8 | concurrency: |
13 | 9 | group: release |
14 | 10 | cancel-in-progress: false |
15 | 11 |
|
16 | 12 | 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 | 13 | wait_for_checks: |
| 14 | + # Run ONLY when PR has the "beta" label |
| 15 | + if: contains(github.event.pull_request.labels.*.name, 'beta') |
33 | 16 | name: Wait for code checks to pass |
34 | 17 | runs-on: ubuntu-latest |
35 | 18 | steps: |
36 | | - |
| 19 | + - name: Wait for existing checks or skip if none |
| 20 | + |
37 | 21 | with: |
38 | | - ref: ${{ github.ref }} |
| 22 | + ref: ${{ github.event.pull_request.head.sha }} |
39 | 23 | repo-token: ${{ secrets.GITHUB_TOKEN }} |
40 | 24 | check-regexp: (Code checks) |
41 | | - wait-interval: 5 |
42 | | - |
43 | | - update_changelog: |
44 | | - needs: [ release_metadata, wait_for_checks ] |
45 | | - name: Update changelog |
| 25 | + wait-interval: 10 |
| 26 | + running-workflow-name: 'Wait for code checks to pass' |
| 27 | + allowed-conclusions: success,neutral,skipped |
| 28 | + continue-on-error: false |
| 29 | + |
| 30 | + push_pkg_pr_new: |
| 31 | + needs: [ wait_for_checks ] |
| 32 | + name: Push to pkg.pr.new |
46 | 33 | runs-on: ubuntu-latest |
47 | | - outputs: |
48 | | - changelog_commitish: ${{ steps.commit.outputs.commit_long_sha || github.sha }} |
49 | 34 |
|
50 | 35 | steps: |
51 | 36 | - name: Checkout repository |
52 | 37 | uses: actions/checkout@v4 |
53 | 38 | with: |
54 | | - token: ${{ secrets.APIFY_SERVICE_ACCOUNT_GITHUB_TOKEN }} |
| 39 | + ref: ${{ github.event.pull_request.head.ref }} |
| 40 | + repository: ${{ github.event.pull_request.head.repo.full_name }} |
55 | 41 |
|
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, wait_for_checks ] |
82 | | - runs-on: ubuntu-latest |
83 | | - steps: |
84 | | - - uses: actions/checkout@v4 |
85 | | - with: |
86 | | - ref: ${{ needs.update_changelog.changelog_commitish }} |
87 | 42 | - name: Use Node.js 22 |
88 | 43 | uses: actions/setup-node@v4 |
89 | 44 | with: |
90 | 45 | node-version: 22 |
91 | 46 | cache: 'npm' |
92 | 47 | cache-dependency-path: 'package-lock.json' |
| 48 | + |
93 | 49 | - name: Install dependencies |
94 | | - run: | |
95 | | - echo "access=public" >> .npmrc |
96 | | - echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc |
97 | | - npm ci |
98 | | - - # Check version consistency and increment pre-release version number for beta only. |
99 | | - name: Bump pre-release version |
100 | | - run: node ./.github/scripts/before-beta-release.cjs |
101 | | - - name: Build module |
| 50 | + run: npm ci |
| 51 | + |
| 52 | + - name: Build |
102 | 53 | run: npm run build |
103 | | - - name: Publish to NPM |
104 | | - run: npm publish --tag beta |
105 | 54 |
|
106 | | -env: |
107 | | - NODE_AUTH_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_NPM_TOKEN }} |
108 | | - NPM_TOKEN: ${{ secrets.APIFY_SERVICE_ACCOUNT_NPM_TOKEN }} |
| 55 | + - run: npx -y pkg-pr-new publish |
0 commit comments