publish.yml 8.2 KB

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