publish.yml 6.0 KB

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