Skip to content

Commit 2bd1ad7

Browse files
authored
fix: improve beta release cicd (#202)
* improve beta release ci * fix beta versioning to find latest stable release and wait for code checks * lint * fix git ref * do not commit package.json beta version * remove the changelog logic * skip code checks when no beta tag * refactor * clean up * try the pkg.pr.new * ci: clean upp add ci skip condition * ci: skip ci test commit * revert ci condition, simplify workflow * document canary releases
1 parent 4bafd8d commit 2bd1ad7

File tree

3 files changed

+29
-109
lines changed

3 files changed

+29
-109
lines changed

.github/scripts/before-beta-release.cjs

Lines changed: 0 additions & 33 deletions
This file was deleted.

.github/workflows/pre_release.yaml

Lines changed: 23 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,108 +1,55 @@
11
name: Create a pre-release
22

33
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]
117

128
concurrency:
139
group: release
1410
cancel-in-progress: false
1511

1612
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-
3213
wait_for_checks:
14+
# Run ONLY when PR has the "beta" label
15+
if: contains(github.event.pull_request.labels.*.name, 'beta')
3316
name: Wait for code checks to pass
3417
runs-on: ubuntu-latest
3518
steps:
36-
- uses: lewagon/[email protected]
19+
- name: Wait for existing checks or skip if none
20+
uses: lewagon/[email protected]
3721
with:
38-
ref: ${{ github.ref }}
22+
ref: ${{ github.event.pull_request.head.sha }}
3923
repo-token: ${{ secrets.GITHUB_TOKEN }}
4024
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
4633
runs-on: ubuntu-latest
47-
outputs:
48-
changelog_commitish: ${{ steps.commit.outputs.commit_long_sha || github.sha }}
4934

5035
steps:
5136
- name: Checkout repository
5237
uses: actions/checkout@v4
5338
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 }}
5541

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-
author_email: [email protected]
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 }}
8742
- name: Use Node.js 22
8843
uses: actions/setup-node@v4
8944
with:
9045
node-version: 22
9146
cache: 'npm'
9247
cache-dependency-path: 'package-lock.json'
48+
9349
- 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
10253
run: npm run build
103-
- name: Publish to NPM
104-
run: npm publish --tag beta
10554

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

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,12 @@ npx @modelcontextprotocol/inspector node ./dist/stdio.js
235235

236236
Upon launching, the Inspector will display a URL that you can open in your browser to begin debugging.
237237

238+
## 🐦 Canary PR releases
239+
240+
Due to the current architecture where Apify MCP is split across two repositories, this one containing the core MCP logic and the private [apify-mcp-server](https://github.com/apify/apify-mcp-server) repository that handles the actual server implementation for [mcp.apify.com](https://mcp.apify.com), development can be challenging as changes need to be synchronized between both repositories.
241+
242+
You can create a canary release from your PR branch by adding the `beta` tag. This will test the code and publish the package to [pkg.pr.new](https://pkg.pr.new/) which you can then use, for example, in a staging environment to test before actually merging the changes. This way we do not need to create new NPM releases and keep the NPM versions cleaner. The workflow runs whenever you commit to a PR branch that has the `beta` tag or when you add the `beta` tag to an already existing PR. For more details check out [the workflow file](.github/workflows/pre_release.yaml).
243+
238244
# 🐛 Troubleshooting (local MCP server)
239245

240246
- Make sure you have `node` installed by running `node -v`.

0 commit comments

Comments
 (0)