Skip to content

Release

Release #81

Workflow file for this run

name: Release
on:
push:
tags:
- v*
workflow_dispatch:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
strategy:
matrix:
include:
# Linux
- bin_target: naija
os: ubuntu-latest
target: x86_64-unknown-linux-gnu
- bin_target: naija
os: ubuntu-latest
target: aarch64-unknown-linux-gnu
# macOS
- bin_target: naija
os: macos-latest
target: x86_64-apple-darwin
- bin_target: naija
os: macos-latest
target: aarch64-apple-darwin
# Windows (x86_64 only)
- bin_target: naija
os: windows-latest
target: x86_64-pc-windows-msvc
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Install Rust toolchain
run: |
rustup toolchain install nightly --no-self-update --profile minimal --component rust-src
rustup target add ${{ matrix.target }}
- name: Install build dependencies for aarch64-unknown-linux-gnu
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: sudo apt-get update && sudo apt-get install -y gcc-aarch64-linux-gnu g++-aarch64-linux-gnu libc6-dev-arm64-cross
- name: Build release binary
run: |
cargo build --config .cargo/release.toml --release --target ${{ matrix.target }} --bin ${{ matrix.bin_target }}
- name: Set artifact name
id: artifact_info
run: |
VERSION=${{ github.event_name == 'workflow_dispatch' && format('nightly-{0}', github.run_number) || github.ref_name }}
NAME=${{ matrix.bin_target }}
TARGET=${{ matrix.target }}
ARTIFACT_NAME="$NAME-$VERSION-$TARGET"
echo "artifact_name=$ARTIFACT_NAME" >> $GITHUB_OUTPUT
- name: Archive binary (Windows)
if: matrix.os == 'windows-latest'
run: |
cd target/${{ matrix.target }}/release
7z a ../../../${{ steps.artifact_info.outputs.artifact_name }}.zip ${{ matrix.bin_target }}.exe
- name: Archive binary (Unix)
if: matrix.os != 'windows-latest'
run: tar -cJvf ${{ steps.artifact_info.outputs.artifact_name }}.tar.xz -C target/${{ matrix.target }}/release ${{ matrix.bin_target }}
- name: Generate checksum
id: checksum
run: |
if [ "${{ matrix.os }}" = "windows-latest" ]; then
sha256sum ${{ steps.artifact_info.outputs.artifact_name }}.zip > ${{ steps.artifact_info.outputs.artifact_name }}.sha256
echo "artifacts=${{ steps.artifact_info.outputs.artifact_name }}.zip ${{ steps.artifact_info.outputs.artifact_name }}.sha256" >> $GITHUB_OUTPUT
else
if command -v sha256sum >/dev/null 2>&1; then
sha256sum ${{ steps.artifact_info.outputs.artifact_name }}.tar.xz > ${{ steps.artifact_info.outputs.artifact_name }}.sha256
else
shasum -a 256 ${{ steps.artifact_info.outputs.artifact_name }}.tar.xz > ${{ steps.artifact_info.outputs.artifact_name }}.sha256
fi
echo "artifacts=${{ steps.artifact_info.outputs.artifact_name }}.tar.xz ${{ steps.artifact_info.outputs.artifact_name }}.sha256" >> $GITHUB_OUTPUT
fi
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: ${{ steps.artifact_info.outputs.artifact_name }}
path: ${{ steps.artifact_info.outputs.artifact_name }}.*
release:
name: ${{ github.event_name == 'workflow_dispatch' && 'Create nightly release' || 'Create release' }}
needs: build
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v5
with:
path: dist
- name: ${{ github.event_name == 'workflow_dispatch' && 'Create nightly release' || 'Create release' }}
uses: softprops/action-gh-release@v2
with:
name: ${{ github.event_name == 'workflow_dispatch' && format('Nightly Build {0}', github.run_number) || github.ref_name }}
tag_name: ${{ github.event_name == 'workflow_dispatch' && format('nightly-{0}', github.run_number) || github.ref_name }}
prerelease: ${{ github.event_name == 'workflow_dispatch' }}
generate_release_notes: ${{ github.event_name == 'push' }}
files: dist/**