publish.yml 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630
  1. name: publish
  2. run-name: "${{ format('release {0}', inputs.bump) }}"
  3. on:
  4. push:
  5. branches:
  6. - ci
  7. - dev
  8. - beta
  9. - snapshot-*
  10. workflow_dispatch:
  11. inputs:
  12. bump:
  13. description: "Bump major, minor, or patch"
  14. required: false
  15. type: choice
  16. options:
  17. - major
  18. - minor
  19. - patch
  20. version:
  21. description: "Override version (optional)"
  22. required: false
  23. type: string
  24. concurrency: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.version || inputs.bump }}
  25. permissions:
  26. id-token: write
  27. contents: write
  28. packages: write
  29. jobs:
  30. version:
  31. runs-on: blacksmith-4vcpu-ubuntu-2404
  32. if: github.repository == 'anomalyco/opencode'
  33. steps:
  34. - uses: actions/checkout@v3
  35. with:
  36. fetch-depth: 0
  37. - uses: ./.github/actions/setup-bun
  38. - name: Setup git committer
  39. id: committer
  40. uses: ./.github/actions/setup-git-committer
  41. with:
  42. opencode-app-id: ${{ vars.OPENCODE_APP_ID }}
  43. opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
  44. - name: Install OpenCode
  45. if: inputs.bump || inputs.version
  46. run: bun i -g opencode-ai
  47. - id: version
  48. run: |
  49. ./script/version.ts
  50. env:
  51. GH_TOKEN: ${{ steps.committer.outputs.token }}
  52. OPENCODE_BUMP: ${{ inputs.bump }}
  53. OPENCODE_VERSION: ${{ inputs.version }}
  54. OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
  55. GH_REPO: ${{ (github.ref_name == 'beta' && 'anomalyco/opencode-beta') || github.repository }}
  56. outputs:
  57. version: ${{ steps.version.outputs.version }}
  58. release: ${{ steps.version.outputs.release }}
  59. tag: ${{ steps.version.outputs.tag }}
  60. repo: ${{ steps.version.outputs.repo }}
  61. build-cli:
  62. needs: version
  63. runs-on: blacksmith-4vcpu-ubuntu-2404
  64. if: github.repository == 'anomalyco/opencode'
  65. steps:
  66. - uses: actions/checkout@v3
  67. with:
  68. fetch-tags: true
  69. - uses: ./.github/actions/setup-bun
  70. - name: Setup git committer
  71. id: committer
  72. uses: ./.github/actions/setup-git-committer
  73. with:
  74. opencode-app-id: ${{ vars.OPENCODE_APP_ID }}
  75. opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
  76. - name: Build
  77. id: build
  78. run: |
  79. ./packages/opencode/script/build.ts
  80. env:
  81. OPENCODE_VERSION: ${{ needs.version.outputs.version }}
  82. OPENCODE_RELEASE: ${{ needs.version.outputs.release }}
  83. GH_REPO: ${{ needs.version.outputs.repo }}
  84. GH_TOKEN: ${{ steps.committer.outputs.token }}
  85. - uses: actions/upload-artifact@v4
  86. with:
  87. name: opencode-cli
  88. path: |
  89. packages/opencode/dist/opencode-darwin*
  90. packages/opencode/dist/opencode-linux*
  91. - uses: actions/upload-artifact@v4
  92. with:
  93. name: opencode-cli-windows
  94. path: packages/opencode/dist/opencode-windows*
  95. outputs:
  96. version: ${{ needs.version.outputs.version }}
  97. sign-cli-windows:
  98. needs:
  99. - build-cli
  100. - version
  101. runs-on: blacksmith-4vcpu-windows-2025
  102. if: github.repository == 'anomalyco/opencode'
  103. env:
  104. AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
  105. AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
  106. AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
  107. AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
  108. AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE }}
  109. AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
  110. steps:
  111. - uses: actions/checkout@v3
  112. - uses: actions/download-artifact@v4
  113. with:
  114. name: opencode-cli-windows
  115. path: packages/opencode/dist
  116. - name: Setup git committer
  117. id: committer
  118. uses: ./.github/actions/setup-git-committer
  119. with:
  120. opencode-app-id: ${{ vars.OPENCODE_APP_ID }}
  121. opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
  122. - name: Azure login
  123. uses: azure/login@v2
  124. with:
  125. client-id: ${{ env.AZURE_CLIENT_ID }}
  126. tenant-id: ${{ env.AZURE_TENANT_ID }}
  127. subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }}
  128. - uses: azure/artifact-signing-action@v1
  129. with:
  130. endpoint: ${{ env.AZURE_TRUSTED_SIGNING_ENDPOINT }}
  131. signing-account-name: ${{ env.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
  132. certificate-profile-name: ${{ env.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE }}
  133. files: |
  134. ${{ github.workspace }}\packages\opencode\dist\opencode-windows-arm64\bin\opencode.exe
  135. ${{ github.workspace }}\packages\opencode\dist\opencode-windows-x64\bin\opencode.exe
  136. ${{ github.workspace }}\packages\opencode\dist\opencode-windows-x64-baseline\bin\opencode.exe
  137. exclude-environment-credential: true
  138. exclude-workload-identity-credential: true
  139. exclude-managed-identity-credential: true
  140. exclude-shared-token-cache-credential: true
  141. exclude-visual-studio-credential: true
  142. exclude-visual-studio-code-credential: true
  143. exclude-azure-cli-credential: false
  144. exclude-azure-powershell-credential: true
  145. exclude-azure-developer-cli-credential: true
  146. exclude-interactive-browser-credential: true
  147. - name: Verify Windows CLI signatures
  148. shell: pwsh
  149. run: |
  150. $files = @(
  151. "${{ github.workspace }}\packages\opencode\dist\opencode-windows-arm64\bin\opencode.exe",
  152. "${{ github.workspace }}\packages\opencode\dist\opencode-windows-x64\bin\opencode.exe",
  153. "${{ github.workspace }}\packages\opencode\dist\opencode-windows-x64-baseline\bin\opencode.exe"
  154. )
  155. foreach ($file in $files) {
  156. $sig = Get-AuthenticodeSignature $file
  157. if ($sig.Status -ne "Valid") {
  158. throw "Invalid signature for ${file}: $($sig.Status)"
  159. }
  160. }
  161. - name: Repack Windows CLI archives
  162. working-directory: packages/opencode/dist
  163. shell: pwsh
  164. run: |
  165. Compress-Archive -Path "opencode-windows-arm64\bin\*" -DestinationPath "opencode-windows-arm64.zip" -Force
  166. Compress-Archive -Path "opencode-windows-x64\bin\*" -DestinationPath "opencode-windows-x64.zip" -Force
  167. Compress-Archive -Path "opencode-windows-x64-baseline\bin\*" -DestinationPath "opencode-windows-x64-baseline.zip" -Force
  168. - name: Upload signed Windows CLI release assets
  169. if: needs.version.outputs.release != ''
  170. shell: pwsh
  171. env:
  172. GH_TOKEN: ${{ steps.committer.outputs.token }}
  173. run: |
  174. gh release upload "v${{ needs.version.outputs.version }}" `
  175. "${{ github.workspace }}\packages\opencode\dist\opencode-windows-arm64.zip" `
  176. "${{ github.workspace }}\packages\opencode\dist\opencode-windows-x64.zip" `
  177. "${{ github.workspace }}\packages\opencode\dist\opencode-windows-x64-baseline.zip" `
  178. --clobber `
  179. --repo "${{ needs.version.outputs.repo }}"
  180. - uses: actions/upload-artifact@v4
  181. with:
  182. name: opencode-cli-signed-windows
  183. path: |
  184. packages/opencode/dist/opencode-windows-arm64
  185. packages/opencode/dist/opencode-windows-x64
  186. packages/opencode/dist/opencode-windows-x64-baseline
  187. build-tauri:
  188. needs:
  189. - build-cli
  190. - version
  191. continue-on-error: false
  192. env:
  193. AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
  194. AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
  195. AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
  196. AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
  197. AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE }}
  198. AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
  199. strategy:
  200. fail-fast: false
  201. matrix:
  202. settings:
  203. - host: macos-latest
  204. target: x86_64-apple-darwin
  205. - host: macos-latest
  206. target: aarch64-apple-darwin
  207. # github-hosted: blacksmith lacks ARM64 MSVC cross-compilation toolchain
  208. - host: windows-2025
  209. target: aarch64-pc-windows-msvc
  210. - host: blacksmith-4vcpu-windows-2025
  211. target: x86_64-pc-windows-msvc
  212. - host: blacksmith-4vcpu-ubuntu-2404
  213. target: x86_64-unknown-linux-gnu
  214. - host: blacksmith-8vcpu-ubuntu-2404-arm
  215. target: aarch64-unknown-linux-gnu
  216. runs-on: ${{ matrix.settings.host }}
  217. steps:
  218. - uses: actions/checkout@v3
  219. with:
  220. fetch-tags: true
  221. - uses: apple-actions/import-codesign-certs@v2
  222. if: ${{ runner.os == 'macOS' }}
  223. with:
  224. keychain: build
  225. p12-file-base64: ${{ secrets.APPLE_CERTIFICATE }}
  226. p12-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
  227. - name: Verify Certificate
  228. if: ${{ runner.os == 'macOS' }}
  229. run: |
  230. CERT_INFO=$(security find-identity -v -p codesigning build.keychain | grep "Developer ID Application")
  231. CERT_ID=$(echo "$CERT_INFO" | awk -F'"' '{print $2}')
  232. echo "CERT_ID=$CERT_ID" >> $GITHUB_ENV
  233. echo "Certificate imported."
  234. - name: Setup Apple API Key
  235. if: ${{ runner.os == 'macOS' }}
  236. run: |
  237. echo "${{ secrets.APPLE_API_KEY_PATH }}" > $RUNNER_TEMP/apple-api-key.p8
  238. - uses: ./.github/actions/setup-bun
  239. - name: Azure login
  240. if: runner.os == 'Windows'
  241. uses: azure/login@v2
  242. with:
  243. client-id: ${{ env.AZURE_CLIENT_ID }}
  244. tenant-id: ${{ env.AZURE_TENANT_ID }}
  245. subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }}
  246. - uses: actions/setup-node@v4
  247. with:
  248. node-version: "24"
  249. - name: Cache apt packages
  250. if: contains(matrix.settings.host, 'ubuntu')
  251. uses: actions/cache@v4
  252. with:
  253. path: ~/apt-cache
  254. key: ${{ runner.os }}-${{ matrix.settings.target }}-apt-${{ hashFiles('.github/workflows/publish.yml') }}
  255. restore-keys: |
  256. ${{ runner.os }}-${{ matrix.settings.target }}-apt-
  257. - name: install dependencies (ubuntu only)
  258. if: contains(matrix.settings.host, 'ubuntu')
  259. run: |
  260. mkdir -p ~/apt-cache && chmod -R a+rw ~/apt-cache
  261. sudo apt-get update
  262. sudo apt-get install -y --no-install-recommends -o dir::cache::archives="$HOME/apt-cache" libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
  263. sudo chmod -R a+rw ~/apt-cache
  264. - name: install Rust stable
  265. uses: dtolnay/rust-toolchain@stable
  266. with:
  267. targets: ${{ matrix.settings.target }}
  268. - uses: Swatinem/rust-cache@v2
  269. with:
  270. workspaces: packages/desktop/src-tauri
  271. shared-key: ${{ matrix.settings.target }}
  272. - name: Prepare
  273. run: |
  274. cd packages/desktop
  275. bun ./scripts/prepare.ts
  276. env:
  277. OPENCODE_VERSION: ${{ needs.version.outputs.version }}
  278. GITHUB_TOKEN: ${{ steps.committer.outputs.token }}
  279. OPENCODE_CLI_ARTIFACT: ${{ (runner.os == 'Windows' && 'opencode-cli-windows') || 'opencode-cli' }}
  280. RUST_TARGET: ${{ matrix.settings.target }}
  281. GH_TOKEN: ${{ github.token }}
  282. GITHUB_RUN_ID: ${{ github.run_id }}
  283. - name: Resolve tauri portable SHA
  284. if: contains(matrix.settings.host, 'ubuntu')
  285. run: echo "TAURI_PORTABLE_SHA=$(git ls-remote https://github.com/tauri-apps/tauri.git refs/heads/feat/truly-portable-appimage | cut -f1)" >> "$GITHUB_ENV"
  286. # Fixes AppImage build issues, can be removed when https://github.com/tauri-apps/tauri/pull/12491 is released
  287. - name: Install tauri-cli from portable appimage branch
  288. uses: taiki-e/cache-cargo-install-action@v3
  289. if: contains(matrix.settings.host, 'ubuntu')
  290. with:
  291. tool: tauri-cli
  292. git: https://github.com/tauri-apps/tauri
  293. # branch: feat/truly-portable-appimage
  294. rev: ${{ env.TAURI_PORTABLE_SHA }}
  295. - name: Show tauri-cli version
  296. if: contains(matrix.settings.host, 'ubuntu')
  297. run: cargo tauri --version
  298. - name: Setup git committer
  299. id: committer
  300. uses: ./.github/actions/setup-git-committer
  301. with:
  302. opencode-app-id: ${{ vars.OPENCODE_APP_ID }}
  303. opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
  304. - name: Build and upload artifacts
  305. uses: tauri-apps/tauri-action@390cbe447412ced1303d35abe75287949e43437a
  306. timeout-minutes: 60
  307. with:
  308. projectPath: packages/desktop
  309. uploadWorkflowArtifacts: true
  310. tauriScript: ${{ (contains(matrix.settings.host, 'ubuntu') && 'cargo tauri') || '' }}
  311. args: --target ${{ matrix.settings.target }} --config ${{ (github.ref_name == 'beta' && './src-tauri/tauri.beta.conf.json') || './src-tauri/tauri.prod.conf.json' }} --verbose
  312. updaterJsonPreferNsis: true
  313. releaseId: ${{ needs.version.outputs.release }}
  314. tagName: ${{ needs.version.outputs.tag }}
  315. releaseDraft: true
  316. releaseAssetNamePattern: opencode-desktop-[platform]-[arch][ext]
  317. repo: ${{ (github.ref_name == 'beta' && 'opencode-beta') || '' }}
  318. releaseCommitish: ${{ github.sha }}
  319. env:
  320. GITHUB_TOKEN: ${{ steps.committer.outputs.token }}
  321. TAURI_BUNDLER_NEW_APPIMAGE_FORMAT: true
  322. TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
  323. TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
  324. APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
  325. APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
  326. APPLE_SIGNING_IDENTITY: ${{ env.CERT_ID }}
  327. APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
  328. APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
  329. APPLE_API_KEY_PATH: ${{ runner.temp }}/apple-api-key.p8
  330. - name: Verify signed Windows desktop artifacts
  331. if: runner.os == 'Windows'
  332. shell: pwsh
  333. run: |
  334. $files = @(
  335. "${{ github.workspace }}\packages\desktop\src-tauri\sidecars\opencode-cli-${{ matrix.settings.target }}.exe"
  336. )
  337. $files += Get-ChildItem "${{ github.workspace }}\packages\desktop\src-tauri\target\${{ matrix.settings.target }}\release\bundle\nsis\*.exe" | Select-Object -ExpandProperty FullName
  338. foreach ($file in $files) {
  339. $sig = Get-AuthenticodeSignature $file
  340. if ($sig.Status -ne "Valid") {
  341. throw "Invalid signature for ${file}: $($sig.Status)"
  342. }
  343. }
  344. build-electron:
  345. needs:
  346. - build-cli
  347. - version
  348. if: github.repository == 'anomalyco/opencode'
  349. continue-on-error: false
  350. env:
  351. AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
  352. AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
  353. AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
  354. AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
  355. AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE }}
  356. AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
  357. strategy:
  358. fail-fast: false
  359. matrix:
  360. settings:
  361. - host: macos-latest
  362. target: x86_64-apple-darwin
  363. platform_flag: --mac --x64
  364. - host: macos-latest
  365. target: aarch64-apple-darwin
  366. platform_flag: --mac --arm64
  367. # github-hosted: blacksmith lacks ARM64 MSVC cross-compilation toolchain
  368. - host: "windows-2025"
  369. target: aarch64-pc-windows-msvc
  370. platform_flag: --win --arm64
  371. - host: "blacksmith-4vcpu-windows-2025"
  372. target: x86_64-pc-windows-msvc
  373. platform_flag: --win
  374. - host: "blacksmith-4vcpu-ubuntu-2404"
  375. target: x86_64-unknown-linux-gnu
  376. platform_flag: --linux
  377. - host: "blacksmith-4vcpu-ubuntu-2404"
  378. target: aarch64-unknown-linux-gnu
  379. platform_flag: --linux
  380. runs-on: ${{ matrix.settings.host }}
  381. steps:
  382. - uses: actions/checkout@v3
  383. - uses: apple-actions/import-codesign-certs@v2
  384. if: runner.os == 'macOS'
  385. with:
  386. keychain: build
  387. p12-file-base64: ${{ secrets.APPLE_CERTIFICATE }}
  388. p12-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
  389. - name: Setup Apple API Key
  390. if: runner.os == 'macOS'
  391. run: echo "${{ secrets.APPLE_API_KEY_PATH }}" > $RUNNER_TEMP/apple-api-key.p8
  392. - uses: ./.github/actions/setup-bun
  393. - name: Azure login
  394. if: runner.os == 'Windows'
  395. uses: azure/login@v2
  396. with:
  397. client-id: ${{ env.AZURE_CLIENT_ID }}
  398. tenant-id: ${{ env.AZURE_TENANT_ID }}
  399. subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }}
  400. - uses: actions/setup-node@v4
  401. with:
  402. node-version: "24"
  403. - name: Cache apt packages
  404. if: contains(matrix.settings.host, 'ubuntu')
  405. uses: actions/cache@v4
  406. with:
  407. path: ~/apt-cache
  408. key: ${{ runner.os }}-${{ matrix.settings.target }}-apt-electron-${{ hashFiles('.github/workflows/publish.yml') }}
  409. restore-keys: |
  410. ${{ runner.os }}-${{ matrix.settings.target }}-apt-electron-
  411. - name: Install dependencies (ubuntu only)
  412. if: contains(matrix.settings.host, 'ubuntu')
  413. run: |
  414. mkdir -p ~/apt-cache && chmod -R a+rw ~/apt-cache
  415. sudo apt-get update
  416. sudo apt-get install -y --no-install-recommends -o dir::cache::archives="$HOME/apt-cache" rpm
  417. sudo chmod -R a+rw ~/apt-cache
  418. - name: Setup git committer
  419. id: committer
  420. uses: ./.github/actions/setup-git-committer
  421. with:
  422. opencode-app-id: ${{ vars.OPENCODE_APP_ID }}
  423. opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
  424. - name: Prepare
  425. run: bun ./scripts/prepare.ts
  426. working-directory: packages/desktop-electron
  427. env:
  428. OPENCODE_VERSION: ${{ needs.version.outputs.version }}
  429. OPENCODE_CHANNEL: ${{ (github.ref_name == 'beta' && 'beta') || 'prod' }}
  430. OPENCODE_CLI_ARTIFACT: ${{ (runner.os == 'Windows' && 'opencode-cli-windows') || 'opencode-cli' }}
  431. RUST_TARGET: ${{ matrix.settings.target }}
  432. GH_TOKEN: ${{ github.token }}
  433. GITHUB_RUN_ID: ${{ github.run_id }}
  434. - name: Build
  435. run: bun run build
  436. working-directory: packages/desktop-electron
  437. env:
  438. OPENCODE_CHANNEL: ${{ (github.ref_name == 'beta' && 'beta') || 'prod' }}
  439. - name: Package and publish
  440. if: needs.version.outputs.release
  441. run: npx electron-builder ${{ matrix.settings.platform_flag }} --publish always --config electron-builder.config.ts
  442. working-directory: packages/desktop-electron
  443. timeout-minutes: 60
  444. env:
  445. OPENCODE_CHANNEL: ${{ (github.ref_name == 'beta' && 'beta') || 'prod' }}
  446. GH_TOKEN: ${{ steps.committer.outputs.token }}
  447. CSC_LINK: ${{ secrets.APPLE_CERTIFICATE }}
  448. CSC_KEY_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
  449. APPLE_API_KEY: ${{ runner.temp }}/apple-api-key.p8
  450. APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY }}
  451. APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
  452. - name: Package (no publish)
  453. if: ${{ !needs.version.outputs.release }}
  454. run: npx electron-builder ${{ matrix.settings.platform_flag }} --publish never --config electron-builder.config.ts
  455. working-directory: packages/desktop-electron
  456. timeout-minutes: 60
  457. env:
  458. OPENCODE_CHANNEL: ${{ (github.ref_name == 'beta' && 'beta') || 'prod' }}
  459. - name: Verify signed Windows Electron artifacts
  460. if: runner.os == 'Windows'
  461. shell: pwsh
  462. run: |
  463. $files = @()
  464. $files += Get-ChildItem "${{ github.workspace }}\packages\desktop-electron\dist\*.exe" | Select-Object -ExpandProperty FullName
  465. $files += Get-ChildItem "${{ github.workspace }}\packages\desktop-electron\dist\*unpacked\*.exe" | Select-Object -ExpandProperty FullName
  466. $files += Get-ChildItem "${{ github.workspace }}\packages\desktop-electron\dist\*unpacked\resources\opencode-cli.exe" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName
  467. foreach ($file in $files | Select-Object -Unique) {
  468. $sig = Get-AuthenticodeSignature $file
  469. if ($sig.Status -ne "Valid") {
  470. throw "Invalid signature for ${file}: $($sig.Status)"
  471. }
  472. }
  473. - uses: actions/upload-artifact@v4
  474. with:
  475. name: opencode-electron-${{ matrix.settings.target }}
  476. path: packages/desktop-electron/dist/*
  477. - uses: actions/upload-artifact@v4
  478. if: needs.version.outputs.release
  479. with:
  480. name: latest-yml-${{ matrix.settings.target }}
  481. path: packages/desktop-electron/dist/latest*.yml
  482. publish:
  483. needs:
  484. - version
  485. - build-cli
  486. - sign-cli-windows
  487. - build-tauri
  488. - build-electron
  489. if: always() && !failure() && !cancelled()
  490. runs-on: blacksmith-4vcpu-ubuntu-2404
  491. steps:
  492. - uses: actions/checkout@v3
  493. - uses: ./.github/actions/setup-bun
  494. - name: Login to GitHub Container Registry
  495. uses: docker/login-action@v3
  496. with:
  497. registry: ghcr.io
  498. username: ${{ github.repository_owner }}
  499. password: ${{ secrets.GITHUB_TOKEN }}
  500. - name: Set up QEMU
  501. uses: docker/setup-qemu-action@v3
  502. - name: Set up Docker Buildx
  503. uses: docker/setup-buildx-action@v3
  504. - uses: actions/setup-node@v4
  505. with:
  506. node-version: "24"
  507. registry-url: "https://registry.npmjs.org"
  508. - name: Setup git committer
  509. id: committer
  510. uses: ./.github/actions/setup-git-committer
  511. with:
  512. opencode-app-id: ${{ vars.OPENCODE_APP_ID }}
  513. opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
  514. - uses: actions/download-artifact@v4
  515. with:
  516. name: opencode-cli
  517. path: packages/opencode/dist
  518. - uses: actions/download-artifact@v4
  519. with:
  520. name: opencode-cli-windows
  521. path: packages/opencode/dist
  522. - uses: actions/download-artifact@v4
  523. with:
  524. name: opencode-cli-signed-windows
  525. path: packages/opencode/dist
  526. - uses: actions/download-artifact@v4
  527. if: needs.version.outputs.release
  528. with:
  529. pattern: latest-yml-*
  530. path: /tmp/latest-yml
  531. - name: Cache apt packages (AUR)
  532. uses: actions/cache@v4
  533. with:
  534. path: /var/cache/apt/archives
  535. key: ${{ runner.os }}-apt-aur-${{ hashFiles('.github/workflows/publish.yml') }}
  536. restore-keys: |
  537. ${{ runner.os }}-apt-aur-
  538. - name: Setup SSH for AUR
  539. run: |
  540. sudo apt-get update
  541. sudo apt-get install -y pacman-package-manager
  542. mkdir -p ~/.ssh
  543. echo "${{ secrets.AUR_KEY }}" > ~/.ssh/id_rsa
  544. chmod 600 ~/.ssh/id_rsa
  545. git config --global user.email "[email protected]"
  546. git config --global user.name "opencode"
  547. ssh-keyscan -H aur.archlinux.org >> ~/.ssh/known_hosts || true
  548. - run: ./script/publish.ts
  549. env:
  550. OPENCODE_VERSION: ${{ needs.version.outputs.version }}
  551. OPENCODE_RELEASE: ${{ needs.version.outputs.release }}
  552. AUR_KEY: ${{ secrets.AUR_KEY }}
  553. GITHUB_TOKEN: ${{ steps.committer.outputs.token }}
  554. GH_REPO: ${{ needs.version.outputs.repo }}
  555. NPM_CONFIG_PROVENANCE: false
  556. LATEST_YML_DIR: /tmp/latest-yml