publish.yml 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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 }}
  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' && github.ref == 'refs/heads/dev'
  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: Setup SSH for AUR
  38. if: inputs.bump || inputs.version
  39. run: |
  40. sudo apt-get update
  41. sudo apt-get install -y pacman-package-manager
  42. mkdir -p ~/.ssh
  43. echo "${{ secrets.AUR_KEY }}" > ~/.ssh/id_rsa
  44. chmod 600 ~/.ssh/id_rsa
  45. git config --global user.email "[email protected]"
  46. git config --global user.name "opencode"
  47. ssh-keyscan -H aur.archlinux.org >> ~/.ssh/known_hosts || true
  48. - name: Install OpenCode
  49. if: inputs.bump || inputs.version
  50. run: bun i -g [email protected]
  51. - name: Login to GitHub Container Registry
  52. uses: docker/login-action@v3
  53. with:
  54. registry: ghcr.io
  55. username: ${{ github.repository_owner }}
  56. password: ${{ secrets.GITHUB_TOKEN }}
  57. - uses: actions/setup-node@v4
  58. with:
  59. node-version: "24"
  60. registry-url: "https://registry.npmjs.org"
  61. - name: Publish
  62. id: publish
  63. run: ./script/publish.ts
  64. env:
  65. OPENCODE_BUMP: ${{ inputs.bump }}
  66. OPENCODE_VERSION: ${{ inputs.version }}
  67. OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
  68. AUR_KEY: ${{ secrets.AUR_KEY }}
  69. GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }}
  70. NPM_CONFIG_PROVENANCE: false
  71. outputs:
  72. releaseId: ${{ steps.publish.outputs.releaseId }}
  73. tagName: ${{ steps.publish.outputs.tagName }}
  74. publish-tauri:
  75. needs: publish
  76. continue-on-error: true
  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. runs-on: ${{ matrix.settings.host }}
  90. steps:
  91. - uses: actions/checkout@v3
  92. with:
  93. fetch-depth: 0
  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. - run: git fetch --force --tags
  112. - uses: ./.github/actions/setup-bun
  113. - name: install dependencies (ubuntu only)
  114. if: contains(matrix.settings.host, 'ubuntu')
  115. run: |
  116. sudo apt-get update
  117. sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
  118. - name: install Rust stable
  119. uses: dtolnay/rust-toolchain@stable
  120. with:
  121. targets: ${{ matrix.settings.target }}
  122. - uses: Swatinem/rust-cache@v2
  123. with:
  124. workspaces: packages/tauri/src-tauri
  125. shared-key: ${{ matrix.settings.target }}
  126. - name: Prepare
  127. run: |
  128. cd packages/tauri
  129. bun ./scripts/prepare.ts
  130. env:
  131. OPENCODE_BUMP: ${{ inputs.bump }}
  132. OPENCODE_VERSION: ${{ inputs.version }}
  133. OPENCODE_CHANNEL: latest
  134. NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
  135. GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }}
  136. AUR_KEY: ${{ secrets.AUR_KEY }}
  137. OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
  138. RUST_TARGET: ${{ matrix.settings.target }}
  139. GH_TOKEN: ${{ github.token }}
  140. # Fixes AppImage build issues, can be removed when https://github.com/tauri-apps/tauri/pull/12491 is released
  141. - run: cargo install tauri-cli --git https://github.com/tauri-apps/tauri --branch feat/truly-portable-appimage
  142. if: contains(matrix.settings.host, 'ubuntu')
  143. - name: Build and upload artifacts
  144. uses: tauri-apps/tauri-action@390cbe447412ced1303d35abe75287949e43437a
  145. env:
  146. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  147. TAURI_BUNDLER_NEW_APPIMAGE_FORMAT: true
  148. TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
  149. TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
  150. APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
  151. APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
  152. APPLE_SIGNING_IDENTITY: ${{ env.CERT_ID }}
  153. APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
  154. APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
  155. APPLE_API_KEY_PATH: ${{ runner.temp }}/apple-api-key.p8
  156. with:
  157. projectPath: packages/tauri
  158. uploadWorkflowArtifacts: true
  159. tauriScript: ${{ (contains(matrix.settings.host, 'ubuntu') && 'cargo tauri') || '' }}
  160. args: --target ${{ matrix.settings.target }}
  161. updaterJsonPreferNsis: true
  162. releaseId: ${{ needs.publish.outputs.releaseId }}
  163. tagName: ${{ needs.publish.outputs.tagName }}
  164. releaseAssetNamePattern: opencode-desktop-[platform]-[arch][ext]