name: Release
on:
push:
tags:
- 'v*'
env:
CARGO_TERM_COLOR: always
jobs:
audit:
name: Security Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache cargo-audit
uses: actions/cache@v5
with:
path: ~/.cargo/bin/cargo-audit
key: cargo-audit-0.21
- name: Install cargo-audit
run: command -v cargo-audit || cargo install cargo-audit --locked
- name: Run security audit
run: cargo audit
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-musl
os: ubuntu-latest
cross: false
features: prometheus
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
cross: true
features: prometheus
- target: aarch64-linux-android
os: ubuntu-latest
cross: true
features: prometheus
- target: aarch64-apple-darwin
os: macos-latest
cross: false
features: prometheus
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Cache cargo registry and git
uses: actions/cache@v5
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Install cross
if: matrix.cross
run: cargo install cross --version 0.2.5
- name: Install musl-tools
if: contains(matrix.target, 'musl')
run: sudo apt-get update && sudo apt-get install -y musl-tools
- name: Build (native)
if: ${{ !matrix.cross }}
run: cargo build --release --target ${{ matrix.target }} --features "${{ matrix.features }}"
- name: Build (cross)
if: matrix.cross
run: cross build --release --target ${{ matrix.target }} --features "${{ matrix.features }}"
- name: Package binary
shell: bash
run: |
cd target/${{ matrix.target }}/release
tar czvf ../../../xfr-${{ matrix.target }}.tar.gz xfr
cd -
- name: Upload artifact
uses: actions/upload-artifact@v6
with:
name: xfr-${{ matrix.target }}
path: xfr-${{ matrix.target }}.tar.gz
release:
name: Create Release
needs: [audit, build, completions]
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6
- name: Download all artifacts
uses: actions/download-artifact@v7
with:
path: artifacts
- name: List artifacts
run: find artifacts -type f
- name: Generate checksums
run: |
cd artifacts
find . -name "*.tar.gz" -exec mv {} . \;
sha256sum *.tar.gz > SHA256SUMS
cat SHA256SUMS
cd -
- name: Create Release
uses: softprops/action-gh-release@v2
with:
files: |
artifacts/*.tar.gz
artifacts/SHA256SUMS
artifacts/completions/completions.tar.gz
generate_release_notes: true
draft: false
prerelease: ${{ contains(github.ref, '-rc') || contains(github.ref, '-beta') || contains(github.ref, '-alpha') }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
completions:
name: Generate Shell Completions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Build
run: cargo build --release --features prometheus
- name: Generate completions
run: |
mkdir -p completions
./target/release/xfr --completions bash > completions/xfr.bash
./target/release/xfr --completions zsh > completions/_xfr
./target/release/xfr --completions fish > completions/xfr.fish
./target/release/xfr --completions powershell > completions/_xfr.ps1
tar czvf completions.tar.gz completions/
- name: Upload completions
uses: actions/upload-artifact@v6
with:
name: completions
path: completions.tar.gz