opencode-voice 0.1.4

A cli utility to control opencode using voice via the HTTP API
Documentation
name: CI / Release

on:
  push:
    branches: ["main"]
  pull_request:
    branches: ["main"]
  workflow_dispatch:
    inputs:
      version:
        description: "Version bump type"
        required: true
        type: choice
        options:
          - patch
          - minor
          - major

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    strategy:
      matrix:
        os: [ubuntu-latest, macos-latest]
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
      - name: Install system dependencies (Linux)
        if: runner.os == 'Linux'
        run: sudo apt-get update && sudo apt-get install -y libasound2-dev libx11-dev libxi-dev libxtst-dev
      - name: Build
        run: cargo build --verbose
      - name: Run tests
        run: cargo test --verbose

  publish:
    name: Publish to crates.io
    needs: [build]
    if: github.event_name == 'workflow_dispatch'
    runs-on: ubuntu-latest
    environment: release
    permissions:
      id-token: write
      contents: write
    outputs:
      version: ${{ steps.version.outputs.version }}
    steps:
      - uses: actions/checkout@v4
      - name: Install system dependencies
        run: sudo apt-get update && sudo apt-get install -y libasound2-dev libx11-dev libxi-dev libxtst-dev
      - name: Install Rust stable
        uses: dtolnay/rust-toolchain@stable
      - name: Configure git
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
      - name: Bump version
        id: version
        run: |
          current=$(grep '^version = ' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
          IFS='.' read -r major minor patch <<< "$current"
          case "${{ inputs.version }}" in
            major) major=$((major + 1)); minor=0; patch=0 ;;
            minor) minor=$((minor + 1)); patch=0 ;;
            patch) patch=$((patch + 1)) ;;
          esac
          new="${major}.${minor}.${patch}"
          sed -i "0,/^version = \".*\"/s//version = \"${new}\"/" Cargo.toml
          echo "version=${new}" >> "$GITHUB_OUTPUT"
      - name: Update lockfile
        run: cargo update --workspace
      - name: Commit and tag
        run: |
          git add Cargo.toml Cargo.lock
          git commit -m "chore: release v${{ steps.version.outputs.version }}"
          git tag "v${{ steps.version.outputs.version }}"
          git push --follow-tags
      - name: Authenticate with crates.io
        uses: rust-lang/crates-io-auth-action@v1
        id: auth
      - name: Publish to crates.io
        run: cargo publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}

  release-binaries:
    name: Release binaries
    needs: publish
    if: github.event_name == 'workflow_dispatch'
    strategy:
      matrix:
        include:
          - os: ubuntu-latest
            artifact: opencode-voice-linux-x86_64
          - os: macos-latest
            artifact: opencode-voice-macos-aarch64
    runs-on: ${{ matrix.os }}
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v4
        with:
          ref: main
      - name: Install system dependencies (Linux)
        if: runner.os == 'Linux'
        run: sudo apt-get update && sudo apt-get install -y libasound2-dev libx11-dev libxi-dev libxtst-dev
      - name: Install Rust stable
        uses: dtolnay/rust-toolchain@stable
      - name: Build release binary
        run: cargo build --release
      - name: Package binary
        run: |
          mkdir -p dist
          cp target/release/opencode-voice dist/${{ matrix.artifact }}
          chmod +x dist/${{ matrix.artifact }}
      - name: Upload to GitHub release
        uses: softprops/action-gh-release@v2
        with:
          tag_name: v${{ needs.publish.outputs.version }}
          files: dist/${{ matrix.artifact }}