name: Companion Release on: workflow_dispatch: inputs: version: description: 'Companion version, for example 0.1.0' required: true type: string targets: description: >- Comma-separated targets to build: macos-arm64,macos-x64,linux-x64,linux-arm64,windows-x64 required: true default: macos-arm64 type: string permissions: contents: write jobs: macos-arm64: name: macOS arm64 if: contains(github.event.inputs.targets, 'macos-arm64') runs-on: macos-latest steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: targets: aarch64-apple-darwin - name: Build companion working-directory: companion run: cargo build --release --target aarch64-apple-darwin - name: Package companion run: | set -euo pipefail version='${{ github.event.inputs.version }}' target='aarch64-apple-darwin' name="oh-my-opencode-slim-companion-v${version}-${target}" mkdir -p dist cp "companion/target/${target}/release/oh-my-opencode-slim-companion" dist/oh-my-opencode-slim-companion tar -C dist -czf "${name}.tar.gz" oh-my-opencode-slim-companion - uses: actions/upload-artifact@v4 with: name: companion-macos-arm64 path: '*.tar.gz' macos-x64: name: macOS x64 if: contains(github.event.inputs.targets, 'macos-x64') runs-on: macos-latest steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: targets: x86_64-apple-darwin - name: Build companion working-directory: companion run: cargo build --release --target x86_64-apple-darwin - name: Package companion run: | set -euo pipefail version='${{ github.event.inputs.version }}' target='x86_64-apple-darwin' name="oh-my-opencode-slim-companion-v${version}-${target}" mkdir -p dist cp "companion/target/${target}/release/oh-my-opencode-slim-companion" dist/oh-my-opencode-slim-companion tar -C dist -czf "${name}.tar.gz" oh-my-opencode-slim-companion - uses: actions/upload-artifact@v4 with: name: companion-macos-x64 path: '*.tar.gz' linux-x64: name: Linux x64 if: contains(github.event.inputs.targets, 'linux-x64') runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: targets: x86_64-unknown-linux-gnu - name: Install system dependencies run: | sudo apt-get update sudo apt-get install -y libgtk-3-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev - name: Build companion working-directory: companion run: cargo build --release --target x86_64-unknown-linux-gnu - name: Package companion run: | set -euo pipefail version='${{ github.event.inputs.version }}' target='x86_64-unknown-linux-gnu' name="oh-my-opencode-slim-companion-v${version}-${target}" mkdir -p dist cp "companion/target/${target}/release/oh-my-opencode-slim-companion" dist/oh-my-opencode-slim-companion tar -C dist -czf "${name}.tar.gz" oh-my-opencode-slim-companion - uses: actions/upload-artifact@v4 with: name: companion-linux-x64 path: '*.tar.gz' linux-arm64: name: Linux arm64 if: contains(github.event.inputs.targets, 'linux-arm64') runs-on: ubuntu-24.04-arm steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: targets: aarch64-unknown-linux-gnu - name: Install system dependencies run: | sudo apt-get update sudo apt-get install -y libgtk-3-dev libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev - name: Build companion working-directory: companion run: cargo build --release --target aarch64-unknown-linux-gnu - name: Package companion run: | set -euo pipefail version='${{ github.event.inputs.version }}' target='aarch64-unknown-linux-gnu' name="oh-my-opencode-slim-companion-v${version}-${target}" mkdir -p dist cp "companion/target/${target}/release/oh-my-opencode-slim-companion" dist/oh-my-opencode-slim-companion tar -C dist -czf "${name}.tar.gz" oh-my-opencode-slim-companion - uses: actions/upload-artifact@v4 with: name: companion-linux-arm64 path: '*.tar.gz' windows-x64: name: Windows x64 if: contains(github.event.inputs.targets, 'windows-x64') runs-on: windows-latest steps: - uses: actions/checkout@v4 - uses: dtolnay/rust-toolchain@stable with: targets: x86_64-pc-windows-msvc - name: Build companion working-directory: companion run: cargo build --release --target x86_64-pc-windows-msvc - name: Package companion shell: pwsh run: | $version = '${{ github.event.inputs.version }}' $target = 'x86_64-pc-windows-msvc' $name = "oh-my-opencode-slim-companion-v$version-$target" New-Item -ItemType Directory -Force -Path dist | Out-Null Copy-Item "companion/target/$target/release/oh-my-opencode-slim-companion.exe" "dist/oh-my-opencode-slim-companion.exe" Compress-Archive -Path "dist/oh-my-opencode-slim-companion.exe" -DestinationPath "$name.zip" -Force - uses: actions/upload-artifact@v4 with: name: companion-windows-x64 path: '*.zip' release: name: Publish companion release needs: - macos-arm64 - macos-x64 - linux-x64 - linux-arm64 - windows-x64 if: always() && !cancelled() && !failure() runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: path: artifacts merge-multiple: true - name: Create or update GitHub release env: GH_TOKEN: ${{ github.token }} VERSION: ${{ github.event.inputs.version }} run: | set -euo pipefail tag="companion-v${VERSION}" if ! gh release view "$tag" >/dev/null 2>&1; then gh release create "$tag" \ --title "Companion v${VERSION}" \ --notes "Manual companion binary release for oh-my-opencode-slim." fi gh release upload "$tag" artifacts/* --clobber