publish.yml 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593
  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. - build-cli
  250. - version
  251. if: github.repository == 'anomalyco/opencode' && github.ref_name != 'v2'
  252. continue-on-error: false
  253. env:
  254. AZURE_CLIENT_ID: ${{ secrets.AZURE_CLIENT_ID }}
  255. AZURE_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }}
  256. AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
  257. AZURE_TRUSTED_SIGNING_ACCOUNT_NAME: ${{ secrets.AZURE_TRUSTED_SIGNING_ACCOUNT_NAME }}
  258. AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE: ${{ secrets.AZURE_TRUSTED_SIGNING_CERTIFICATE_PROFILE }}
  259. AZURE_TRUSTED_SIGNING_ENDPOINT: ${{ secrets.AZURE_TRUSTED_SIGNING_ENDPOINT }}
  260. strategy:
  261. fail-fast: false
  262. matrix:
  263. settings:
  264. - host: macos-26-intel
  265. target: x86_64-apple-darwin
  266. platform_flag: --mac --x64
  267. bun_install_flags: --os=darwin --cpu=x64
  268. - host: macos-26
  269. target: aarch64-apple-darwin
  270. platform_flag: --mac --arm64
  271. bun_install_flags: --os=darwin --cpu=arm64
  272. # github-hosted: blacksmith lacks ARM64 MSVC cross-compilation toolchain
  273. - host: "windows-2025"
  274. target: aarch64-pc-windows-msvc
  275. platform_flag: --win --arm64
  276. - host: "blacksmith-4vcpu-windows-2025"
  277. target: x86_64-pc-windows-msvc
  278. platform_flag: --win
  279. - host: "blacksmith-4vcpu-ubuntu-2404"
  280. target: x86_64-unknown-linux-gnu
  281. platform_flag: --linux
  282. - host: "blacksmith-4vcpu-ubuntu-2404-arm"
  283. target: aarch64-unknown-linux-gnu
  284. platform_flag: --linux --arm64
  285. runs-on: ${{ matrix.settings.host }}
  286. steps:
  287. - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
  288. - uses: apple-actions/import-codesign-certs@8f3fb608891dd2244cdab3d69cd68c0d37a7fe93 # v2.0.0
  289. if: runner.os == 'macOS'
  290. with:
  291. keychain: build
  292. p12-file-base64: ${{ secrets.APPLE_CERTIFICATE }}
  293. p12-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
  294. - name: Setup Apple API Key
  295. if: runner.os == 'macOS'
  296. run: echo "${{ secrets.APPLE_API_KEY_PATH }}" > $RUNNER_TEMP/apple-api-key.p8
  297. - uses: ./.github/actions/setup-bun
  298. with:
  299. install-flags: ${{ matrix.settings.bun_install_flags }}
  300. - name: Azure login
  301. if: runner.os == 'Windows'
  302. uses: azure/login@a457da9ea143d694b1b9c7c869ebb04ebe844ef5 # v2.3.0
  303. with:
  304. client-id: ${{ env.AZURE_CLIENT_ID }}
  305. tenant-id: ${{ env.AZURE_TENANT_ID }}
  306. subscription-id: ${{ env.AZURE_SUBSCRIPTION_ID }}
  307. - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
  308. with:
  309. node-version: "24"
  310. - name: Cache apt packages
  311. if: contains(matrix.settings.host, 'ubuntu')
  312. uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
  313. with:
  314. path: ~/apt-cache
  315. key: ${{ runner.os }}-${{ matrix.settings.target }}-apt-electron-${{ hashFiles('.github/workflows/publish.yml') }}
  316. restore-keys: |
  317. ${{ runner.os }}-${{ matrix.settings.target }}-apt-electron-
  318. - name: Install dependencies (ubuntu only)
  319. if: contains(matrix.settings.host, 'ubuntu')
  320. run: |
  321. mkdir -p ~/apt-cache && chmod -R a+rw ~/apt-cache
  322. sudo apt-get update
  323. sudo apt-get install -y --no-install-recommends -o dir::cache::archives="$HOME/apt-cache" rpm
  324. sudo chmod -R a+rw ~/apt-cache
  325. - name: Setup git committer
  326. id: committer
  327. uses: ./.github/actions/setup-git-committer
  328. with:
  329. opencode-app-id: ${{ vars.OPENCODE_APP_ID }}
  330. opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
  331. - name: Prepare
  332. run: bun ./scripts/prepare.ts
  333. working-directory: packages/desktop
  334. env:
  335. OPENCODE_VERSION: ${{ needs.version.outputs.version }}
  336. OPENCODE_CHANNEL: ${{ (github.ref_name == 'beta' && 'beta') || 'prod' }}
  337. OPENCODE_CLI_ARTIFACT: ${{ (runner.os == 'Windows' && 'opencode-cli-windows') || 'opencode-cli' }}
  338. RUST_TARGET: ${{ matrix.settings.target }}
  339. GH_TOKEN: ${{ github.token }}
  340. GITHUB_RUN_ID: ${{ github.run_id }}
  341. - name: Build
  342. run: bun run build
  343. working-directory: packages/desktop
  344. env:
  345. NODE_OPTIONS: --max-old-space-size=4096
  346. OPENCODE_CHANNEL: ${{ (github.ref_name == 'beta' && 'beta') || 'prod' }}
  347. SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
  348. SENTRY_ORG: ${{ vars.SENTRY_ORG }}
  349. SENTRY_PROJECT: ${{ vars.WEB_SENTRY_PROJECT }}
  350. SENTRY_RELEASE: desktop@${{ needs.version.outputs.version }}
  351. VITE_SENTRY_DSN: ${{ vars.WEB_SENTRY_DSN }}
  352. VITE_SENTRY_ENVIRONMENT: ${{ (github.ref_name == 'beta' && 'beta') || 'production' }}
  353. VITE_SENTRY_RELEASE: desktop@${{ needs.version.outputs.version }}
  354. - name: Package
  355. if: needs.version.outputs.release
  356. run: npx electron-builder ${{ matrix.settings.platform_flag }} --publish never --config electron-builder.config.ts
  357. working-directory: packages/desktop
  358. timeout-minutes: 60
  359. env:
  360. OPENCODE_CHANNEL: ${{ (github.ref_name == 'beta' && 'beta') || 'prod' }}
  361. GH_TOKEN: ${{ steps.committer.outputs.token }}
  362. CSC_LINK: ${{ secrets.APPLE_CERTIFICATE }}
  363. CSC_KEY_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
  364. APPLE_API_KEY: ${{ runner.temp }}/apple-api-key.p8
  365. APPLE_API_KEY_ID: ${{ secrets.APPLE_API_KEY }}
  366. APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
  367. - name: Package (no publish)
  368. if: ${{ !needs.version.outputs.release }}
  369. run: npx electron-builder ${{ matrix.settings.platform_flag }} --publish never --config electron-builder.config.ts
  370. working-directory: packages/desktop
  371. timeout-minutes: 60
  372. env:
  373. OPENCODE_CHANNEL: ${{ (github.ref_name == 'beta' && 'beta') || 'prod' }}
  374. - name: Create macOS .app.tar.gz
  375. if: runner.os == 'macOS' && needs.version.outputs.release
  376. working-directory: packages/desktop/dist
  377. run: |
  378. if [[ "${{ matrix.settings.target }}" == "x86_64-apple-darwin" ]]; then
  379. APP_DIR="mac"
  380. OUT_NAME="opencode-desktop-mac-x64.app.tar.gz"
  381. elif [[ "${{ matrix.settings.target }}" == "aarch64-apple-darwin" ]]; then
  382. APP_DIR="mac-arm64"
  383. OUT_NAME="opencode-desktop-mac-arm64.app.tar.gz"
  384. else
  385. echo "Unknown macOS target: ${{ matrix.settings.target }}"
  386. exit 1
  387. fi
  388. APP_PATH=$(find "$APP_DIR" -maxdepth 1 -name "*.app" -type d | head -1)
  389. if [ -z "$APP_PATH" ]; then
  390. echo "No .app bundle found in $APP_DIR"
  391. exit 1
  392. fi
  393. tar -czf "$OUT_NAME" -C "$(dirname "$APP_PATH")" "$(basename "$APP_PATH")"
  394. - name: Verify signed Windows Electron artifacts
  395. if: runner.os == 'Windows'
  396. shell: pwsh
  397. run: |
  398. $files = @()
  399. $files += Get-ChildItem "${{ github.workspace }}\packages\desktop\dist\*.exe" | Select-Object -ExpandProperty FullName
  400. $files += Get-ChildItem "${{ github.workspace }}\packages\desktop\dist\*unpacked\*.exe" | Select-Object -ExpandProperty FullName
  401. $files += Get-ChildItem "${{ github.workspace }}\packages\desktop\dist\*unpacked\resources\opencode-cli.exe" -ErrorAction SilentlyContinue | Select-Object -ExpandProperty FullName
  402. foreach ($file in $files | Select-Object -Unique) {
  403. $sig = Get-AuthenticodeSignature $file
  404. if ($sig.Status -ne "Valid") {
  405. throw "Invalid signature for ${file}: $($sig.Status)"
  406. }
  407. }
  408. - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
  409. with:
  410. name: opencode-desktop-${{ matrix.settings.target }}
  411. path: packages/desktop/dist/*
  412. - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
  413. if: needs.version.outputs.release
  414. with:
  415. name: latest-yml-${{ matrix.settings.target }}
  416. path: packages/desktop/dist/latest*.yml
  417. publish:
  418. needs:
  419. - version
  420. - build-cli
  421. - build-node-cli
  422. - sign-cli-windows
  423. - build-electron
  424. if: always() && !failure() && !cancelled()
  425. runs-on: blacksmith-4vcpu-ubuntu-2404
  426. steps:
  427. - uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
  428. - uses: ./.github/actions/setup-bun
  429. - name: Login to GitHub Container Registry
  430. uses: docker/login-action@c94ce9fb468520275223c153574b00df6fe4bcc9 # v3.7.0
  431. with:
  432. registry: ghcr.io
  433. username: ${{ github.repository_owner }}
  434. password: ${{ secrets.GITHUB_TOKEN }}
  435. - name: Set up QEMU
  436. uses: docker/setup-qemu-action@c7c53464625b32c7a7e944ae62b3e17d2b600130 # v3.7.0
  437. - name: Set up Docker Buildx
  438. uses: docker/setup-buildx-action@8d2750c68a42422c14e847fe6c8ac0403b4cbd6f # v3.12.0
  439. - uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
  440. with:
  441. node-version: "24"
  442. registry-url: "https://registry.npmjs.org"
  443. - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
  444. if: github.ref_name != 'v2'
  445. with:
  446. name: opencode-cli
  447. path: packages/opencode/dist
  448. - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
  449. if: github.ref_name != 'v2'
  450. with:
  451. name: opencode-cli-windows
  452. path: packages/opencode/dist
  453. - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
  454. if: github.ref_name != 'v2'
  455. with:
  456. name: opencode-cli-signed-windows
  457. path: packages/opencode/dist
  458. - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
  459. with:
  460. name: opencode-preview-cli
  461. path: packages/cli/dist
  462. - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
  463. with:
  464. pattern: opencode-node-cli-*
  465. path: packages/cli/dist/node
  466. merge-multiple: true
  467. - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
  468. if: needs.version.outputs.release
  469. with:
  470. pattern: latest-yml-*
  471. path: /tmp/latest-yml
  472. - uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4.3.0
  473. if: needs.version.outputs.release
  474. with:
  475. pattern: opencode-desktop-*
  476. path: /tmp/desktop
  477. merge-multiple: true
  478. - name: Setup git committer
  479. id: committer
  480. uses: ./.github/actions/setup-git-committer
  481. with:
  482. opencode-app-id: ${{ vars.OPENCODE_APP_ID }}
  483. opencode-app-secret: ${{ secrets.OPENCODE_APP_SECRET }}
  484. - name: Cache apt packages (AUR)
  485. uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
  486. with:
  487. path: /var/cache/apt/archives
  488. key: ${{ runner.os }}-apt-aur-${{ hashFiles('.github/workflows/publish.yml') }}
  489. restore-keys: |
  490. ${{ runner.os }}-apt-aur-
  491. - name: Setup SSH for AUR
  492. run: |
  493. sudo apt-get update
  494. sudo apt-get install -y pacman-package-manager
  495. mkdir -p ~/.ssh
  496. echo "${{ secrets.AUR_KEY }}" > ~/.ssh/id_rsa
  497. chmod 600 ~/.ssh/id_rsa
  498. git config --global user.email "opencode@sst.dev"
  499. git config --global user.name "opencode"
  500. ssh-keyscan -H aur.archlinux.org >> ~/.ssh/known_hosts || true
  501. - name: Upload desktop release assets
  502. if: needs.version.outputs.release
  503. env:
  504. GH_TOKEN: ${{ steps.committer.outputs.token }}
  505. run: |
  506. shopt -s nullglob
  507. files=(/tmp/desktop/*.{exe,blockmap,dmg,zip,AppImage,deb,rpm} /tmp/desktop/*.app.tar.gz)
  508. if (( ${#files[@]} == 0 )); then
  509. echo "No desktop release assets found"
  510. exit 1
  511. fi
  512. gh release upload "v${{ needs.version.outputs.version }}" "${files[@]}" --clobber --repo "${{ needs.version.outputs.repo }}"
  513. - run: ./script/publish.ts
  514. env:
  515. OPENCODE_VERSION: ${{ needs.version.outputs.version }}
  516. OPENCODE_RELEASE: ${{ needs.version.outputs.release }}
  517. AUR_KEY: ${{ secrets.AUR_KEY }}
  518. GITHUB_TOKEN: ${{ steps.committer.outputs.token }}
  519. GH_REPO: ${{ needs.version.outputs.repo }}
  520. NPM_CONFIG_PROVENANCE: false
  521. LATEST_YML_DIR: /tmp/latest-yml
  522. TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
  523. TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}