publish.yml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  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. run: |
  63. ./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. publish-tauri:
  72. if: false # inputs.bump || inputs.version
  73. continue-on-error: true
  74. strategy:
  75. fail-fast: false
  76. matrix:
  77. settings:
  78. - host: macos-latest
  79. target: x86_64-apple-darwin
  80. - host: macos-latest
  81. target: aarch64-apple-darwin
  82. - host: windows-latest
  83. target: x86_64-pc-windows-msvc
  84. - host: ubuntu-24.04
  85. target: x86_64-unknown-linux-gnu
  86. runs-on: ${{ matrix.settings.host }}
  87. steps:
  88. - uses: actions/checkout@v3
  89. with:
  90. fetch-depth: 0
  91. - uses: apple-actions/import-codesign-certs@v2
  92. if: ${{ runner.os == 'macOS' }}
  93. with:
  94. keychain: build
  95. p12-file-base64: ${{ secrets.APPLE_CERTIFICATE }}
  96. p12-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
  97. - name: Verify Certificate
  98. if: ${{ runner.os == 'macOS' }}
  99. run: |
  100. CERT_INFO=$(security find-identity -v -p codesigning build.keychain | grep "Developer ID Application")
  101. CERT_ID=$(echo "$CERT_INFO" | awk -F'"' '{print $2}')
  102. echo "CERT_ID=$CERT_ID" >> $GITHUB_ENV
  103. echo "Certificate imported."
  104. - name: Setup Apple API Key
  105. if: ${{ runner.os == 'macOS' }}
  106. run: |
  107. echo "${{ secrets.APPLE_API_KEY_PATH }}" > $RUNNER_TEMP/apple-api-key.p8
  108. - run: git fetch --force --tags
  109. - uses: ./.github/actions/setup-bun
  110. - name: install dependencies (ubuntu only)
  111. if: startsWith(matrix.settings.host, 'ubuntu')
  112. run: |
  113. sudo apt-get update
  114. sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
  115. - name: install Rust stable
  116. uses: dtolnay/rust-toolchain@stable
  117. with:
  118. targets: ${{ matrix.settings.target }}
  119. - uses: Swatinem/rust-cache@v2
  120. with:
  121. workspaces: packages/tauri/src-tauri
  122. shared-key: ${{ matrix.settings.target }}
  123. - name: Prepare
  124. run: |
  125. cd packages/tauri
  126. bun ./scripts/prepare.ts
  127. env:
  128. OPENCODE_BUMP: ${{ inputs.bump }}
  129. OPENCODE_VERSION: ${{ inputs.version }}
  130. OPENCODE_CHANNEL: latest
  131. NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
  132. GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }}
  133. AUR_KEY: ${{ secrets.AUR_KEY }}
  134. OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
  135. RUST_TARGET: ${{ matrix.settings.target }}
  136. GH_TOKEN: ${{ github.token }}
  137. # Fixes AppImage build issues, can be removed when https://github.com/tauri-apps/tauri/pull/12491 is released
  138. - run: cargo install tauri-cli --git https://github.com/tauri-apps/tauri --branch feat/truly-portable-appimage
  139. if: startsWith(matrix.settings.host, 'ubuntu')
  140. - name: Build and upload artifacts
  141. uses: tauri-apps/tauri-action@390cbe447412ced1303d35abe75287949e43437a
  142. env:
  143. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  144. TAURI_BUNDLER_NEW_APPIMAGE_FORMAT: true
  145. TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
  146. TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
  147. APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
  148. APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
  149. APPLE_SIGNING_IDENTITY: ${{ env.CERT_ID }}
  150. APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
  151. APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
  152. APPLE_API_KEY_PATH: ${{ runner.temp }}/apple-api-key.p8
  153. with:
  154. projectPath: packages/tauri
  155. uploadWorkflowArtifacts: true
  156. tauriScript: ${{ (startsWith(matrix.settings.host, 'ubuntu') && 'cargo tauri') || '' }}
  157. args: --target ${{ matrix.settings.target }}
  158. updaterJsonPreferNsis: true
  159. # releaseId: TODO