name: Release
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+*'
permissions:
contents: write
packages: write
jobs:
binaries:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
setup: sudo apt-get install -y musl-tools
- target: x86_64-apple-darwin
os: macos-latest
- target: aarch64-apple-darwin
os: macos-latest
- target: x86_64-pc-windows-msvc
os: windows-latest
ext: .exe
steps:
- uses: actions/checkout@v7
- name: Set up Rust stable
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install musl tools
if: matrix.setup
run: ${{ matrix.setup }}
- name: Build release binary (musl)
if: matrix.target == 'x86_64-unknown-linux-musl'
env:
OPENSSL_STATIC: '1'
run: cargo build --release --target ${{ matrix.target }} --all-features
- name: Build release binary
if: matrix.target != 'x86_64-unknown-linux-musl'
run: cargo build --release --target ${{ matrix.target }} --all-features
- name: Package (unix)
if: runner.os != 'Windows'
run: |
cd target/${{ matrix.target }}/release
tar czf ../../../llm-browser-testkit-${{ matrix.target }}.tar.gz llm-browser-testkit
- name: Package (windows)
if: runner.os == 'Windows'
run: |
cd target/${{ matrix.target }}/release
7z a ../../../llm-browser-testkit-${{ matrix.target }}.zip llm-browser-testkit.exe
- uses: actions/upload-artifact@v7
with:
name: ${{ matrix.target }}
path: llm-browser-testkit-${{ matrix.target }}.*
docker:
name: Build and push Docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Log in to GitHub Container Registry
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker meta
id: meta
uses: docker/metadata-action@v6
with:
images: ghcr.io/${{ github.repository }}
tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=ref,event=tag
flavor: |
latest=auto
- name: Build and push
uses: docker/build-push-action@v7
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
release:
name: Create GitHub release
runs-on: ubuntu-latest
needs: [binaries]
steps:
- uses: actions/download-artifact@v8
- name: Collect artifacts
run: |
mkdir dist
cp x86_64-unknown-linux-gnu/*.tar.gz dist/
cp x86_64-unknown-linux-musl/*.tar.gz dist/
cp x86_64-apple-darwin/*.tar.gz dist/
cp aarch64-apple-darwin/*.tar.gz dist/
cp x86_64-pc-windows-msvc/*.zip dist/
- name: Create GitHub release
uses: softprops/action-gh-release@v3
with:
files: dist/*
generate_release_notes: true
crates-io:
name: Publish to crates.io
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Set up Rust stable
uses: dtolnay/rust-toolchain@stable
- name: cargo publish
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}