Skip to content

Commit 5cf235f

Browse files
authored
desktop: add electron version (#15663)
1 parent e4f0825 commit 5cf235f

File tree

223 files changed

+4292
-46
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

223 files changed

+4292
-46
lines changed

.github/workflows/publish.yml

Lines changed: 126 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ jobs:
9999
with:
100100
name: opencode-cli
101101
path: packages/opencode/dist
102-
103102
outputs:
104103
version: ${{ needs.version.outputs.version }}
105104

@@ -240,11 +239,130 @@ jobs:
240239
APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
241240
APPLE_API_KEY_PATH: ${{ runner.temp }}/apple-api-key.p8
242241

242+
build-electron:
243+
needs:
244+
- build-cli
245+
- version
246+
continue-on-error: false
247+
strategy:
248+
fail-fast: false
249+
matrix:
250+
settings:
251+
- host: macos-latest
252+
target: x86_64-apple-darwin
253+
platform_flag: --mac --x64
254+
- host: macos-latest
255+
target: aarch64-apple-darwin
256+
platform_flag: --mac --arm64
257+
- host: "blacksmith-4vcpu-windows-2025"
258+
target: x86_64-pc-windows-msvc
259+
platform_flag: --win
260+
- host: "blacksmith-4vcpu-ubuntu-2404"
261+
target: x86_64-unknown-linux-gnu
262+
platform_flag: --linux
263+
- host: "blacksmith-4vcpu-ubuntu-2404"
264+
target: aarch64-unknown-linux-gnu
265+
platform_flag: --linux
266+
runs-on: ${{ matrix.settings.host }}
267+
steps:
268+
- uses: actions/checkout@v3
269+
270+
- uses: apple-actions/import-codesign-certs@v2
271+
if: runner.os == 'macOS'
272+
with:
273+
keychain: build
274+
p12-file-base64: ${{ secrets.APPLE_CERTIFICATE }}
275+
p12-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
276+
277+
- name: Setup Apple API Key
278+
if: runner.os == 'macOS'
279+
run: echo "${{ secrets.APPLE_API_KEY_PATH }}" > $RUNNER_TEMP/apple-api-key.p8
280+
281+
- uses: ./.github/actions/setup-bun
282+
283+
- uses: actions/setup-node@v4
284+
with:
285+
node-version: "24"
286+
287+
- name: Cache apt packages
288+
if: contains(matrix.settings.host, 'ubuntu')
289+
uses: actions/cache@v4
290+
with:
291+
path: ~/apt-cache
292+
key: ${{ runner.os }}-${{ matrix.settings.target }}-apt-electron-${{ hashFiles('.github/workflows/publish.yml') }}
293+
restore-keys: |
294+
${{ runner.os }}-${{ matrix.settings.target }}-apt-electron-
295+
296+
- name: Install dependencies (ubuntu only)
297+
if: contains(matrix.settings.host, 'ubuntu')
298+
run: |
299+
mkdir -p ~/apt-cache && chmod -R a+rw ~/apt-cache
300+
sudo apt-get update
301+
sudo apt-get install -y --no-install-recommends -o dir::cache::archives="$HOME/apt-cache" rpm
302+
sudo chmod -R a+rw ~/apt-cache
303+
304+
- name: Setup git committer
305+
id: committer
306+
uses: ./.github/actions/setup-git-committer
307+
with:
308+
opencode-app-id: ${{ vars.OPENCODE_APP_ID }}
309+
opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
310+
311+
- name: Prepare
312+
run: bun ./scripts/prepare.ts
313+
working-directory: packages/desktop-electron
314+
env:
315+
OPENCODE_VERSION: ${{ needs.version.outputs.version }}
316+
OPENCODE_CHANNEL: ${{ (github.ref_name == 'beta' && 'beta') || 'prod' }}
317+
RUST_TARGET: ${{ matrix.settings.target }}
318+
GH_TOKEN: ${{ github.token }}
319+
GITHUB_RUN_ID: ${{ github.run_id }}
320+
321+
- name: Build
322+
run: bun run build
323+
working-directory: packages/desktop-electron
324+
env:
325+
OPENCODE_CHANNEL: ${{ (github.ref_name == 'beta' && 'beta') || 'prod' }}
326+
327+
- name: Package and publish
328+
if: needs.version.outputs.release
329+
run: npx electron-builder ${{ matrix.settings.platform_flag }} --publish always --config electron-builder.config.ts
330+
working-directory: packages/desktop-electron
331+
timeout-minutes: 60
332+
env:
333+
OPENCODE_CHANNEL: ${{ (github.ref_name == 'beta' && 'beta') || 'prod' }}
334+
GH_TOKEN: ${{ steps.committer.outputs.token }}
335+
CSC_LINK: ${{ secrets.APPLE_CERTIFICATE }}
336+
CSC_KEY_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
337+
APPLE_API_KEY: ${{ runner.temp }}/apple-api-key.p8
338+
APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY }}
339+
APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
340+
341+
- name: Package (no publish)
342+
if: ${{ !needs.version.outputs.release }}
343+
run: npx electron-builder ${{ matrix.settings.platform_flag }} --publish never --config electron-builder.config.ts
344+
working-directory: packages/desktop-electron
345+
timeout-minutes: 60
346+
env:
347+
OPENCODE_CHANNEL: ${{ (github.ref_name == 'beta' && 'beta') || 'prod' }}
348+
349+
- uses: actions/upload-artifact@v4
350+
with:
351+
name: opencode-electron-${{ matrix.settings.target }}
352+
path: packages/desktop-electron/dist/*
353+
354+
- uses: actions/upload-artifact@v4
355+
if: needs.version.outputs.release
356+
with:
357+
name: latest-yml-${{ matrix.settings.target }}
358+
path: packages/desktop-electron/dist/latest*.yml
359+
243360
publish:
244361
needs:
245362
- version
246363
- build-cli
247364
- build-tauri
365+
- build-electron
248366
runs-on: blacksmith-4vcpu-ubuntu-2404
249367
steps:
250368
- uses: actions/checkout@v3
@@ -281,6 +399,12 @@ jobs:
281399
name: opencode-cli
282400
path: packages/opencode/dist
283401

402+
- uses: actions/download-artifact@v4
403+
if: needs.version.outputs.release
404+
with:
405+
pattern: latest-yml-*
406+
path: /tmp/latest-yml
407+
284408
- name: Cache apt packages (AUR)
285409
uses: actions/cache@v4
286410
with:
@@ -308,3 +432,4 @@ jobs:
308432
GITHUB_TOKEN: ${{ steps.committer.outputs.token }}
309433
GH_REPO: ${{ needs.version.outputs.repo }}
310434
NPM_CONFIG_PROVENANCE: false
435+
LATEST_YML_DIR: /tmp/latest-yml

0 commit comments

Comments
 (0)