-
Notifications
You must be signed in to change notification settings - Fork 1
400 lines (339 loc) · 13.4 KB
/
release.yml
File metadata and controls
400 lines (339 loc) · 13.4 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
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
name: Release
on:
workflow_dispatch:
inputs:
version:
description: "Specific version to release (e.g. 1.2.3, 1.2.3-beta.1, 1.2.3-rc.1), or leave empty for auto-detect from conventional commits"
required: false
type: string
jobs:
release:
runs-on: ubuntu-latest
permissions:
contents: write
outputs:
version: ${{ steps.release_meta.outputs.version }}
prerelease: ${{ steps.release_meta.outputs.prerelease }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Determine next version (auto)
if: inputs.version == ''
id: semver
uses: ietf-tools/semver-action@v1
with:
token: ${{ github.token }}
noVersionBumpBehavior: patch
noNewCommitBehavior: patch
- name: Validate manual version
if: inputs.version != ''
run: |
if ! echo "${{ inputs.version }}" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+(-(beta|rc)\.[0-9]+)?$'; then
echo "::error::Invalid version format '${{ inputs.version }}'. Expected X.Y.Z, X.Y.Z-beta.N, or X.Y.Z-rc.N"
exit 1
fi
- name: Set release metadata
id: release_meta
env:
VERSION: ${{ inputs.version != '' && inputs.version || steps.semver.outputs.nextStrict }}
run: |
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
if echo "$VERSION" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+-(beta|rc)\.[0-9]+$'; then
echo "prerelease=true" >> "$GITHUB_OUTPUT"
else
echo "prerelease=false" >> "$GITHUB_OUTPUT"
fi
- name: Create tag
env:
VERSION: ${{ steps.release_meta.outputs.version }}
run: |
git tag "$VERSION"
git push origin "$VERSION"
- name: Generate release notes
id: changelog
uses: requarks/changelog-action@v1
with:
token: ${{ github.token }}
tag: ${{ steps.release_meta.outputs.version }}
writeToFile: false
useGitmojis: false
excludeTypes: ""
includeInvalidCommits: true
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.release_meta.outputs.version }}
body: ${{ steps.changelog.outputs.changes }}
prerelease: ${{ steps.release_meta.outputs.prerelease == 'true' }}
build-macos:
runs-on: macos-14
needs: release
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
ref: ${{ needs.release.outputs.version }}
- uses: oven-sh/setup-bun@v2
- uses: actions/cache@v5
with:
path: |
~/.bun/install/cache
~\.bun\install\cache
key: ${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}
restore-keys: ${{ runner.os }}-bun-
- run: bun install --frozen-lockfile
- name: Set version in package.json
env:
VERSION: ${{ needs.release.outputs.version }}
run: |
bun -e "
const pkg = await Bun.file('package.json').json();
pkg.version = process.env.VERSION;
await Bun.write('package.json', JSON.stringify(pkg, null, 2) + '\n');
"
- name: Build Electrobun app
run: bun run build -- --env=stable
- name: Import code signing certificate
env:
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
run: |
CERT_FILE=$(mktemp /tmp/certificate.XXXXXX.p12)
KEYCHAIN_FILE=$(mktemp /tmp/keychain.XXXXXX.keychain-db)
KEYCHAIN_PASSWORD=$(openssl rand -base64 32)
echo "$APPLE_CERTIFICATE" | base64 --decode > "$CERT_FILE"
security create-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_FILE"
security set-keychain-settings -lut 21600 "$KEYCHAIN_FILE"
security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_FILE"
security import "$CERT_FILE" -P "$APPLE_CERTIFICATE_PASSWORD" -A -t cert -f pkcs12 -k "$KEYCHAIN_FILE"
security set-key-partition-list -S apple-tool:,apple: -k "$KEYCHAIN_PASSWORD" "$KEYCHAIN_FILE"
security list-keychains -d user -s "$KEYCHAIN_FILE" login.keychain
echo "KEYCHAIN_FILE=$KEYCHAIN_FILE" >> "$GITHUB_ENV"
rm "$CERT_FILE"
- name: Sign and notarize macOS app
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
APPLE_APP_PASSWORD: ${{ secrets.APPLE_APP_PASSWORD }}
run: |
BUILD_DIR="build/stable-macos-arm64"
if [ ! -d "$BUILD_DIR" ]; then
echo "::error::Expected build output in $BUILD_DIR"
find build -maxdepth 2 -type d || true
exit 1
fi
APP_DIR=$(find "$BUILD_DIR" -maxdepth 1 -type d -name "*.app" | head -1)
if [ -z "$APP_DIR" ]; then
echo "::error::Could not find .app bundle in $BUILD_DIR"
exit 1
fi
IDENTITY="Developer ID Application: Cookielab s.r.o. ($APPLE_TEAM_ID)"
# Sign all nested binaries, frameworks, and dylibs from the inside out
find "$APP_DIR" -type f \( -name "*.dylib" -o -name "*.so" \) -exec \
codesign --force --options runtime --sign "$IDENTITY" --keychain "$KEYCHAIN_FILE" {} \;
find "$APP_DIR" -type d -name "*.framework" -exec \
codesign --force --options runtime --sign "$IDENTITY" --keychain "$KEYCHAIN_FILE" {} \;
# Sign any helper executables inside the bundle
find "$APP_DIR/Contents/MacOS" -type f -perm +111 -exec \
codesign --force --options runtime --sign "$IDENTITY" --keychain "$KEYCHAIN_FILE" {} \;
# Sign the app bundle itself
codesign --force --options runtime --sign "$IDENTITY" --keychain "$KEYCHAIN_FILE" "$APP_DIR"
echo "Verifying signature..."
codesign --verify --deep --strict "$APP_DIR"
# Create zip for notarization
NOTARIZE_ZIP=$(mktemp /tmp/notarize.XXXXXX.zip)
ditto -c -k --keepParent "$APP_DIR" "$NOTARIZE_ZIP"
echo "Submitting for notarization..."
xcrun notarytool submit "$NOTARIZE_ZIP" \
--apple-id "$APPLE_ID" \
--team-id "$APPLE_TEAM_ID" \
--password "$APPLE_APP_PASSWORD" \
--wait
rm "$NOTARIZE_ZIP"
echo "Stapling notarization ticket..."
xcrun stapler staple "$APP_DIR"
echo "APP_DIR=$APP_DIR" >> "$GITHUB_ENV"
- name: Package and upload macOS arm64 asset
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.release.outputs.version }}
run: |
ZIP_NAME="Klovi-${VERSION}-macos-arm64.zip"
ditto -c -k --keepParent "$APP_DIR" "$ZIP_NAME"
gh release upload "$VERSION" "$ZIP_NAME" --clobber
- name: Clean up keychain
if: always()
run: |
if [ -n "$KEYCHAIN_FILE" ] && [ -f "$KEYCHAIN_FILE" ]; then
security delete-keychain "$KEYCHAIN_FILE"
fi
build-linux:
runs-on: ${{ matrix.runner }}
needs: release
strategy:
fail-fast: false
matrix:
include:
- runner: ubuntu-24.04
electrobun_arch: x64
artifact_arch: amd64
- runner: ubuntu-24.04-arm
electrobun_arch: arm64
artifact_arch: arm64
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
ref: ${{ needs.release.outputs.version }}
- uses: oven-sh/setup-bun@v2
- uses: actions/cache@v5
with:
path: |
~/.bun/install/cache
~\.bun\install\cache
key: ${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}
restore-keys: ${{ runner.os }}-bun-
- run: bun install --frozen-lockfile
- name: Set version in package.json
env:
VERSION: ${{ needs.release.outputs.version }}
run: |
bun -e "
const pkg = await Bun.file('package.json').json();
pkg.version = process.env.VERSION;
await Bun.write('package.json', JSON.stringify(pkg, null, 2) + '\n');
"
- name: Build Electrobun app
run: bun run build -- --env=stable
- name: Package and upload Linux asset
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.release.outputs.version }}
ELECTROBUN_ARCH: ${{ matrix.electrobun_arch }}
ARTIFACT_ARCH: ${{ matrix.artifact_arch }}
run: |
# Electrobun stable builds produce a self-extracting installer in artifacts/
INSTALLER="artifacts/stable-linux-${ELECTROBUN_ARCH}-Klovi-Setup.tar.gz"
if [ ! -f "$INSTALLER" ]; then
echo "::error::Expected installer at $INSTALLER"
find artifacts -type f 2>/dev/null || echo "No artifacts directory found"
find build -maxdepth 2 -type f -name "*.tar.gz" 2>/dev/null || true
exit 1
fi
ASSET_NAME="Klovi-${VERSION}-linux-${ARTIFACT_ARCH}.tar.gz"
cp "$INSTALLER" "$ASSET_NAME"
gh release upload "$VERSION" "$ASSET_NAME" --clobber
build-windows:
runs-on: ${{ matrix.runner }}
needs: release
strategy:
fail-fast: false
matrix:
include:
- runner: windows-2025
electrobun_arch: x64
artifact_arch: amd64
- runner: windows-11-arm
electrobun_arch: arm64
artifact_arch: arm64
permissions:
contents: write
steps:
- uses: actions/checkout@v6
with:
ref: ${{ needs.release.outputs.version }}
- uses: oven-sh/setup-bun@v2
- uses: actions/cache@v5
with:
path: |
~/.bun/install/cache
~\.bun\install\cache
key: ${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}
restore-keys: ${{ runner.os }}-bun-
- run: bun install --frozen-lockfile
- name: Set version in package.json
env:
VERSION: ${{ needs.release.outputs.version }}
run: |
bun -e "
const pkg = await Bun.file('package.json').json();
pkg.version = process.env.VERSION;
await Bun.write('package.json', JSON.stringify(pkg, null, 2) + '\n');
"
- name: Build Electrobun app
run: bun run build -- --env=stable
- name: Package and upload Windows asset
env:
GH_TOKEN: ${{ github.token }}
VERSION: ${{ needs.release.outputs.version }}
ELECTROBUN_ARCH: ${{ matrix.electrobun_arch }}
ARTIFACT_ARCH: ${{ matrix.artifact_arch }}
shell: pwsh
run: |
# Electrobun stable builds produce a self-extracting installer zip in artifacts/
$installer = "artifacts/stable-win-$env:ELECTROBUN_ARCH-Klovi-Setup.zip"
if (-not (Test-Path $installer)) {
Write-Host "::error::Expected installer at $installer"
if (Test-Path artifacts) {
Get-ChildItem artifacts -File -Recurse | ForEach-Object { $_.FullName }
}
if (Test-Path build) {
Get-ChildItem build -File -Recurse -Filter "*.zip" | ForEach-Object { $_.FullName }
}
exit 1
}
$assetName = "Klovi-$env:VERSION-windows-$env:ARTIFACT_ARCH.zip"
Copy-Item $installer $assetName
gh release upload $env:VERSION $assetName --clobber
update-cask:
if: ${{ needs.release.outputs.prerelease != 'true' }}
runs-on: ubuntu-latest
needs:
- release
- build-macos
environment: homebrew
steps:
- name: Download release asset and update Homebrew cask
env:
GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
VERSION: ${{ needs.release.outputs.version }}
REPO: ${{ github.repository }}
run: |
set -e
ZIP_NAME="Klovi-${VERSION}-macos-arm64.zip"
curl -L -o "$ZIP_NAME" \
"https://github.com/${REPO}/releases/download/${VERSION}/${ZIP_NAME}"
SHA256=$(sha256sum "$ZIP_NAME" | cut -d' ' -f1)
BASE_URL="https://github.com/${REPO}/releases/download/${VERSION}"
git clone "https://x-access-token:${GH_TOKEN}@github.com/cookielab/homebrew-tap.git"
cd homebrew-tap
# Remove old Formula if it exists
rm -f Formula/klovi.rb
mkdir -p Casks
cat > Casks/klovi.rb << CASK
cask "klovi" do
version "${VERSION}"
sha256 "${SHA256}"
url "${BASE_URL}/${ZIP_NAME}"
name "Klovi"
desc "Native desktop app for browsing and presenting AI coding session history"
homepage "https://github.com/${REPO}"
depends_on arch: :arm64
app "Klovi.app"
zap trash: [
"~/Library/Application Support/io.cookielab.klovi",
"~/Library/Preferences/io.cookielab.klovi.plist",
"~/Library/Caches/io.cookielab.klovi",
]
end
CASK
# Remove leading whitespace from heredoc indentation
sed -i 's/^ //' Casks/klovi.rb
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add -A
git commit -m "Update klovi cask to ${VERSION}"
git push