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-build:
name: Build image (${{ matrix.arch }})
runs-on: ${{ matrix.runner }}
strategy:
fail-fast: false
matrix:
include:
- platform: linux/amd64
runner: ubuntu-latest
arch: amd64
- platform: linux/arm64
runner: ubuntu-24.04-arm
arch: arm64
steps:
- uses: actions/checkout@v7
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- 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 }}
- name: Build and push by digest
id: build
uses: docker/build-push-action@v7
with:
context: .
platforms: ${{ matrix.platform }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=ghcr.io/${{ github.repository }},push-by-digest=true,name-canonical=true,push=true
cache-from: type=gha,scope=${{ matrix.arch }}
cache-to: type=gha,mode=max,scope=${{ matrix.arch }}
build-args: |
ENABLE_AWS_CLI=true
ENABLE_AZURE_CLI=true
- name: Export digest
run: |
mkdir -p /tmp/digests
touch "/tmp/digests/${digest#sha256:}"
env:
digest: ${{ steps.build.outputs.digest }}
- name: Upload digest
uses: actions/upload-artifact@v7
with:
name: digests-${{ matrix.arch }}
path: /tmp/digests/*
if-no-files-found: error
retention-days: 1
docker-manifest:
name: Publish multi-arch manifest
runs-on: ubuntu-latest
needs: [docker-build]
steps:
- name: Download digests
uses: actions/download-artifact@v8
with:
path: /tmp/digests
pattern: digests-*
merge-multiple: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v4
- 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: Create manifest list and push
working-directory: /tmp/digests
run: |
docker buildx imagetools create \
$(jq -cr '.tags | map("-t " + .) | join(" ")' <<< '${{ steps.meta.outputs.json }}') \
$(printf 'ghcr.io/${{ github.repository }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect \
ghcr.io/${{ github.repository }}:${{ steps.meta.outputs.version }}
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 }}