Skip to content

Commit 48ea147

Browse files
committed
updated workflows
1 parent 0b25011 commit 48ea147

File tree

3 files changed

+178
-38
lines changed

3 files changed

+178
-38
lines changed

.github/scripts/is_release.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/sh
2+
3+
# This script checks if the current commit contains changesets.
4+
5+
set -eu
6+
7+
CHANGES=$(node -e "require('@changesets/read').default(process.cwd()).then(result => console.log(!!result.length))")
8+
9+
echo "${CHANGES}"
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Publish MCP Packages
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
E2B_API_KEY:
7+
required: true
8+
NPM_TOKEN:
9+
required: true
10+
PYPI_TOKEN:
11+
required: true
12+
13+
permissions:
14+
contents: write
15+
16+
jobs:
17+
test:
18+
name: Publish Desktop SDK
19+
runs-on: ubuntu-20.04
20+
steps:
21+
- uses: actions/create-github-app-token@v1
22+
id: app-token
23+
with:
24+
app-id: ${{ vars.VERSION_BUMPER_APPID }}
25+
private-key: ${{ secrets.VERSION_BUMPER_SECRET }}
26+
27+
- name: Checkout Repo
28+
uses: actions/checkout@v3
29+
with:
30+
token: ${{ steps.app-token.outputs.token }}
31+
32+
- name: Set up Python
33+
uses: actions/setup-python@v4
34+
with:
35+
python-version: "3.9"
36+
37+
- name: Install and configure Poetry
38+
uses: snok/install-poetry@v1
39+
with:
40+
version: 1.5.1
41+
virtualenvs-create: true
42+
virtualenvs-in-project: true
43+
installer-parallel: true
44+
45+
- uses: pnpm/action-setup@v3
46+
with:
47+
version: 9.5
48+
49+
- name: Setup Node.js 18
50+
uses: actions/setup-node@v3
51+
with:
52+
node-version: '18.x'
53+
cache: pnpm
54+
55+
- name: Configure pnpm
56+
run: |
57+
pnpm config set auto-install-peers true
58+
pnpm config set exclude-links-from-lockfile true
59+
60+
- name: Install dependencies
61+
run: pnpm install --frozen-lockfile
62+
63+
- name: Create new versions
64+
run: pnpm run version
65+
env:
66+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67+
68+
- name: Generate SDK reference
69+
id: sdk-ref
70+
run: pnpm run --recursive generate-ref
71+
72+
- name: Show docs file structure
73+
run: tree ./sdk-reference
74+
75+
- name: Release new versions
76+
uses: changesets/action@v1
77+
with:
78+
publish: pnpm run publish
79+
createGithubReleases: true
80+
env:
81+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
82+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
83+
PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
84+
85+
- name: Update lock file
86+
run: pnpm i --no-link --no-frozen-lockfile
87+
88+
- name: Commit new versions
89+
run: |
90+
git config user.name "github-actions[bot]"
91+
git config user.email "github-actions[bot]@users.noreply.github.com"
92+
git add ./sdk-reference
93+
git commit -am "[skip ci] Release new versions" || exit 0
94+
git push
95+
env:
96+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/release.yml

Lines changed: 73 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,38 @@
1-
name: Publish Packages
1+
name: Release MCP Packages
22

33
on:
4-
workflow_call:
5-
secrets:
6-
NPM_TOKEN:
7-
required: true
4+
push:
5+
branches:
6+
- main
7+
8+
concurrency: ${{ github.workflow }}-${{ github.ref }}
89

910
permissions:
1011
contents: write
1112

1213
jobs:
13-
release:
14-
name: Release
15-
runs-on: ubuntu-20.04
14+
is_release:
15+
name: Is release?
16+
runs-on: ubuntu-latest
17+
outputs:
18+
release: ${{ steps.version.outputs.release }}
1619
steps:
17-
- uses: actions/create-github-app-token@v1
18-
id: app-token
19-
with:
20-
app-id: ${{ vars.VERSION_BUMPER_APPID }}
21-
private-key: ${{ secrets.VERSION_BUMPER_SECRET }}
22-
2320
- name: Checkout Repo
2421
uses: actions/checkout@v3
25-
with:
26-
token: ${{ steps.app-token.outputs.token }}
2722

28-
- uses: pnpm/action-setup@v3
23+
- name: Install pnpm
24+
uses: pnpm/action-setup@v3
25+
id: pnpm-install
2926
with:
3027
version: 9.5
3128

32-
- name: Setup Node.js 18
29+
- name: Setup Node
3330
uses: actions/setup-node@v3
3431
with:
35-
node-version: '18.x'
32+
node-version: "18.x"
33+
registry-url: "https://registry.npmjs.org"
3634
cache: pnpm
35+
cache-dependency-path: pnpm-lock.yaml
3736

3837
- name: Configure pnpm
3938
run: |
@@ -43,28 +42,64 @@ jobs:
4342
- name: Install dependencies
4443
run: pnpm install --frozen-lockfile
4544

46-
- name: Create new versions
47-
run: pnpm run version
48-
env:
49-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
- name: Check if new version
46+
id: version
47+
run: |
48+
IS_RELEASE=$(./.github/scripts/is_release.sh)
49+
echo "release=$IS_RELEASE" >> "$GITHUB_OUTPUT"
5050
51-
- name: Release new versions
52-
uses: changesets/action@v1
51+
changes:
52+
name: Repository changes
53+
needs: [is_release]
54+
if: needs.is_release.outputs.release == 'true'
55+
runs-on: ubuntu-latest
56+
outputs:
57+
js-sdk: ${{ steps.filter.outputs.js-sdk }}
58+
python-sdk: ${{ steps.filter.outputs.python-sdk }}
59+
steps:
60+
- name: Checkout repository
61+
uses: actions/checkout@v3
5362
with:
54-
publish: pnpm run publish
55-
createGithubReleases: true
63+
fetch-depth: 0
64+
65+
- name: Get the last release
66+
id: last_release
67+
uses: cardinalby/git-get-release-action@v1
5668
env:
57-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
58-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
69+
GITHUB_TOKEN: ${{ github.token }}
70+
with:
71+
latest: true
72+
prerelease: false
73+
draft: false
5974

60-
- name: Update lock file
61-
run: pnpm i --no-link --no-frozen-lockfile
75+
- name: Find changes since the last release
76+
uses: dorny/paths-filter@v2
77+
id: filter
78+
with:
79+
base: ${{ steps.last_release.outputs.tag_name }}
80+
filters: |
81+
js:
82+
- 'packages/js/**'
83+
python:
84+
- 'packages/python/**'
6285
63-
- name: Commit new versions
64-
run: |
65-
git config user.name "github-actions[bot]"
66-
git config user.email "github-actions[bot]@users.noreply.github.com"
67-
git commit -am "[skip ci] Release new versions" || exit 0
68-
git push
86+
publish:
87+
name: Publish
88+
needs: [is_release]
89+
if: (!cancelled()) && !contains(needs.*.result, 'failure') && needs.is_release.outputs.release == 'true'
90+
uses: ./.github/workflows/publish_packages.yml
91+
secrets: inherit
92+
93+
report-failure:
94+
needs: [publish]
95+
if: failure()
96+
name: Release Failed - Slack Notification
97+
runs-on: ubuntu-latest
98+
steps:
99+
- name: Release Failed - Slack Notification
100+
uses: rtCamp/action-slack-notify@v2
69101
env:
70-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
102+
SLACK_COLOR: "#ff0000"
103+
SLACK_MESSAGE: ":here-we-go-again: :bob-the-destroyer: We need :fix-parrot: ASAP :pray:"
104+
SLACK_TITLE: Release Failed
105+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}

0 commit comments

Comments
 (0)