Repository navigation
85 lines (77 loc) · 2.97 KB
/
Copy pathrelease.yml
File metadata and controls
85 lines (77 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Release after merge, by default: every push to master whose package version has
# no tag yet becomes a GitHub release and an npm publish of both packages. One
# workflow on purpose: a release made with GITHUB_TOKEN does not trigger other
# workflows, so a separate "on: release" publish would never run.
#
# To ship: bump "version" in packages/cli/package.json AND packages/mcp/package.json
# (the check below refuses a mismatch) and merge.
#
# NPM_TOKEN is the house automation token. Keep it current in GitHub Actions.
name: release
on:
push:
branches: [master]
workflow_dispatch:
permissions:
contents: write
id-token: write
concurrency:
group: release
cancel-in-progress: false
jobs:
release:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.4.4
- uses: actions/setup-node@v4
with:
node-version: 24
registry-url: https://registry.npmjs.org
- run: bun install --frozen-lockfile
- run: bun test
- name: Read and check versions
id: v
run: |
CLI=$(node -p "require('./packages/cli/package.json').version")
MCP=$(node -p "require('./packages/mcp/package.json').version")
if [ "$CLI" != "$MCP" ]; then
echo "::error::packages/cli is $CLI but packages/mcp is $MCP; bump both"; exit 1
fi
echo "version=$CLI" >> "$GITHUB_OUTPUT"
if git ls-remote --exit-code --tags origin "refs/tags/v$CLI" >/dev/null; then
echo "tagged=true" >> "$GITHUB_OUTPUT"; echo "v$CLI is already released"
else
echo "tagged=false" >> "$GITHUB_OUTPUT"
fi
- name: Require an npm token
if: steps.v.outputs.tagged == 'false'
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
[ -n "$NPM_TOKEN" ] || { echo "::error::NPM_TOKEN repository secret is not set"; exit 1; }
# Publish order matters: the MCP package depends on the CLI package.
- name: Publish to npm (skips a version already there)
if: steps.v.outputs.tagged == 'false'
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
VERSION: ${{ steps.v.outputs.version }}
run: |
for dir in packages/cli packages/mcp; do
name=$(node -p "require('./$dir/package.json').name")
version=$(node -p "require('./$dir/package.json').version")
if npm view "$name@$version" version >/dev/null 2>&1; then
echo "$name@$version already on npm"
else
(cd "$dir" && npm publish --access public --provenance)
fi
done
- name: Create the GitHub release
if: steps.v.outputs.tagged == 'false'
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ steps.v.outputs.version }}
run: gh release create "v$VERSION" --target "$GITHUB_SHA" --generate-notes --title "v$VERSION"