companion-release.yml 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. name: Companion Release
  2. on:
  3. workflow_dispatch:
  4. inputs:
  5. version:
  6. description: 'Companion version, for example 0.1.0'
  7. required: true
  8. type: string
  9. targets:
  10. description: >-
  11. Comma-separated targets to build: macos-arm64,macos-x64,linux-x64,linux-arm64,windows-x64
  12. required: true
  13. default: macos-arm64
  14. type: string
  15. permissions:
  16. contents: write
  17. jobs:
  18. macos-arm64:
  19. name: macOS arm64
  20. if: contains(github.event.inputs.targets, 'macos-arm64')
  21. runs-on: macos-latest
  22. steps:
  23. - uses: actions/checkout@v4
  24. - uses: dtolnay/rust-toolchain@stable
  25. with:
  26. targets: aarch64-apple-darwin
  27. - name: Build companion
  28. working-directory: companion
  29. run: cargo build --release --target aarch64-apple-darwin
  30. - name: Package companion
  31. run: |
  32. set -euo pipefail
  33. version='${{ github.event.inputs.version }}'
  34. target='aarch64-apple-darwin'
  35. name="oh-my-opencode-slim-companion-v${version}-${target}"
  36. mkdir -p dist
  37. cp "companion/target/${target}/release/oh-my-opencode-slim-companion" dist/oh-my-opencode-slim-companion
  38. tar -C dist -czf "${name}.tar.gz" oh-my-opencode-slim-companion
  39. - uses: actions/upload-artifact@v4
  40. with:
  41. name: companion-macos-arm64
  42. path: '*.tar.gz'
  43. macos-x64:
  44. name: macOS x64
  45. if: contains(github.event.inputs.targets, 'macos-x64')
  46. runs-on: macos-latest
  47. steps:
  48. - uses: actions/checkout@v4
  49. - uses: dtolnay/rust-toolchain@stable
  50. with:
  51. targets: x86_64-apple-darwin
  52. - name: Build companion
  53. working-directory: companion
  54. run: cargo build --release --target x86_64-apple-darwin
  55. - name: Package companion
  56. run: |
  57. set -euo pipefail
  58. version='${{ github.event.inputs.version }}'
  59. target='x86_64-apple-darwin'
  60. name="oh-my-opencode-slim-companion-v${version}-${target}"
  61. mkdir -p dist
  62. cp "companion/target/${target}/release/oh-my-opencode-slim-companion" dist/oh-my-opencode-slim-companion
  63. tar -C dist -czf "${name}.tar.gz" oh-my-opencode-slim-companion
  64. - uses: actions/upload-artifact@v4
  65. with:
  66. name: companion-macos-x64
  67. path: '*.tar.gz'
  68. linux-x64:
  69. name: Linux x64
  70. if: contains(github.event.inputs.targets, 'linux-x64')
  71. runs-on: ubuntu-latest
  72. steps:
  73. - uses: actions/checkout@v4
  74. - uses: dtolnay/rust-toolchain@stable
  75. with:
  76. targets: x86_64-unknown-linux-gnu
  77. - name: Install system dependencies
  78. run: |
  79. sudo apt-get update
  80. sudo apt-get install -y libgtk-3-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev
  81. - name: Build companion
  82. working-directory: companion
  83. run: cargo build --release --target x86_64-unknown-linux-gnu
  84. - name: Package companion
  85. run: |
  86. set -euo pipefail
  87. version='${{ github.event.inputs.version }}'
  88. target='x86_64-unknown-linux-gnu'
  89. name="oh-my-opencode-slim-companion-v${version}-${target}"
  90. mkdir -p dist
  91. cp "companion/target/${target}/release/oh-my-opencode-slim-companion" dist/oh-my-opencode-slim-companion
  92. tar -C dist -czf "${name}.tar.gz" oh-my-opencode-slim-companion
  93. - uses: actions/upload-artifact@v4
  94. with:
  95. name: companion-linux-x64
  96. path: '*.tar.gz'
  97. linux-arm64:
  98. name: Linux arm64
  99. if: contains(github.event.inputs.targets, 'linux-arm64')
  100. runs-on: ubuntu-24.04-arm
  101. steps:
  102. - uses: actions/checkout@v4
  103. - uses: dtolnay/rust-toolchain@stable
  104. with:
  105. targets: aarch64-unknown-linux-gnu
  106. - name: Install system dependencies
  107. run: |
  108. sudo apt-get update
  109. sudo apt-get install -y libgtk-3-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev
  110. - name: Build companion
  111. working-directory: companion
  112. run: cargo build --release --target aarch64-unknown-linux-gnu
  113. - name: Package companion
  114. run: |
  115. set -euo pipefail
  116. version='${{ github.event.inputs.version }}'
  117. target='aarch64-unknown-linux-gnu'
  118. name="oh-my-opencode-slim-companion-v${version}-${target}"
  119. mkdir -p dist
  120. cp "companion/target/${target}/release/oh-my-opencode-slim-companion" dist/oh-my-opencode-slim-companion
  121. tar -C dist -czf "${name}.tar.gz" oh-my-opencode-slim-companion
  122. - uses: actions/upload-artifact@v4
  123. with:
  124. name: companion-linux-arm64
  125. path: '*.tar.gz'
  126. windows-x64:
  127. name: Windows x64
  128. if: contains(github.event.inputs.targets, 'windows-x64')
  129. runs-on: windows-latest
  130. steps:
  131. - uses: actions/checkout@v4
  132. - uses: dtolnay/rust-toolchain@stable
  133. with:
  134. targets: x86_64-pc-windows-msvc
  135. - name: Build companion
  136. working-directory: companion
  137. run: cargo build --release --target x86_64-pc-windows-msvc
  138. - name: Package companion
  139. shell: pwsh
  140. run: |
  141. $version = '${{ github.event.inputs.version }}'
  142. $target = 'x86_64-pc-windows-msvc'
  143. $name = "oh-my-opencode-slim-companion-v$version-$target"
  144. New-Item -ItemType Directory -Force -Path dist | Out-Null
  145. Copy-Item "companion/target/$target/release/oh-my-opencode-slim-companion.exe" "dist/oh-my-opencode-slim-companion.exe"
  146. Compress-Archive -Path "dist/oh-my-opencode-slim-companion.exe" -DestinationPath "$name.zip" -Force
  147. - uses: actions/upload-artifact@v4
  148. with:
  149. name: companion-windows-x64
  150. path: '*.zip'
  151. release:
  152. name: Publish companion release
  153. needs:
  154. - macos-arm64
  155. - macos-x64
  156. - linux-x64
  157. - linux-arm64
  158. - windows-x64
  159. if: always() && !cancelled() && !failure()
  160. runs-on: ubuntu-latest
  161. steps:
  162. - uses: actions/checkout@v4
  163. - uses: actions/download-artifact@v4
  164. with:
  165. path: artifacts
  166. merge-multiple: true
  167. - name: Create or update GitHub release
  168. env:
  169. GH_TOKEN: ${{ github.token }}
  170. VERSION: ${{ github.event.inputs.version }}
  171. run: |
  172. set -euo pipefail
  173. tag="companion-v${VERSION}"
  174. if ! gh release view "$tag" >/dev/null 2>&1; then
  175. gh release create "$tag" \
  176. --title "Companion v${VERSION}" \
  177. --notes "Manual companion binary release for oh-my-opencode-slim."
  178. fi
  179. gh release upload "$tag" artifacts/* --clobber