publish.yml 8.2 KB

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