-
-
Notifications
You must be signed in to change notification settings - Fork 62
488 lines (440 loc) · 17.3 KB
/
main.yml
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
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
name: Release
on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+*"
env:
TAURI_PRIVATE_KEY: ${{ secrets.TAURI_PRIVATE_KEY }}
TAURI_KEY_PASSWORD: ${{ secrets.TAURI_KEY_PASSWORD }}
VITE_ENV: "production"
TAURI_DEBUG: "false"
jobs:
validate-version:
runs-on: ubuntu-24.04
steps:
- name: Validate version format
run: |
if ! [[ ${{ github.ref_name }} =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9.]+)?$ ]]; then
echo "Invalid version format. Must be vX.Y.Z or vX.Y.Z-suffix"
exit 1
fi
create-release-draft:
needs: validate-version
permissions:
contents: write
runs-on: ubuntu-24.04
outputs:
release_id: ${{ steps.create_release.outputs.id }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check existing release
id: check_release
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Attempt to get release ID and check if it's a valid number
release_id=$(gh api repos/${{ github.repository }}/releases/tags/${{ github.ref_name }} --jq .id 2>/dev/null || echo "")
if [[ "$release_id" =~ ^[0-9]+$ ]]; then
echo "Release already exists with ID: $release_id"
echo "release_exists=true" >> "$GITHUB_OUTPUT"
echo "existing_release_id=$release_id" >> "$GITHUB_OUTPUT"
else
echo "Release does not exist"
echo "release_exists=false" >> "$GITHUB_OUTPUT"
fi
- name: Create release draft
id: create_release
if: steps.check_release.outputs.release_exists != 'true'
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref_name }}
release_name: "KFtray - ${{ github.ref_name }}"
draft: true
prerelease: false
- name: Set release ID output
run: |
if [ "${{ steps.check_release.outputs.release_exists }}" == "true" ]; then
echo "id=${{ steps.check_release.outputs.existing_release_id }}" >> "$GITHUB_OUTPUT"
else
echo "id=${{ steps.create_release.outputs.id }}" >> "$GITHUB_OUTPUT"
fi
kftray-tauri:
needs: create-release-draft
permissions:
contents: write
strategy:
matrix:
include:
- os: ubuntu-24.04
arch: arm64
runner: ubicloud-standard-4-arm
rust_target: aarch64-unknown-linux-gnu
tauri_args: "--target aarch64-unknown-linux-gnu --bundles appimage,updater --verbose"
- os: ubuntu-24.04
arch: amd64
rust_target: x86_64-unknown-linux-gnu
tauri_args: "--target x86_64-unknown-linux-gnu --bundles appimage,updater --verbose"
- os: macos-latest
arch: universal
rust_target: universal-apple-darwin
tauri_args: "--target universal-apple-darwin --bundles dmg,updater --verbose"
- os: windows-latest
arch: x86
rust_target: i686-pc-windows-msvc
tauri_args: "--target i686-pc-windows-msvc --bundles nsis,updater --verbose"
msvc_arch: x86
- os: windows-latest
arch: x86_64
rust_target: x86_64-pc-windows-msvc
tauri_args: "--target x86_64-pc-windows-msvc --bundles nsis,updater --verbose"
msvc_arch: x64
- os: windows-latest
arch: arm64
rust_target: aarch64-pc-windows-msvc
tauri_args: "--target aarch64-pc-windows-msvc --bundles nsis,updater --verbose"
runs-on: ${{ matrix.runner || matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust
uses: swatinem/rust-cache@v2
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: |
- recursive: true
args: [--frozen-lockfile]
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "pnpm"
- name: Cache pnpm modules
uses: actions/cache@v4
with:
path: |
$(pnpm store path --silent)
**/node_modules
key: ${{ runner.OS }}-pnpm-${{ matrix.arch }}-${{ hashFiles('**/pnpm-lock.yaml', '**/package.json') }}
restore-keys: |
${{ runner.OS }}-pnpm-${{ matrix.arch }}-
- name: Set up Visual Studio shell
if: matrix.os == 'windows-latest' && matrix.arch == 'arm64'
uses: TheMrMilchmann/setup-msvc-dev@v3
with:
arch: amd64_arm64
- name: Setup platform-specific dependencies
if: matrix.os == 'ubuntu-24.04'
run: |
if [ "${{ matrix.arch }}" == "arm64" ]; then
echo "deb http://ports.ubuntu.com/ubuntu-ports jammy main restricted universe multiverse" | sudo tee /etc/apt/sources.list.d/ubuntu-ports-jammy-main.list
else
echo "deb http://gb.archive.ubuntu.com/ubuntu jammy main" | sudo tee /etc/apt/sources.list.d/ubuntu-jammy-main.list
fi
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libayatana-appindicator3-dev librsvg2-dev libssl-dev
- name: Reconfigure Rust targets
run: |
if [ "${{ matrix.os }}" == "macos-latest" ]; then
rustup target add aarch64-apple-darwin x86_64-apple-darwin
else
rustup target add ${{ matrix.rust_target }}
fi
shell: bash
- name: Build kftray-tauri Desktop App
uses: tauri-apps/tauri-action@v0
id: tauri_build
continue-on-error: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_OPTIONS: --max-old-space-size=6000
ENABLE_CODE_SIGNING: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
with:
tagName: ${{ github.ref_name }}
releaseName: "KFtray - ${{ github.ref_name }}"
releaseBody: "See the assets to download this version and install."
releaseDraft: true
prerelease: false
updaterJsonKeepUniversal: true
args: ${{ matrix.tauri_args }}
- name: Retry Build on Failure
if: steps.tauri_build.outcome == 'failure'
uses: tauri-apps/tauri-action@v0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_OPTIONS: --max-old-space-size=6000
ENABLE_CODE_SIGNING: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
APPLE_SIGNING_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
APPLE_TEAM_ID: ${{ secrets.APPLE_TEAM_ID }}
APPLE_ID: ${{ secrets.APPLE_ID }}
APPLE_PASSWORD: ${{ secrets.APPLE_PASSWORD }}
with:
tagName: ${{ github.ref_name }}
releaseName: "KFtray - ${{ github.ref_name }}"
releaseBody: "See the assets to download this version and install."
releaseDraft: true
prerelease: false
updaterJsonKeepUniversal: true
args: ${{ matrix.tauri_args }}
kftui:
needs: create-release-draft
permissions:
contents: write
strategy:
matrix:
include:
- os: ubuntu-24.04
arch: arm64
runner: ubicloud-standard-4-arm
rust_target: aarch64-unknown-linux-gnu
os_name: linux
- os: ubuntu-24.04
arch: amd64
rust_target: x86_64-unknown-linux-gnu
os_name: linux
- os: macos-latest
arch: universal
rust_target: universal-apple-darwin
os_name: macos
- os: windows-latest
arch: x86
rust_target: i686-pc-windows-msvc
msvc_arch: x86
os_name: windows
- os: windows-latest
arch: x86_64
rust_target: x86_64-pc-windows-msvc
msvc_arch: x64
os_name: windows
runs-on: ${{ matrix.runner || matrix.os }}
outputs:
os: ${{ matrix.os }}
arch: ${{ matrix.arch }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust
uses: swatinem/rust-cache@v2
- name: Install pnpm
uses: pnpm/action-setup@v4
with:
version: 9
run_install: |
- recursive: true
args: [--frozen-lockfile]
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: "22"
cache: "pnpm"
- name: Cache pnpm modules
uses: actions/cache@v4
with:
path: |
$(pnpm store path --silent)
**/node_modules
key: ${{ runner.OS }}-pnpm-${{ runner.ARCH }}-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.OS }}-pnpm-${{ runner.ARCH }}-
- name: Setup platform-specific dependencies
if: matrix.os == 'ubuntu-24.04'
run: |
if [ "${{ matrix.arch }}" == "arm64" ]; then
echo "deb http://ports.ubuntu.com/ubuntu-ports jammy main restricted universe multiverse" | sudo tee /etc/apt/sources.list.d/ubuntu-ports-jammy-main.list
else
echo "deb http://gb.archive.ubuntu.com/ubuntu jammy main" | sudo tee /etc/apt/sources.list.d/ubuntu-jammy-main.list
fi
sudo apt-get update
sudo apt-get install -y libgtk-3-dev libwebkit2gtk-4.0-dev libayatana-appindicator3-dev librsvg2-dev libssl-dev
- name: Reconfigure Rust targets
run: |
if [ "${{ matrix.os }}" == "macos-latest" ]; then
rustup target add aarch64-apple-darwin x86_64-apple-darwin
else
rustup target add ${{ matrix.rust_target }}
fi
shell: bash
- name: Install OpenSSL on Windows
if: matrix.os == 'windows-latest'
run: choco install openssl
- name: Set up Perl on Windows
if: matrix.os == 'windows-latest'
uses: shogo82148/actions-setup-perl@v1
with:
perl-version: "5.32"
distribution: "strawberry"
- name: Set Perl environment variables
if: matrix.os == 'windows-latest'
run: |
echo "PERL=$((where.exe perl)[0])" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
echo "OPENSSL_SRC_PERL=$((where.exe perl)[0])" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
- name: Build kftui
run: |
if [ "${{ matrix.os }}" == "macos-latest" ]; then
cargo build --release --bin kftui --target aarch64-apple-darwin
cargo build --release --bin kftui --target x86_64-apple-darwin
lipo -create -output ./target/release/kftui ./target/x86_64-apple-darwin/release/kftui ./target/aarch64-apple-darwin/release/kftui
else
cargo build --release --bin kftui --target ${{ matrix.rust_target }}
fi
shell: bash
- name: Sign and notarize the release build
if: matrix.os == 'macos-latest'
uses: toitlang/action-macos-sign-notarize@v1.2.0
with:
certificate: ${{ secrets.APPLE_CERTIFICATE }}
certificate-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
username: ${{ secrets.APPLE_ID }}
password: ${{ secrets.APPLE_PASSWORD }}
apple-team-id: 6M376JWU73
app-path: target/release/kftui
entitlements-path: crates/kftui/entitlements.plist
- name: Rename and upload release asset
run: |
if [ "${{ matrix.os }}" == "macos-latest" ]; then
mv ./target/release/kftui ./target/release/kftui_macos_universal
gh release upload ${{ github.ref_name }} ./target/release/kftui_macos_universal --clobber
elif [ "${{ matrix.os }}" == "windows-latest" ]; then
mv ./target/${{ matrix.rust_target }}/release/kftui.exe ./target/release/kftui_${{ matrix.os_name }}_${{ matrix.arch }}.exe
chmod +x ./target/release/kftui_${{ matrix.os_name }}_${{ matrix.arch }}.exe
gh release upload ${{ github.ref_name }} ./target/release/kftui_${{ matrix.os_name }}_${{ matrix.arch }}.exe
else
mv ./target/${{ matrix.rust_target }}/release/kftui ./target/release/kftui_${{ matrix.os_name }}_${{ matrix.arch }}
chmod +x ./target/release/kftui_${{ matrix.os_name }}_${{ matrix.arch }}
gh release upload ${{ github.ref_name }} ./target/release/kftui_${{ matrix.os_name }}_${{ matrix.arch }}
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ github.token }}
GH_REPO: ${{ github.repository }}
shell: bash
kftray-server:
permissions:
contents: write
packages: write
runs-on: ubuntu-24.04
if: ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v') }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64
context: ./crates/kftray-server
file: ./crates/kftray-server/Dockerfile
push: true
tags: |
ghcr.io/${{ github.repository_owner }}/kftray-server:${{ github.sha }}
ghcr.io/${{ github.repository_owner }}/kftray-server:${{ github.ref_name }}
ghcr.io/${{ github.repository_owner }}/kftray-server:latest
update-release:
needs: [kftray-tauri, kftui, kftray-server, create-release-draft]
permissions:
contents: write
runs-on: ubuntu-24.04
if: |
startsWith(github.ref, 'refs/tags/v') &&
!contains(github.ref, '-beta') &&
!contains(github.ref, '-alpha')
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Generate changelog
uses: orhun/git-cliff-action@v4
id: git-cliff
with:
config: cliff.toml
args: --latest --strip header
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Update release notes
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
try {
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: ${{ needs.create-release-draft.outputs.release_id }},
body: `${{ steps.git-cliff.outputs.content }}`,
tag_name: process.env.GITHUB_REF_NAME,
name: `KFtray - ${process.env.GITHUB_REF_NAME}`
});
} catch (error) {
console.error('Failed to update release notes:', error);
if (error.status === 404) {
console.log('Release not found, retrying after short delay...');
await new Promise(resolve => setTimeout(resolve, 5000));
await github.rest.repos.updateRelease({
owner: context.repo.owner,
repo: context.repo.repo,
release_id: ${{ needs.create-release-draft.outputs.release_id }},
body: `${{ steps.git-cliff.outputs.content }}`,
tag_name: process.env.GITHUB_REF_NAME,
name: `KFtray - ${process.env.GITHUB_REF_NAME}`
});
} else {
throw error;
}
}
- name: Publish release
uses: eregon/publish-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
release_id: ${{ needs.create-release-draft.outputs.release_id }}
update-homebrew:
needs: [update-release]
permissions:
contents: write
runs-on: macos-latest
if: |
startsWith(github.ref, 'refs/tags/v') &&
!contains(github.ref, '-beta') &&
!contains(github.ref, '-alpha')
steps:
- name: Checkout main repository
uses: actions/checkout@v4
- name: Update Homebrew formulas
env:
GH_TOKEN: ${{ secrets.GH_PAT }}
run: |
chmod +x ./hacks/update-homebrew.sh
./hacks/update-homebrew.sh \
"${{ github.repository }}" \
"${{ github.ref_name }}" \
"hcavarsan/homebrew-kftray" \
"${{ secrets.GH_PAT }}"