publish.yml 23 KB

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