name: Release
on:
push:
tags: ["v*"]
permissions:
contents: write
jobs:
build:
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
use_cross: false
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
use_cross: true
- target: x86_64-apple-darwin
os: macos-14
use_cross: false
- target: aarch64-apple-darwin
os: macos-latest
use_cross: false
- target: x86_64-pc-windows-msvc
os: windows-latest
use_cross: false
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross
if: matrix.use_cross
run: cargo install cross --version 0.2.5
- name: Build (cross)
if: matrix.use_cross
run: cross build --release --target ${{ matrix.target }}
env:
CROSS_CONTAINER_ENGINE: docker
- name: Build (cargo)
if: "!matrix.use_cross"
run: cargo build --release --target ${{ matrix.target }}
- name: Package (Unix)
if: runner.os != 'Windows'
run: tar czf agent-doc-${{ matrix.target }}.tar.gz -C target/${{ matrix.target }}/release agent-doc
- name: Package (Windows)
if: runner.os == 'Windows'
shell: pwsh
run: Compress-Archive -Path target/${{ matrix.target }}/release/agent-doc.exe -DestinationPath agent-doc-${{ matrix.target }}.zip
- name: Upload artifact (Unix)
if: runner.os != 'Windows'
uses: actions/upload-artifact@v4
with:
name: agent-doc-${{ matrix.target }}
path: agent-doc-${{ matrix.target }}.tar.gz
- name: Upload artifact (Windows)
if: runner.os == 'Windows'
uses: actions/upload-artifact@v4
with:
name: agent-doc-${{ matrix.target }}
path: agent-doc-${{ matrix.target }}.zip
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: true
- name: Create release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_REPO: ${{ github.repository }}
run: |
tag="${GITHUB_REF#refs/tags/}"
if gh release view "$tag" >/dev/null 2>&1; then
echo "Release $tag already exists — uploading assets only"
gh release upload "$tag" artifacts/* --clobber
else
gh release create "$tag" \
--title "agent-doc $tag" \
--generate-notes \
artifacts/*
fi