Skip to content

Commit 7ce0463

Browse files
committed
ci: add zexi electron build workflow
1 parent b2a06fb commit 7ce0463

1 file changed

Lines changed: 127 additions & 0 deletions

File tree

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: zexi-electron
2+
3+
on:
4+
push:
5+
branches:
6+
- zexi/dev
7+
workflow_dispatch:
8+
inputs:
9+
ref:
10+
description: "Git ref to build"
11+
required: false
12+
type: string
13+
channel:
14+
description: "Desktop channel"
15+
required: false
16+
default: prod
17+
type: choice
18+
options:
19+
- prod
20+
- beta
21+
- dev
22+
23+
concurrency: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.ref || 'head' }}
24+
25+
permissions:
26+
contents: read
27+
28+
jobs:
29+
build-electron:
30+
strategy:
31+
fail-fast: false
32+
matrix:
33+
settings:
34+
- name: mac-arm64
35+
host: macos-26
36+
target: aarch64-apple-darwin
37+
platform_flag: --mac --arm64
38+
bun_install_flags: --os=darwin --cpu=arm64
39+
- name: windows-x64
40+
host: windows-2025
41+
target: x86_64-pc-windows-msvc
42+
platform_flag: --win
43+
bun_install_flags: ""
44+
runs-on: ${{ matrix.settings.host }}
45+
env:
46+
OPENCODE_CHANNEL: ${{ inputs.channel || 'prod' }}
47+
AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
48+
AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
49+
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
50+
AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
51+
AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE }}
52+
AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
53+
steps:
54+
- uses: actions/checkout@v4
55+
with:
56+
ref: ${{ inputs.ref || github.ref }}
57+
58+
- uses: apple-actions/import-codesign-certs@v2
59+
if: runner.os == 'macOS' && secrets.APPLE_CERTIFICATE != '' && secrets.APPLE_CERTIFICATE_PASSWORD != ''
60+
with:
61+
keychain: build
62+
p12-file-base64: ${{ secrets.APPLE_CERTIFICATE }}
63+
p12-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
64+
65+
- name: Setup Apple API Key
66+
if: runner.os == 'macOS' && secrets.APPLE_API_KEY_PATH != ''
67+
shell: bash
68+
run: echo "${{ secrets.APPLE_API_KEY_PATH }}" > "$RUNNER_TEMP/apple-api-key.p8"
69+
70+
- uses: ./.github/actions/setup-bun
71+
with:
72+
install-flags: ${{ matrix.settings.bun_install_flags }}
73+
74+
- uses: actions/setup-node@v4
75+
with:
76+
node-version: "24"
77+
78+
- name: Azure login
79+
if: runner.os == 'Windows' && env.AZURE_CLIENT_ID != '' && env.AZURE_TENANT_ID != '' && env.AZURE_SUBSCRIPTION_ID != ''
80+
uses: azure/login@v2
81+
with:
82+
client-id: ${{ env.AZURE_CLIENT_ID }}
83+
tenant-id: ${{ env.AZURE_TENANT_ID }}
84+
subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }}
85+
86+
- name: Prepare
87+
working-directory: packages/desktop-electron
88+
env:
89+
RUST_TARGET: ${{ matrix.settings.target }}
90+
run: bun ./scripts/prepare.ts
91+
92+
- name: Build
93+
working-directory: packages/desktop-electron
94+
run: bun run build
95+
96+
- name: Package
97+
working-directory: packages/desktop-electron
98+
timeout-minutes: 90
99+
env:
100+
CSC_LINK: ${{ secrets.APPLE_CERTIFICATE }}
101+
CSC_KEY_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
102+
APPLE_API_KEY: ${{ runner.temp }}/apple-api-key.p8
103+
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY }}
104+
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
105+
run: npx electron-builder ${{ matrix.settings.platform_flag }} --publish never --config electron-builder.config.ts
106+
107+
- name: Verify signed Windows artifacts
108+
if: runner.os == 'Windows'
109+
shell: pwsh
110+
run: |
111+
$files = @()
112+
$files += Get-ChildItem "${{ github.workspace }}\packages\desktop-electron\dist\*.exe" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName
113+
$files += Get-ChildItem "${{ github.workspace }}\packages\desktop-electron\dist\*unpacked\*.exe" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName
114+
$files += Get-ChildItem "${{ github.workspace }}\packages\desktop-electron\dist\*unpacked\resources\opencode-cli.exe" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName
115+
116+
foreach ($file in $files | Select-Object -Unique) {
117+
$sig = Get-AuthenticodeSignature $file
118+
Write-Host "$file => $($sig.Status)"
119+
}
120+
121+
- uses: actions/upload-artifact@v4
122+
with:
123+
name: opencode-electron-${{ matrix.settings.name }}
124+
path: |
125+
packages/desktop-electron/dist/*
126+
!packages/desktop-electron/dist/*unpacked
127+
!packages/desktop-electron/dist/mac-arm64

0 commit comments

Comments
 (0)