publish.yml 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. name: publish
  2. run-name: "${{ format('release {0}', inputs.bump) }}"
  3. on:
  4. workflow_dispatch:
  5. inputs:
  6. bump:
  7. description: "Bump major, minor, or patch"
  8. required: true
  9. type: choice
  10. options:
  11. - major
  12. - minor
  13. - patch
  14. version:
  15. description: "Override version (optional)"
  16. required: false
  17. type: string
  18. concurrency: ${{ github.workflow }}-${{ github.ref }}
  19. permissions:
  20. contents: write
  21. packages: write
  22. jobs:
  23. publish:
  24. runs-on: blacksmith-4vcpu-ubuntu-2404
  25. if: github.repository == 'sst/opencode' && github.ref == 'refs/heads/dev'
  26. steps:
  27. - uses: actions/checkout@v3
  28. with:
  29. fetch-depth: 0
  30. - run: git fetch --force --tags
  31. - uses: actions/setup-go@v5
  32. with:
  33. go-version: ">=1.24.0"
  34. cache: true
  35. cache-dependency-path: go.sum
  36. - uses: ./.github/actions/setup-bun
  37. - name: Install makepkg
  38. run: |
  39. sudo apt-get update
  40. sudo apt-get install -y pacman-package-manager
  41. - name: Setup SSH for AUR
  42. run: |
  43. mkdir -p ~/.ssh
  44. echo "${{ secrets.AUR_KEY }}" > ~/.ssh/id_rsa
  45. chmod 600 ~/.ssh/id_rsa
  46. git config --global user.email "[email protected]"
  47. git config --global user.name "opencode"
  48. ssh-keyscan -H aur.archlinux.org >> ~/.ssh/known_hosts || true
  49. - name: Install OpenCode
  50. run: curl -fsSL https://opencode.ai/install | bash
  51. - name: Setup npm auth
  52. run: |
  53. echo "//registry.npmjs.org/:_authToken=${{ secrets.NPM_TOKEN }}" > ~/.npmrc
  54. - name: Login to GitHub Container Registry
  55. uses: docker/login-action@v3
  56. with:
  57. registry: ghcr.io
  58. username: ${{ github.repository_owner }}
  59. password: ${{ secrets.GITHUB_TOKEN }}
  60. - name: Publish
  61. run: |
  62. ./script/publish.ts
  63. env:
  64. OPENCODE_BUMP: ${{ inputs.bump }}
  65. OPENCODE_VERSION: ${{ inputs.version }}
  66. OPENCODE_CHANNEL: latest
  67. NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
  68. GITHUB_TOKEN: ${{ secrets.SST_GITHUB_TOKEN }}
  69. AUR_KEY: ${{ secrets.AUR_KEY }}
  70. OPENCODE_API_KEY: ${{ secrets.OPENCODE_API_KEY }}
  71. publish-tauri:
  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