Repository navigation
120 lines (115 loc) · 5.25 KB
/
Copy pathrelease.yml
File metadata and controls
120 lines (115 loc) · 5.25 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# Pushing a tag such as v0.2.0 builds the installers on each system and publishes a release on
# GitHub with them attached, described by that version's section of CHANGELOG.md. A tag with a
# hyphen (v1.0.0-rc.1) is published as a pre-release. Nothing is published unless every system
# built: a release missing its macOS or Windows installer would be worse than a late one.
name: Release
on:
push:
tags: ['v*']
permissions:
contents: write
jobs:
build:
strategy:
fail-fast: false
matrix:
os: [windows-latest, macos-latest, ubuntu-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: pnpm
- run: pnpm install --frozen-lockfile
# Fails early when the tag has no section in the changelog, or when the versions disagree.
- run: node scripts/release-notes.mjs "${{ github.ref_name }}"
- run: pnpm test
- run: pnpm dist
env:
# The builds are not signed: there is no certificate to sign them with.
CSC_IDENTITY_AUTO_DISCOVERY: false
- uses: actions/upload-artifact@v4
with:
name: installers-${{ matrix.os }}
if-no-files-found: error
# latest*.yml and the blockmaps are what an installed app reads to update itself
# (apps/desktop/src/main/updates.ts): the version, and the sha512 its download must have.
path: |
apps/desktop/dist/*.exe
apps/desktop/dist/*.dmg
apps/desktop/dist/*.AppImage
apps/desktop/dist/latest*.yml
apps/desktop/dist/*.blockmap
# The CLI and MCP server as the package `opencalque` on npm (packages/cli/src/build-package.ts),
# then listed in the MCP registry. npm trusts this workflow (trusted publishing, set on the
# package's page on npmjs.com), so no token is kept; the registry knows the repository's GitHub
# account the same way. The first version was published by hand: npm learns of a package so.
npm:
needs: build
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
env:
MCP_PUBLISHER_VERSION: v1.8.1
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
- uses: actions/setup-node@v4
with:
node-version: 24
cache: pnpm
- run: pnpm install --frozen-lockfile
- run: pnpm package:npm
- working-directory: packages/cli/npm
run: |
# A version already on npm (published by hand, or a run done again) is left as it is.
if npm view "opencalque@${GITHUB_REF_NAME#v}" version > /dev/null 2>&1; then echo "opencalque ${GITHUB_REF_NAME#v} is already on npm"; exit 0; fi
# A version with a hyphen (1.0.0-rc.1) is not what `npx opencalque` gets.
if [[ "$GITHUB_REF_NAME" == *-* ]]; then npm publish --tag next; else npm publish; fi
- if: ${{ !contains(github.ref_name, '-') }}
uses: sigstore/cosign-installer@v3
- if: ${{ !contains(github.ref_name, '-') }}
working-directory: packages/cli/npm
run: |
set -euo pipefail
# npm takes a few minutes to serve a new version, and the registry checks it there.
# A version npm only staged waits for a maintainer to approve it on npmjs.com.
version="${GITHUB_REF_NAME#v}"
for attempt in $(seq 1 40); do
if npm view "opencalque@$version" version > /dev/null 2>&1; then break; fi
if [ "$attempt" = 40 ]; then echo "::error::opencalque $version is not on npm after 20 minutes. If it was staged, approve it on npmjs.com, then re-run this job."; exit 1; fi
sleep 30
done
archive="mcp-publisher_linux_amd64.tar.gz"
base_url="https://github.com/modelcontextprotocol/registry/releases/download/${MCP_PUBLISHER_VERSION}"
curl --fail --location --silent --show-error --output "$archive" "$base_url/$archive"
curl --fail --location --silent --show-error --output "$archive.sigstore.json" "$base_url/$archive.sigstore.json"
cosign verify-blob \
--bundle "$archive.sigstore.json" \
--certificate-identity "https://github.com/modelcontextprotocol/registry/.github/workflows/release.yml@refs/tags/${MCP_PUBLISHER_VERSION}" \
--certificate-oidc-issuer "https://token.actions.githubusercontent.com" \
"$archive"
tar xzf "$archive" mcp-publisher
rm -f "$archive" "$archive.sigstore.json"
./mcp-publisher login github-oidc
./mcp-publisher publish
publish:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v4
with:
path: installers
merge-multiple: true
- run: node scripts/release-notes.mjs "$GITHUB_REF_NAME" > notes.md
- run: |
# A version with a hyphen (1.0.0-rc.1) is a pre-release.
prerelease=""
if [[ "$GITHUB_REF_NAME" == *-* ]]; then prerelease="--prerelease"; fi
gh release create "$GITHUB_REF_NAME" installers/* --title "OpenCalque ${GITHUB_REF_NAME#v}" --notes-file notes.md $prerelease
env:
GH_TOKEN: ${{ github.token }}