-
-
Notifications
You must be signed in to change notification settings - Fork 1
431 lines (387 loc) · 15.3 KB
/
Copy pathci.yml
File metadata and controls
431 lines (387 loc) · 15.3 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
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
name: CI
on:
push:
branches: [ main, develop ]
pull_request:
branches: [ main ]
workflow_dispatch:
inputs:
release-tag:
description: Release version tag (e.g. v0.1.0)
required: true
default: v0.1.0
type: string
prerelease:
description: Mark the GitHub release as a prerelease
required: true
default: false
type: boolean
env:
R2_BUCKET: osagent-releases
R2_RELEASE_PREFIX: releases
CDN_BASE_URL: https://osa.fuckyourcdn.com
jobs:
validate-release-tag:
if: github.event_name == 'workflow_dispatch'
runs-on: ubuntu-22.04
steps:
- name: Validate release tag format
shell: bash
run: |
RELEASE_TAG="${{ inputs['release-tag'] }}"
if [[ ! "$RELEASE_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
echo "Invalid release tag: $RELEASE_TAG"
echo "Expected format: v0.1.0 or v0.1.0-rc1"
exit 1
fi
quick:
if: github.event_name != 'workflow_dispatch'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Check formatting
run: cargo fmt --all -- --check
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
libjavascriptcoregtk-4.1-dev \
libwayland-dev \
build-essential \
curl \
wget \
file \
libxdo-dev \
libssl-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
libsoup-3.0-dev \
libgtk-3-dev
- name: Run clippy
run: cargo clippy --all-targets --features discord -- -D warnings
release-linux:
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
needs: validate-release-tag
runs-on: ubuntu-22.04
env:
RELEASE_TAG: ${{ inputs['release-tag'] }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
updater/target
launcher/target
key: linux-cargo-release-${{ hashFiles('**/Cargo.lock') }}
- name: Install Linux dependencies
run: |
sudo apt-get update
sudo apt-get install -y \
libwebkit2gtk-4.1-dev \
libjavascriptcoregtk-4.1-dev \
libwayland-dev \
build-essential \
curl \
wget \
file \
libxdo-dev \
libssl-dev \
libayatana-appindicator3-dev \
librsvg2-dev \
libsoup-3.0-dev \
libgtk-3-dev
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Bundle frontend
run: |
cd frontend
npm install
npm run build
- name: Install cargo-tauri CLI
run: cargo install tauri-cli --locked
- name: Build Linux release artifacts
run: |
export OSAGENT_APP_VERSION="${RELEASE_TAG#v}"
perl -0pi -e 's/"version":\s*"[^"]+"/"version": "'"$OSAGENT_APP_VERSION"'"/' launcher/tauri.conf.json
cargo build --release --features discord,production-frontend
CARGO_TARGET_DIR="$GITHUB_WORKSPACE/updater/target" cargo build --manifest-path updater/Cargo.toml --release
export OSAGENT_CORE_SOURCE="$GITHUB_WORKSPACE/target/release/osagent"
export OSAGENT_UPDATER_SOURCE="$GITHUB_WORKSPACE/updater/target/release/osagent-updater"
(cd launcher && cargo tauri build --bundles deb --target x86_64-unknown-linux-gnu)
DEB_FILE=$(find "$GITHUB_WORKSPACE/launcher/target/x86_64-unknown-linux-gnu/release/bundle/deb" -name "*.deb" | head -1)
if [ -z "$DEB_FILE" ] || [ ! -f "$DEB_FILE" ]; then
echo "Linux .deb bundle not found"
exit 1
fi
cp "$DEB_FILE" "$GITHUB_WORKSPACE/osagent-linux-x86_64.deb"
(cd "$GITHUB_WORKSPACE" && sha256sum osagent-linux-x86_64.deb > osagent-linux-x86_64.deb.sha256)
- name: Upload Linux release artifacts
uses: actions/upload-artifact@v4
with:
name: linux-x86_64
path: |
osagent-linux-x86_64.deb
osagent-linux-x86_64.deb.sha256
release-windows-installer:
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
needs: validate-release-tag
runs-on: windows-latest
env:
RELEASE_TAG: ${{ inputs['release-tag'] }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
updater/target
launcher/target
key: win-installer-cargo-release-${{ hashFiles('**/Cargo.lock') }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Bundle frontend
shell: pwsh
run: |
Set-Location frontend
npm install
npm run build
- name: Install cargo-tauri CLI
run: cargo install tauri-cli --locked
- name: Build Windows installer artifacts
shell: pwsh
run: |
$env:OSAGENT_APP_VERSION = $env:RELEASE_TAG.TrimStart("v")
$configPath = Join-Path $env:GITHUB_WORKSPACE "launcher/tauri.conf.json"
$config = Get-Content $configPath -Raw
$config = [regex]::Replace($config, '"version"\s*:\s*"[^"]+"', '"version": "' + $env:OSAGENT_APP_VERSION + '"')
Set-Content -Path $configPath -Value $config -NoNewline
./build-launcher.ps1 -Installer
Copy-Item "launcher/target/release/bundle/nsis/*.exe" "osagent-windows-x86_64-setup.exe"
Get-FileHash osagent-windows-x86_64-setup.exe -Algorithm SHA256 | ForEach-Object { "$($_.Hash.ToLower()) osagent-windows-x86_64-setup.exe" } | Set-Content osagent-windows-x86_64-setup.exe.sha256
- name: Upload Windows installer artifacts
uses: actions/upload-artifact@v4
with:
name: windows-installer
path: |
osagent-windows-x86_64-setup.exe
osagent-windows-x86_64-setup.exe.sha256
release-macos-arm64:
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
needs: validate-release-tag
runs-on: macos-14
env:
RELEASE_TAG: ${{ inputs['release-tag'] }}
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
updater/target
launcher/target
key: macos-arm64-cargo-release-${{ hashFiles('**/Cargo.lock') }}
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Bundle frontend
run: |
cd frontend
npm install
npm run build
- name: Install cargo-tauri CLI
run: cargo install tauri-cli --locked
- name: Build macOS release artifacts
run: |
export OSAGENT_APP_VERSION="${RELEASE_TAG#v}"
sed -i '' 's/"version":\s*"[^"]*"/"version": "'"$OSAGENT_APP_VERSION"'"/' launcher/tauri.conf.json
cargo build --release --features discord,production-frontend
CARGO_TARGET_DIR="$GITHUB_WORKSPACE/updater/target" cargo build --manifest-path updater/Cargo.toml --release
export OSAGENT_CORE_SOURCE="$GITHUB_WORKSPACE/target/release/osagent"
export OSAGENT_UPDATER_SOURCE="$GITHUB_WORKSPACE/updater/target/release/osagent-updater"
(cd launcher && cargo tauri build --bundles app --target aarch64-apple-darwin)
APP_BUNDLE=$(find "$GITHUB_WORKSPACE/launcher/target/aarch64-apple-darwin/release/bundle/macos" -name "*.app" -maxdepth 1 -type d | head -1)
if [ -z "$APP_BUNDLE" ] || [ ! -d "$APP_BUNDLE" ]; then
echo "macOS .app bundle not found"
exit 1
fi
echo "==> Ad-hoc signing app bundle..."
codesign --force --deep --sign - "$APP_BUNDLE"
codesign -dv "$APP_BUNDLE"
echo "==> Creating DMG from signed .app..."
DMG_STAGING="$GITHUB_WORKSPACE/dmg-staging"
rm -rf "$DMG_STAGING"
mkdir -p "$DMG_STAGING"
cp -R "$APP_BUNDLE" "$DMG_STAGING/"
ln -s /Applications "$DMG_STAGING/Applications"
DMG_FILE="$GITHUB_WORKSPACE/osagent-macos-arm64.dmg"
hdiutil create -volname "OSAgent Launcher" -srcfolder "$DMG_STAGING" -format UDZO -ov "$DMG_FILE"
echo "==> DMG created: $DMG_FILE"
if [ ! -f "$DMG_FILE" ]; then
echo "DMG creation failed"
exit 1
fi
(cd "$GITHUB_WORKSPACE" && shasum -a 256 osagent-macos-arm64.dmg > osagent-macos-arm64.dmg.sha256)
- name: Verify DMG
run: |
DMG_PATH="$GITHUB_WORKSPACE/osagent-macos-arm64.dmg"
echo "==> Verifying DMG integrity..."
hdiutil verify "$DMG_PATH"
echo "==> Checking DMG contents..."
hdiutil imageinfo "$DMG_PATH"
echo "==> Attempting attach (read-only, no browse)..."
hdiutil attach "$DMG_PATH" -readonly -nobrowse -mountpoint /tmp/osagent-dmg-mount
ls -laR /tmp/osagent-dmg-mount/
APP_BUNDLE=$(find /tmp/osagent-dmg-mount -name "*.app" -type d -maxdepth 3 | head -1)
if [ -z "$APP_BUNDLE" ]; then
echo "ERROR: No .app bundle found in DMG"
hdiutil detach /tmp/osagent-dmg-mount 2>/dev/null || true
exit 1
fi
echo "==> .app bundle found: $APP_BUNDLE"
echo "==> Checking .app structure..."
ls -la "$APP_BUNDLE/Contents/"
echo "==> Checking code signature..."
if ! codesign -dv "$APP_BUNDLE"; then
echo "ERROR: App bundle is not code-signed"
hdiutil detach /tmp/osagent-dmg-mount 2>/dev/null || true
exit 1
fi
echo "==> .app is ad-hoc signed (CI build - notarization not required)"
echo "==> Validating binary runtime integrity..."
BIN="$APP_BUNDLE/Contents/MacOS/osagent-launcher"
echo "--- Mach-O type/arch ---"
file "$BIN"
echo "--- Linked libraries ---"
otool -L "$BIN"
echo "--- Info.plist keys ---"
/usr/libexec/PlistBuddy -c "Print CFBundleExecutable" "$APP_BUNDLE/Contents/Info.plist"
/usr/libexec/PlistBuddy -c "Print CFBundleIdentifier" "$APP_BUNDLE/Contents/Info.plist"
/usr/libexec/PlistBuddy -c "Print CFBundleVersion" "$APP_BUNDLE/Contents/Info.plist"
echo "--- Gatekeeper assessment ---"
spctl -a -t exec -vv "$APP_BUNDLE" 2>&1 || echo "(expected: notarization not available in CI)"
hdiutil detach /tmp/osagent-dmg-mount
echo "==> DMG verification passed"
- name: Upload macOS release artifacts
uses: actions/upload-artifact@v4
with:
name: macos-arm64
path: |
osagent-macos-arm64.dmg
osagent-macos-arm64.dmg.sha256
publish-r2:
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
needs:
- release-linux
- release-windows-installer
- release-macos-arm64
runs-on: ubuntu-22.04
environment: release
env:
RELEASE_TAG: ${{ inputs['release-tag'] }}
R2_ACCOUNT_ID: ${{ secrets.R2_ACCOUNT_ID }}
R2_ACCESS_KEY_ID: ${{ secrets.R2_ACCESS_KEY_ID }}
R2_SECRET_ACCESS_KEY: ${{ secrets.R2_SECRET_ACCESS_KEY }}
steps:
- uses: actions/checkout@v4
- name: Download release artifacts
uses: actions/download-artifact@v4
with:
path: release
- name: Flatten downloaded artifacts
shell: bash
run: |
mkdir -p release-flat
find release -type f -exec cp {} release-flat/ \;
- name: Install AWS CLI
run: |
sudo apt-get update
sudo apt-get install -y awscli
- name: Upload release to Cloudflare R2
run: |
chmod +x upload-to-r2.sh
./upload-to-r2.sh "$RELEASE_TAG" release-flat
- name: Upload release manifest artifact
uses: actions/upload-artifact@v4
with:
name: release-manifest
path: release-flat/release-manifest.json
github-release:
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
needs: publish-r2
runs-on: ubuntu-22.04
permissions:
contents: write
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ inputs['release-tag'] }}
PRERELEASE: ${{ inputs.prerelease }}
steps:
- name: Create or update GitHub release
shell: bash
run: |
RELEASE_DIR_URL="${CDN_BASE_URL}/${R2_RELEASE_PREFIX}/${RELEASE_TAG}"
BODY=$(cat <<EOF
Installer release for Windows, Linux, and macOS with bundled core and updater. Auto-updates are served from Cloudflare R2 via ${CDN_BASE_URL}/${R2_RELEASE_PREFIX}/latest.json.
Assets:
- [osagent-linux-x86_64.deb](${RELEASE_DIR_URL}/osagent-linux-x86_64.deb)
- [osagent-linux-x86_64.deb.sha256](${RELEASE_DIR_URL}/osagent-linux-x86_64.deb.sha256)
- [osagent-macos-arm64.dmg](${RELEASE_DIR_URL}/osagent-macos-arm64.dmg)
- [osagent-macos-arm64.dmg.sha256](${RELEASE_DIR_URL}/osagent-macos-arm64.dmg.sha256)
- [osagent-windows-x86_64-setup.exe](${RELEASE_DIR_URL}/osagent-windows-x86_64-setup.exe)
- [osagent-windows-x86_64-setup.exe.sha256](${RELEASE_DIR_URL}/osagent-windows-x86_64-setup.exe.sha256)
- [release-manifest.json](${RELEASE_DIR_URL}/release-manifest.json)
- [latest.json](${CDN_BASE_URL}/${R2_RELEASE_PREFIX}/latest.json)
EOF
)
if [ "$PRERELEASE" = "true" ]; then
PRERELEASE_JSON=true
else
PRERELEASE_JSON=false
fi
if RELEASE_ID=$(gh api "repos/${GITHUB_REPOSITORY}/releases/tags/${RELEASE_TAG}" --jq .id 2>/dev/null); then
gh api \
--method PATCH \
-H "Accept: application/vnd.github+json" \
"repos/${GITHUB_REPOSITORY}/releases/${RELEASE_ID}" \
-f name="OSAgent ${RELEASE_TAG}" \
-f body="$BODY" \
-F prerelease="$PRERELEASE_JSON"
else
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
"repos/${GITHUB_REPOSITORY}/releases" \
-f tag_name="$RELEASE_TAG" \
-f target_commitish="${GITHUB_SHA}" \
-f name="OSAgent ${RELEASE_TAG}" \
-f body="$BODY" \
-F prerelease="$PRERELEASE_JSON"
fi