name: Release
on:
push:
tags:
- 'v*'
permissions:
contents: write
jobs:
build:
name: Build (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- target: x86_64-unknown-linux-gnu
os: ubuntu-latest
ext: ''
platform: unknown-linux-gnu
- target: aarch64-unknown-linux-musl
os: ubuntu-latest
ext: ''
platform: unknown-linux-musl
- target: x86_64-pc-windows-msvc
os: windows-latest
ext: .exe
platform: pc-windows-msvc
- target: x86_64-apple-darwin
os: macos-latest
ext: ''
platform: apple-darwin
- target: aarch64-apple-darwin
os: macos-latest
ext: ''
platform: apple-darwin
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install cross-compilation tools
if: matrix.target == 'aarch64-unknown-linux-musl'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu musl-tools
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Build
shell: bash
run: |
if [ "${{ matrix.target }}" = "aarch64-unknown-linux-musl" ]; then
export CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER=aarch64-linux-gnu-gcc
fi
cargo build --release --target ${{ matrix.target }}
- name: Package
shell: bash
run: |
mkdir -p dist
if [ "${{ matrix.ext }}" = ".exe" ]; then
cp target/${{ matrix.target }}/release/gitcore.exe dist/gitcore.exe
cd dist
tar -czf ../gitcore-${{ matrix.target }}.tar.gz *
else
cp target/${{ matrix.target }}/release/gitcore dist/gitcore
cd dist
tar -czf ../gitcore-${{ matrix.target }}.tar.gz *
fi
- name: Upload Release Assets
uses: softprops/action-gh-release@v2
with:
files: gitcore-*.tar.gz
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}