publish.yml 23 KB

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