publish.yml 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. name: publish
  2. run-name: "${{ format('release {0}', inputs.bump) }}"
  3. on:
  4. push:
  5. branches:
  6. - ci
  7. - dev
  8. - beta
  9. - snapshot-*
  10. workflow_dispatch:
  11. inputs:
  12. bump:
  13. description: "Bump major, minor, or patch"
  14. required: false
  15. type: choice
  16. options:
  17. - major
  18. - minor
  19. - patch
  20. version:
  21. description: "Override version (optional)"
  22. required: false
  23. type: string
  24. concurrency: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.version || inputs.bump }}
  25. permissions:
  26. id-token: write
  27. contents: write
  28. packages: write
  29. jobs:
  30. version:
  31. runs-on: blacksmith-4vcpu-ubuntu-2404
  32. if: github.repository == 'anomalyco/opencode'
  33. steps:
  34. - uses: actions/checkout@v3
  35. - uses: ./.github/actions/setup-bun
  36. - id: version
  37. run: |
  38. ./script/version.ts
  39. env:
  40. GH_TOKEN: ${{ github.token }}
  41. OPENCODE_BUMP: ${{ inputs.bump }}
  42. OPENCODE_VERSION: ${{ inputs.version }}
  43. outputs:
  44. version: ${{ steps.version.outputs.version }}
  45. release: ${{ steps.version.outputs.release }}
  46. tag: ${{ steps.version.outputs.tag }}
  47. build-cli:
  48. needs: version
  49. runs-on: blacksmith-4vcpu-ubuntu-2404
  50. if: github.repository == 'anomalyco/opencode'
  51. steps:
  52. - uses: actions/checkout@v3
  53. with:
  54. fetch-tags: true
  55. - uses: ./.github/actions/setup-bun
  56. - name: Build
  57. id: build
  58. run: |
  59. ./packages/opencode/script/build.ts
  60. env:
  61. OPENCODE_VERSION: ${{ needs.version.outputs.version }}
  62. OPENCODE_RELEASE: ${{ needs.version.outputs.release }}
  63. GH_TOKEN: ${{ github.token }}
  64. - uses: actions/upload-artifact@v4
  65. with:
  66. name: opencode-cli
  67. path: packages/opencode/dist
  68. outputs:
  69. version: ${{ needs.version.outputs.version }}
  70. build-tauri:
  71. needs:
  72. - build-cli
  73. - version
  74. continue-on-error: false
  75. strategy:
  76. fail-fast: false
  77. matrix:
  78. settings:
  79. - host: macos-latest
  80. target: x86_64-apple-darwin
  81. - host: macos-latest
  82. target: aarch64-apple-darwin
  83. - host: blacksmith-4vcpu-windows-2025
  84. target: x86_64-pc-windows-msvc
  85. - host: blacksmith-4vcpu-ubuntu-2404
  86. target: x86_64-unknown-linux-gnu
  87. - host: blacksmith-4vcpu-ubuntu-2404-arm
  88. target: aarch64-unknown-linux-gnu
  89. runs-on: ${{ matrix.settings.host }}
  90. steps:
  91. - uses: actions/checkout@v3
  92. with:
  93. fetch-tags: true
  94. - uses: apple-actions/import-codesign-certs@v2
  95. if: ${{ runner.os == 'macOS' }}
  96. with:
  97. keychain: build
  98. p12-file-base64: ${{ secrets.APPLE_CERTIFICATE }}
  99. p12-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
  100. - name: Verify Certificate
  101. if: ${{ runner.os == 'macOS' }}
  102. run: |
  103. CERT_INFO=$(security find-identity -v -p codesigning build.keychain | grep "Developer ID Application")
  104. CERT_ID=$(echo "$CERT_INFO" | awk -F'"' '{print $2}')
  105. echo "CERT_ID=$CERT_ID" >> $GITHUB_ENV
  106. echo "Certificate imported."
  107. - name: Setup Apple API Key
  108. if: ${{ runner.os == 'macOS' }}
  109. run: |
  110. echo "${{ secrets.APPLE_API_KEY_PATH }}" > $RUNNER_TEMP/apple-api-key.p8
  111. - uses: ./.github/actions/setup-bun
  112. - name: install dependencies (ubuntu only)
  113. if: contains(matrix.settings.host, 'ubuntu')
  114. run: |
  115. sudo apt-get update
  116. sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
  117. - name: install Rust stable
  118. uses: dtolnay/rust-toolchain@stable
  119. with:
  120. targets: ${{ matrix.settings.target }}
  121. - uses: Swatinem/rust-cache@v2
  122. with:
  123. workspaces: packages/desktop/src-tauri
  124. shared-key: ${{ matrix.settings.target }}
  125. - name: Prepare
  126. run: |
  127. cd packages/desktop
  128. bun ./scripts/prepare.ts
  129. env:
  130. OPENCODE_VERSION: ${{ needs.publish.outputs.version }}
  131. GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }}
  132. RUST_TARGET: ${{ matrix.settings.target }}
  133. GH_TOKEN: ${{ github.token }}
  134. GITHUB_RUN_ID: ${{ github.run_id }}
  135. # Fixes AppImage build issues, can be removed when https://github.com/tauri-apps/tauri/pull/12491 is released
  136. - name: Install tauri-cli from portable appimage branch
  137. if: contains(matrix.settings.host, 'ubuntu')
  138. run: |
  139. cargo install tauri-cli --git https://github.com/tauri-apps/tauri --branch feat/truly-portable-appimage --force
  140. echo "Installed tauri-cli version:"
  141. cargo tauri --version
  142. - name: Build and upload artifacts
  143. uses: tauri-apps/tauri-action@390cbe447412ced1303d35abe75287949e43437a
  144. timeout-minutes: 60
  145. with:
  146. projectPath: packages/desktop
  147. uploadWorkflowArtifacts: true
  148. tauriScript: ${{ (contains(matrix.settings.host, 'ubuntu') && 'cargo tauri') || '' }}
  149. args: --target ${{ matrix.settings.target }} --config ./src-tauri/tauri.prod.conf.json --verbose
  150. updaterJsonPreferNsis: true
  151. releaseId: ${{ needs.version.outputs.release }}
  152. tagName: ${{ needs.version.outputs.tag }}
  153. releaseDraft: true
  154. releaseAssetNamePattern: opencode-desktop-[platform]-[arch][ext]
  155. env:
  156. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  157. TAURI_BUNDLER_NEW_APPIMAGE_FORMAT: true
  158. TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
  159. TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
  160. APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
  161. APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
  162. APPLE_SIGNING_IDENTITY: ${{ env.CERT_ID }}
  163. APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
  164. APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
  165. APPLE_API_KEY_PATH: ${{ runner.temp }}/apple-api-key.p8
  166. publish:
  167. needs:
  168. - version
  169. - build-cli
  170. - build-tauri
  171. runs-on: blacksmith-4vcpu-ubuntu-2404
  172. steps:
  173. - uses: actions/checkout@v3
  174. with:
  175. fetch-depth: 0
  176. - uses: ./.github/actions/setup-bun
  177. - name: Install OpenCode
  178. if: inputs.bump || inputs.version
  179. run: bun i -g opencode-ai
  180. - name: Login to GitHub Container Registry
  181. uses: docker/login-action@v3
  182. with:
  183. registry: ghcr.io
  184. username: ${{ github.repository_owner }}
  185. password: ${{ secrets.GITHUB_TOKEN }}
  186. - name: Set up QEMU
  187. uses: docker/setup-qemu-action@v3
  188. - name: Set up Docker Buildx
  189. uses: docker/setup-buildx-action@v3
  190. - uses: actions/setup-node@v4
  191. with:
  192. node-version: "24"
  193. registry-url: "https://registry.npmjs.org"
  194. - name: Setup Git Identity
  195. run: |
  196. git config --global user.email "[email protected]"
  197. git config --global user.name "opencode"
  198. git remote set-url origin https://x-access-token:${{ secrets.SST_GITHUB_TOKEN }}@github.com/${{ github.repository }}
  199. - uses: actions/download-artifact@v4
  200. with:
  201. name: opencode-cli
  202. path: packages/opencode/dist
  203. - name: Setup SSH for AUR
  204. run: |
  205. sudo apt-get update
  206. sudo apt-get install -y pacman-package-manager
  207. mkdir -p ~/.ssh
  208. echo "${{ secrets.AUR_KEY }}" > ~/.ssh/id_rsa
  209. chmod 600 ~/.ssh/id_rsa
  210. git config --global user.email "[email protected]"
  211. git config --global user.name "opencode"
  212. ssh-keyscan -H aur.archlinux.org >> ~/.ssh/known_hosts || true
  213. - run: ./script/publish.ts
  214. env:
  215. OPENCODE_VERSION: ${{ needs.version.outputs.version }}
  216. OPENCODE_RELEASE: ${{ needs.version.outputs.release }}
  217. AUR_KEY: ${{ secrets.AUR_KEY }}
  218. GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }}
  219. OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
  220. NPM_CONFIG_PROVENANCE: false