publish.yml 8.2 KB

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