name: Release
on:
push:
tags:
- "v*"
jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
archive: tar.gz
- target: x86_64-apple-darwin
os: macos-latest
archive: tar.gz
- target: aarch64-apple-darwin
os: macos-latest
archive: tar.gz
- target: x86_64-pc-windows-msvc
os: windows-latest
archive: zip
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install cross-compilation tools
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu
- name: Configure cross-compilation
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
echo '[target.aarch64-unknown-linux-gnu]' >> ~/.cargo/config.toml
echo 'linker = "aarch64-linux-gnu-gcc"' >> ~/.cargo/config.toml
- name: Build
run: cargo build --release --target ${{ matrix.target }}
- name: Package (Unix)
if: matrix.archive == 'tar.gz'
run: |
cd target/${{ matrix.target }}/release
tar -czf toad-${{ github.ref_name }}-${{ matrix.target }}.tar.gz toad
mv toad-${{ github.ref_name }}-${{ matrix.target }}.tar.gz ../../../
- name: Package (Windows)
if: matrix.archive == 'zip'
run: |
cd target/${{ matrix.target }}/release
Compress-Archive -Path toad.exe -DestinationPath ../../../toad-${{ github.ref_name }}-${{ matrix.target }}.zip
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: toad-${{ matrix.target }}
path: toad-${{ github.ref_name }}-${{ matrix.target }}.${{ matrix.archive }}
release:
name: Create Release
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4
- name: Create GitHub Release
uses: softprops/action-gh-release@v2
with:
files: |
toad-x86_64-unknown-linux-gnu/toad-${{ github.ref_name }}-x86_64-unknown-linux-gnu.tar.gz
toad-aarch64-unknown-linux-gnu/toad-${{ github.ref_name }}-aarch64-unknown-linux-gnu.tar.gz
toad-x86_64-apple-darwin/toad-${{ github.ref_name }}-x86_64-apple-darwin.tar.gz
toad-aarch64-apple-darwin/toad-${{ github.ref_name }}-aarch64-apple-darwin.tar.gz
toad-x86_64-pc-windows-msvc/toad-${{ github.ref_name }}-x86_64-pc-windows-msvc.zip
generate_release_notes: true
publish-crate:
name: Publish to crates.io
needs: release
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Publish
run: cargo publish --token ${{ secrets.CARGO_REGISTRY_TOKEN }}