name: CI
on:
push:
branches: [main, master]
tags: ['v*']
pull_request:
branches: [main, master]
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: rustup default stable
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --all-targets
- name: Build
run: cargo build --all-targets
- name: Run tests
run: cargo test --all-targets
- name: Run doc tests
run: cargo test --doc
test-versions:
name: Test on ${{ matrix.rust }}
runs-on: ubuntu-latest
strategy:
matrix:
rust: [stable, beta, nightly]
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: rustup default ${{ matrix.rust }}
- name: Cache cargo
uses: Swatinem/rust-cache@v2
- name: Run tests
run: cargo test --all-targets
cross-build:
name: Cross-build ${{ matrix.platform }}
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- platform: macOS ARM64
runner: macos-14
target: aarch64-apple-darwin
- platform: Windows x86_64
runner: windows-latest
target: x86_64-pc-windows-msvc
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build example CLI
run: cargo build --release --example cli --target ${{ matrix.target }}
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: llm-wiki-lib-${{ matrix.platform }}
path: target/${{ matrix.target }}/release/examples/cli
retention-days: 1
publish:
name: Publish to crates.io
needs: [test, test-versions, cross-build]
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: rustup default stable
- name: Publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
cargo publish --token $CARGO_REGISTRY_TOKEN
release:
name: Upload to Release
needs: [cross-build]
if: startsWith(github.ref, 'refs/tags/') || github.event_name == 'release'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
- name: List artifacts
run: ls -lhR artifacts/
- name: Prepare binaries
run: |
mkdir -p dist
# Note: Linux musl, macOS x86_64, and Windows skipped due to CI constraints
# Only macOS ARM64 artifact is available
cp "artifacts/llm-wiki-lib-macOS ARM64/cli" dist/llm-wiki-lib-macos-arm64
chmod +x dist/llm-wiki-lib-macos-arm64
- name: SHA256 checksums
run: |
cd dist
sha256sum llm-wiki-lib-* > SHA256SUMS.txt
cat SHA256SUMS.txt
- name: Upload to release
env:
TAG: ${{ github.ref }}
GH_TOKEN: ${{ github.token }}
run: |
TAG_NAME="${TAG##refs/tags/}"
echo "Uploading to release: $TAG_NAME"
# Create release if it doesn't exist
gh release create "$TAG_NAME" --repo wbyanclaw/llm-wiki-lib --title "v0.1.5 Release" --notes "llm-wiki-lib v0.1.5" || true
# Upload artifacts (only macOS ARM64 available)
gh release upload "$TAG_NAME" dist/llm-wiki-lib-macos-arm64 --repo wbyanclaw/llm-wiki-lib --clobber
gh release upload "$TAG_NAME" dist/SHA256SUMS.txt --repo wbyanclaw/llm-wiki-lib --clobber