name: Release
on:
release:
types: [published]
jobs:
check:
uses: ./.github/workflows/check.yml
build-binaries:
name: Build binary (${{ matrix.target }})
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
artifact: granite-cli-linux-x86_64
- target: aarch64-unknown-linux-gnu
os: ubuntu-latest
artifact: granite-cli-linux-aarch64
- target: x86_64-apple-darwin
os: macos-latest
artifact: granite-cli-macos-x86_64
- target: aarch64-apple-darwin
os: macos-latest
artifact: granite-cli-macos-aarch64
- target: x86_64-pc-windows-msvc
os: windows-latest
artifact: granite-cli-windows-x86_64.exe
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 with:
toolchain: 1.99
targets: ${{ matrix.target }}
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6 with:
key: ${{ 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: Build release binary
run: cargo build --locked --release --target ${{ matrix.target }}
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER: aarch64-linux-gnu-gcc
- name: Rename binary (Unix)
if: matrix.os != 'windows-latest'
run: |
cp target/${{ matrix.target }}/release/granite-cli ${{ matrix.artifact }}
- name: Rename binary (Windows)
if: matrix.os == 'windows-latest'
run: |
cp target/${{ matrix.target }}/release/granite-cli.exe ${{ matrix.artifact }}
- name: Upload binary to release
uses: softprops/action-gh-release@efb35369e0ad2afab669f228072c1b0d510eae64 with:
files: ${{ matrix.artifact }}
publish:
name: Publish to crates.io
needs: build-binaries
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1
- uses: dtolnay/rust-toolchain@683b588c487a69d01f6c6ddf40f036ff682cc2c8 with:
toolchain: 1.99
- uses: Swatinem/rust-cache@6323deb102c322ba6fcbdcafc7e3dddab59af2b6
- name: Publish
run: ./scripts/publish.sh
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}