name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
env:
CARGO_TERM_COLOR: always
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [stable]
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: ${{ matrix.rust }}
- name: Install Linux dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libxcb-xfixes0-dev libxcb-shape0-dev
- name: Cache cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Check formatting
run: cargo fmt -- --check
- name: Run clippy
run: cargo clippy -- -D warnings
release:
name: Release
needs: test
runs-on: ${{ matrix.os }}
if: startsWith(github.ref, 'refs/tags/')
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
suffix: linux-x64
- os: windows-latest
target: x86_64-pc-windows-msvc
suffix: windows-x64.exe
- os: macos-latest
target: x86_64-apple-darwin
suffix: macos-x64
- os: macos-latest
target: aarch64-apple-darwin
suffix: macos-arm64
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install Linux dependencies
if: matrix.os == 'ubuntu-latest'
run: |
sudo apt-get update
sudo apt-get install -y libxcb-xfixes0-dev libxcb-shape0-dev
- name: Build release
run: cargo build --release --target ${{ matrix.target }}
- name: Package binary
shell: bash
run: |
if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
cp target/${{ matrix.target }}/release/claude-utils.exe claude-utils-${{ matrix.suffix }}
else
cp target/${{ matrix.target }}/release/claude-utils claude-utils-${{ matrix.suffix }}
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: claude-utils-${{ matrix.suffix }}
path: claude-utils-${{ matrix.suffix }}
- name: Create release
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
with:
files: claude-utils-${{ matrix.suffix }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}