name: release
on:
push:
tags: ["v*"]
env:
CARGO_TERM_COLOR: always
jobs:
verify:
name: verify
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.94.0
components: rustfmt, clippy
- uses: Swatinem/rust-cache@v2
- name: Check tag against Cargo.toml
run: |
version=$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n 1)
tag="${GITHUB_REF_NAME#v}"
if [ "$tag" != "$version" ]; then
echo "::error::tag $GITHUB_REF_NAME does not match Cargo.toml version $version"
exit 1
fi
- name: Test
run: cargo test --all-features --locked
- name: Clippy
run: cargo clippy --all-targets --all-features --locked -- -D warnings
- name: Format
run: cargo fmt --check
build:
name: build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
needs: verify
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
ext: ""
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
ext: ""
- os: ubuntu-24.04-arm
target: aarch64-unknown-linux-gnu
ext: ""
- os: macos-15
target: x86_64-apple-darwin
ext: ""
- os: macos-latest
target: aarch64-apple-darwin
ext: ""
- os: windows-11-arm
target: aarch64-pc-windows-msvc
ext: ".exe"
- os: windows-latest
target: x86_64-pc-windows-msvc
ext: ".exe"
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.94.0
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@v2
with:
key: ${{ matrix.target }}
- name: Install musl-tools
if: matrix.target == 'x86_64-unknown-linux-musl'
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Add target
run: rustup target add ${{ matrix.target }}
- name: Build release (core)
run: cargo build --release --locked --target ${{ matrix.target }}
- name: Strip binary (core)
if: runner.os != 'Windows'
run: strip target/${{ matrix.target }}/release/meta-ast${{ matrix.ext }}
- name: Build release (deploy)
env:
CARGO_TARGET_DIR: target-deploy
run: cargo build --release --locked --target ${{ matrix.target }} --features metacall-deploy
- name: Strip binary (deploy)
if: runner.os != 'Windows'
run: strip target-deploy/${{ matrix.target }}/release/meta-ast${{ matrix.ext }}
- name: Collect artifacts
shell: bash
run: |
mkdir -p release
cp target/${{ matrix.target }}/release/meta-ast${{ matrix.ext }} release/meta-ast-${{ matrix.target }}${{ matrix.ext }}
cp target-deploy/${{ matrix.target }}/release/meta-ast${{ matrix.ext }} release/meta-ast-${{ matrix.target }}-deploy${{ matrix.ext }}
- name: Upload core artifact
uses: actions/upload-artifact@v4
with:
name: meta-ast-${{ matrix.target }}
path: release/meta-ast-${{ matrix.target }}${{ matrix.ext }}
if-no-files-found: error
- name: Upload deploy artifact
uses: actions/upload-artifact@v4
with:
name: meta-ast-${{ matrix.target }}-deploy
path: release/meta-ast-${{ matrix.target }}-deploy${{ matrix.ext }}
if-no-files-found: error
release:
name: release
runs-on: ubuntu-latest
needs: [verify, build]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download all artifacts
uses: actions/download-artifact@v4
with:
path: artifacts
merge-multiple: false
- name: Generate release notes
id: changelog
uses: orhun/git-cliff-action@v4
with:
version: v2.14.1
config: cliff.toml
args: --current --strip header --offline
env:
OUTPUT: release-notes.md
- name: Create GitHub release
uses: softprops/action-gh-release@v2
with:
generate_release_notes: false
body_path: ${{ steps.changelog.outputs.changelog }}
files: |
artifacts/meta-ast-x86_64-unknown-linux-gnu/*
artifacts/meta-ast-x86_64-unknown-linux-musl/*
artifacts/meta-ast-aarch64-unknown-linux-gnu/*
artifacts/meta-ast-x86_64-apple-darwin/*
artifacts/meta-ast-aarch64-apple-darwin/*
artifacts/meta-ast-aarch64-pc-windows-msvc/*
artifacts/meta-ast-x86_64-pc-windows-msvc/*
artifacts/meta-ast-x86_64-unknown-linux-gnu-deploy/*
artifacts/meta-ast-x86_64-unknown-linux-musl-deploy/*
artifacts/meta-ast-aarch64-unknown-linux-gnu-deploy/*
artifacts/meta-ast-x86_64-apple-darwin-deploy/*
artifacts/meta-ast-aarch64-apple-darwin-deploy/*
artifacts/meta-ast-aarch64-pc-windows-msvc-deploy/*
artifacts/meta-ast-x86_64-pc-windows-msvc-deploy/*