-
Notifications
You must be signed in to change notification settings - Fork 0
279 lines (231 loc) · 9.59 KB
/
release.yml
File metadata and controls
279 lines (231 loc) · 9.59 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# Build CLI + desktop app installers, then create a GitHub Release.
#
# Triggered by: git push origin main --tags (after running `make release`)
#
# What it does:
# 1. Bundles CLI as a single .mjs file
# 2. Builds desktop app for macOS (dmg)
# 3. Extracts changelog for this version
# 4. Creates a GitHub Release with all artifacts + changelog
# 5. Updates manifest.json with the final git hash
name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
# ── CLI (single .mjs file, platform-independent) ─────────────────
# ink/yoga-layout use top-level await (ESM-only) which is incompatible
# with Node.js SEA (CJS-only). We ship a single .mjs bundle instead.
# The install script creates a wrapper that invokes it with node.
cli:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- uses: pnpm/action-setup@v4
with:
version: 9
- name: Install dependencies
run: pnpm install --ignore-scripts
- name: Build TypeScript
run: |
pnpm --filter @anton/protocol build
pnpm --filter @anton/cli build
- name: Get CLI version
id: cli_version
run: echo "version=$(node -e "console.log(JSON.parse(require('fs').readFileSync('packages/cli/package.json','utf8')).version)")" >> "$GITHUB_OUTPUT"
- name: Bundle CLI with esbuild
run: |
# Stub out react-devtools-core (ink imports it but it's optional/dev-only)
mkdir -p .stubs
echo "export default {};" > .stubs/react-devtools-core.mjs
CLI_EXTERNALS=$(node scripts/esbuild.config.js cli-externals)
npx esbuild packages/cli/dist/index.js \
--bundle \
--platform=node \
--target=node22 \
--format=esm \
--outfile=anton-cli.mjs \
$CLI_EXTERNALS \
--alias:react-devtools-core=./.stubs/react-devtools-core.mjs \
--define:__CLI_VERSION__=\"${{ steps.cli_version.outputs.version }}\" \
--banner:js="import{createRequire}from'module';const require=createRequire(import.meta.url);"
chmod +x anton-cli.mjs
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: anton-cli
path: anton-cli.mjs
# ── Sidecar (Go binary, cross-compiled for Linux) ────────────────
sidecar:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.25'
cache-dependency-path: sidecar/go.sum
- name: Extract version from tag
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Cross-compile sidecar
working-directory: sidecar
run: |
VERSION="${{ steps.version.outputs.version }}"
LDFLAGS="-s -w -X main.version=${VERSION}"
GOOS=linux GOARCH=arm64 go build -ldflags "$LDFLAGS" -o ../anton-sidecar-linux-arm64 .
GOOS=linux GOARCH=amd64 go build -ldflags "$LDFLAGS" -o ../anton-sidecar-linux-amd64 .
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: sidecar-binaries
path: |
anton-sidecar-linux-arm64
anton-sidecar-linux-amd64
# ── Detect desktop changes (tag events don't support path filters) ─
desktop-changes:
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.check.outputs.changed }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if desktop-related files changed since last tag
id: check
run: |
# Find the previous tag (the one before the current push)
PREV_TAG=$(git tag --sort=-v:refname | grep '^v' | sed -n '2p')
if [ -z "$PREV_TAG" ]; then
echo "No previous tag found — building desktop"
echo "changed=true" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "Comparing $PREV_TAG..HEAD"
# Paths that should trigger a desktop rebuild
DESKTOP_PATHS="packages/desktop/ packages/protocol/"
CHANGED=$(git diff --name-only "$PREV_TAG"..HEAD -- $DESKTOP_PATHS)
if [ -n "$CHANGED" ]; then
echo "Desktop-related files changed:"
echo "$CHANGED"
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "No desktop-related files changed — skipping build"
echo "changed=false" >> "$GITHUB_OUTPUT"
fi
# ── Desktop app (macOS) ─────────────────────────────────────────
desktop:
needs: [desktop-changes]
if: needs.desktop-changes.outputs.changed == 'true'
strategy:
matrix:
include:
- os: macos-latest
target: macos
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: '22'
- uses: pnpm/action-setup@v4
with:
version: 9
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Install dependencies
run: pnpm install
- name: Build protocol (desktop dependency)
run: pnpm --filter @anton/protocol build
- name: Build desktop app
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
with:
projectPath: packages/desktop
tauriScript: pnpm tauri
- name: Upload desktop artifacts
uses: actions/upload-artifact@v4
with:
name: desktop-${{ matrix.target }}
path: |
packages/desktop/src-tauri/target/release/bundle/**/*.dmg
packages/desktop/src-tauri/target/release/bundle/**/*.app.tar.gz
packages/desktop/src-tauri/target/release/bundle/**/*.app.tar.gz.sig
packages/desktop/src-tauri/target/release/bundle/**/*.msi
packages/desktop/src-tauri/target/release/bundle/**/*.msi.sig
packages/desktop/src-tauri/target/release/bundle/**/*.AppImage
packages/desktop/src-tauri/target/release/bundle/**/*.AppImage.sig
packages/desktop/src-tauri/target/release/bundle/**/*.deb
# ── Create GitHub Release ────────────────────────────────────────
release:
needs: [cli, sidecar, desktop]
if: always() && needs.cli.result == 'success' && needs.sidecar.result == 'success'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
path: artifacts
- name: Extract version from tag
id: version
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
- name: Extract changelog
run: |
VERSION="${{ steps.version.outputs.version }}"
node -e "
const fs = require('fs');
const changelog = fs.readFileSync('CHANGELOG.md', 'utf8');
const regex = new RegExp('## \\\\[' + '${VERSION}'.replace(/\\./g, '\\\\.') + '\\\\][\\\\s\\\\S]*?(?=\\n---)', 'm');
const match = changelog.match(regex);
fs.writeFileSync('release-notes.md', match ? match[0] : 'Release v${VERSION}');
"
- name: Collect all release assets
run: |
mkdir -p release-assets
# CLI
cp artifacts/anton-cli/anton-cli.mjs release-assets/ 2>/dev/null || true
# Sidecar binaries
cp artifacts/sidecar-binaries/anton-sidecar-linux-* release-assets/ 2>/dev/null || true
# Desktop installers (only present when desktop files changed)
if ls artifacts/desktop-* 1>/dev/null 2>&1; then
find artifacts/desktop-* -type f \( \
-name "*.dmg" -o -name "*.msi" -o -name "*.AppImage" -o -name "*.deb" \
-o -name "*.app.tar.gz" -o -name "*.app.tar.gz.sig" \
-o -name "*.msi.sig" -o -name "*.AppImage.sig" \
\) -exec cp {} release-assets/ \;
find artifacts/desktop-* -name "latest.json" -exec cp {} release-assets/ \; 2>/dev/null || true
fi
echo "Release assets:"
ls -lh release-assets/
- name: Create GitHub Release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create "${{ github.ref_name }}" \
--title "v${{ steps.version.outputs.version }}" \
--notes-file release-notes.md \
release-assets/*
- name: Update manifest with git hash
run: |
GIT_HASH=$(git rev-parse --short HEAD)
node -e "
const fs = require('fs');
const manifest = JSON.parse(fs.readFileSync('manifest.json', 'utf8'));
manifest.gitHash = '${GIT_HASH}';
fs.writeFileSync('manifest.json', JSON.stringify(manifest, null, 2) + '\n');
"
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add manifest.json
git commit -m "ci: update manifest.json with git hash for v${{ steps.version.outputs.version }}"
git push origin HEAD:main