Skip to content

Add build workflow

Add build workflow #2

Workflow file for this run

name: Build and Upload Release Binaries
on:
workflow_dispatch:
inputs:
tag:
description: 'Release tag to build for'
required: true
pull_request:
branches:
- '**' # TODO: remove
jobs:
build-and-upload:
name: ${{ matrix.os }} build
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
suffix: linux-x86_64
- os: ubuntu-latest
target: aarch64-unknown-linux-gnu
suffix: linux-aarch64
- os: macos-latest
target: x86_64-apple-darwin
suffix: macos-x86_64
- os: macos-latest
target: aarch64-apple-darwin
suffix: macos-aarch64
- os: windows-latest
target: x86_64-pc-windows-msvc
suffix: windows-x86_64.exe
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.inputs.tag }}
- 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: Build binary
run: cargo build --release --target ${{ matrix.target }}
- name: Get binary name from Cargo.toml
shell: bash
run: |
BINARY_NAME=$(grep -m1 '^name' Cargo.toml | cut -d'"' -f2 | cut -d"'" -f2)
echo "BINARY_NAME=$BINARY_NAME" >> $GITHUB_ENV
- name: Rename binary
shell: bash
run: |
cd target/${{ matrix.target }}/release
if [[ "${{ runner.os }}" == "Windows" ]]; then
mv "${{ env.BINARY_NAME }}.exe" "${{ env.BINARY_NAME }}-${{ matrix.suffix }}"
else
mv "${{ env.BINARY_NAME }}" "${{ env.BINARY_NAME }}-${{ matrix.suffix }}"
fi
- name: Upload to release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.tag }}
files: target/${{ matrix.target }}/release/${{ env.BINARY_NAME }}-${{ matrix.suffix }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}