Skip to content

Add build workflow

Add build workflow #1

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: Rename binary
shell: bash
run: |
cd target/${{ matrix.target }}/release
binary_name=$(ls | grep -E '^[^.]+$' || ls *.exe)
mv "$binary_name" "$binary_name-${{ matrix.suffix }}"
- name: Upload to release
uses: softprops/action-gh-release@v1
with:
tag_name: ${{ github.event.inputs.tag }}
files: target/${{ matrix.target }}/release/*-${{ matrix.suffix }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}