publish.yml 25 KB

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