publish.yml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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. contents: write
  25. packages: write
  26. jobs:
  27. publish:
  28. runs-on: blacksmith-4vcpu-ubuntu-2404
  29. if: github.repository == 'sst/opencode' && github.ref == 'refs/heads/dev'
  30. steps:
  31. - uses: actions/checkout@v3
  32. with:
  33. fetch-depth: 0
  34. - run: git fetch --force --tags
  35. - uses: ./.github/actions/setup-bun
  36. - name: Setup SSH for AUR
  37. if: inputs.bump || inputs.version
  38. run: |
  39. sudo apt-get update
  40. sudo apt-get install -y pacman-package-manager
  41. mkdir -p ~/.ssh
  42. echo "${{ secrets.AUR_KEY }}" > ~/.ssh/id_rsa
  43. chmod 600 ~/.ssh/id_rsa
  44. git config --global user.email "[email protected]"
  45. git config --global user.name "opencode"
  46. ssh-keyscan -H aur.archlinux.org >> ~/.ssh/known_hosts || true
  47. - name: Install OpenCode
  48. if: inputs.bump || inputs.version
  49. run: curl -fsSL https://opencode.ai/install | bash
  50. - name: Login to GitHub Container Registry
  51. uses: docker/login-action@v3
  52. with:
  53. registry: ghcr.io
  54. username: ${{ github.repository_owner }}
  55. password: ${{ secrets.GITHUB_TOKEN }}
  56. - uses: actions/setup-node@v4
  57. with:
  58. node-version: "24"
  59. registry-url: "https://registry.npmjs.org"
  60. - name: Publish
  61. run: |
  62. ./script/publish.ts
  63. env:
  64. OPENCODE_BUMP: ${{ inputs.bump }}
  65. OPENCODE_VERSION: ${{ inputs.version }}
  66. OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
  67. AUR_KEY: ${{ secrets.AUR_KEY }}
  68. GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }}
  69. NPM_CONFIG_PROVENANCE: false
  70. publish-tauri:
  71. if: inputs.bump || inputs.version
  72. continue-on-error: true
  73. strategy:
  74. fail-fast: false
  75. matrix:
  76. settings:
  77. - host: macos-latest
  78. target: x86_64-apple-darwin
  79. - host: macos-latest
  80. target: aarch64-apple-darwin
  81. - host: windows-latest
  82. target: x86_64-pc-windows-msvc
  83. - host: ubuntu-24.04
  84. target: x86_64-unknown-linux-gnu
  85. runs-on: ${{ matrix.settings.host }}
  86. steps:
  87. - uses: actions/checkout@v3
  88. with:
  89. fetch-depth: 0
  90. - uses: apple-actions/import-codesign-certs@v2
  91. if: ${{ runner.os == 'macOS' }}
  92. with:
  93. keychain: build
  94. p12-file-base64: ${{ secrets.APPLE_CERTIFICATE }}
  95. p12-password: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
  96. - name: Verify Certificate
  97. if: ${{ runner.os == 'macOS' }}
  98. run: |
  99. CERT_INFO=$(security find-identity -v -p codesigning build.keychain | grep "Developer ID Application")
  100. CERT_ID=$(echo "$CERT_INFO" | awk -F'"' '{print $2}')
  101. echo "CERT_ID=$CERT_ID" >> $GITHUB_ENV
  102. echo "Certificate imported."
  103. - name: Setup Apple API Key
  104. if: ${{ runner.os == 'macOS' }}
  105. run: |
  106. echo "${{ secrets.APPLE_API_KEY_PATH }}" > $RUNNER_TEMP/apple-api-key.p8
  107. - run: git fetch --force --tags
  108. - uses: ./.github/actions/setup-bun
  109. - name: install dependencies (ubuntu only)
  110. if: startsWith(matrix.settings.host, 'ubuntu')
  111. run: |
  112. sudo apt-get update
  113. sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev patchelf
  114. - name: install Rust stable
  115. uses: dtolnay/rust-toolchain@stable
  116. with:
  117. targets: ${{ matrix.settings.target }}
  118. - uses: Swatinem/rust-cache@v2
  119. with:
  120. workspaces: packages/tauri/src-tauri
  121. shared-key: ${{ matrix.settings.target }}
  122. - name: Prepare
  123. run: |
  124. cd packages/tauri
  125. bun ./scripts/prepare.ts
  126. env:
  127. OPENCODE_BUMP: ${{ inputs.bump }}
  128. OPENCODE_VERSION: ${{ inputs.version }}
  129. OPENCODE_CHANNEL: latest
  130. NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
  131. GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }}
  132. AUR_KEY: ${{ secrets.AUR_KEY }}
  133. OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
  134. RUST_TARGET: ${{ matrix.settings.target }}
  135. GH_TOKEN: ${{ github.token }}
  136. # Fixes AppImage build issues, can be removed when https://github.com/tauri-apps/tauri/pull/12491 is released
  137. - run: cargo install tauri-cli --git https://github.com/tauri-apps/tauri --branch feat/truly-portable-appimage
  138. if: startsWith(matrix.settings.host, 'ubuntu')
  139. - name: Build and upload artifacts
  140. uses: tauri-apps/tauri-action@390cbe447412ced1303d35abe75287949e43437a
  141. env:
  142. GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  143. TAURI_BUNDLER_NEW_APPIMAGE_FORMAT: true
  144. TAURI_SIGNING_PRIVATE_KEY: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY }}
  145. TAURI_SIGNING_PRIVATE_KEY_PASSWORD: ${{ secrets.TAURI_SIGNING_PRIVATE_KEY_PASSWORD }}
  146. APPLE_CERTIFICATE: ${{ secrets.APPLE_CERTIFICATE }}
  147. APPLE_CERTIFICATE_PASSWORD: ${{ secrets.APPLE_CERTIFICATE_PASSWORD }}
  148. APPLE_SIGNING_IDENTITY: ${{ env.CERT_ID }}
  149. APPLE_API_ISSUER: ${{ secrets.APPLE_API_ISSUER }}
  150. APPLE_API_KEY: ${{ secrets.APPLE_API_KEY }}
  151. APPLE_API_KEY_PATH: ${{ runner.temp }}/apple-api-key.p8
  152. with:
  153. projectPath: packages/tauri
  154. uploadWorkflowArtifacts: true
  155. tauriScript: ${{ (startsWith(matrix.settings.host, 'ubuntu') && 'cargo tauri') || '' }}
  156. args: --target ${{ matrix.settings.target }}
  157. updaterJsonPreferNsis: true
  158. # releaseId: TODO