name: Release
on:
push:
tags:
- "v*"
workflow_dispatch:
inputs:
tag:
description: "Release tag, for example v0.1.0"
required: true
type: string
permissions:
contents: write
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
archive: tar.gz
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
archive: tar.gz
- os: macos-13
target: x86_64-apple-darwin
archive: tar.gz
- os: macos-14
target: aarch64-apple-darwin
archive: tar.gz
- os: windows-latest
target: x86_64-pc-windows-msvc
archive: zip
- os: windows-latest
target: aarch64-pc-windows-msvc
archive: zip
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo
uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install Linux cross linker
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Configure Linux cross linker
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
mkdir -p .cargo
cat >> .cargo/config.toml <<'EOF'
[target.aarch64-unknown-linux-gnu]
linker = "aarch64-linux-gnu-gcc"
EOF
- name: Build
run: cargo build --release --features http --bin ferryllm --target ${{ matrix.target }}
- name: Package Unix
if: matrix.archive == 'tar.gz'
shell: bash
run: |
set -euo pipefail
tag="${GITHUB_REF_NAME}"
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
tag="${{ inputs.tag }}"
fi
name="ferryllm-${tag}-${{ matrix.target }}"
mkdir -p "dist/${name}"
cp "target/${{ matrix.target }}/release/ferryllm" "dist/${name}/"
cp README.md README.zh-CN.md LICENSE CHANGELOG.md "dist/${name}/"
tar -C dist -czf "dist/${name}.tar.gz" "${name}"
- name: Package Windows
if: matrix.archive == 'zip'
shell: pwsh
run: |
$tag = $env:GITHUB_REF_NAME
if ("${{ github.event_name }}" -eq "workflow_dispatch") {
$tag = "${{ inputs.tag }}"
}
$name = "ferryllm-$tag-${{ matrix.target }}"
New-Item -ItemType Directory -Force -Path "dist/$name" | Out-Null
Copy-Item "target/${{ matrix.target }}/release/ferryllm.exe" "dist/$name/"
Copy-Item README.md,README.zh-CN.md,LICENSE,CHANGELOG.md "dist/$name/"
Compress-Archive -Path "dist/$name" -DestinationPath "dist/$name.zip"
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ferryllm-${{ matrix.target }}
path: |
dist/*.tar.gz
dist/*.zip
if-no-files-found: error
release:
name: Publish GitHub Release
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Resolve release tag
id: tag
shell: bash
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "tag=${{ inputs.tag }}" >> "$GITHUB_OUTPUT"
else
echo "tag=${GITHUB_REF_NAME}" >> "$GITHUB_OUTPUT"
fi
- name: Create release
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.tag.outputs.tag }}
name: ferryllm ${{ steps.tag.outputs.tag }}
body_path: CHANGELOG.md
files: |
dist/*.tar.gz
dist/*.zip