name: Release
on:
push:
tags:
- "*"
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
jobs:
release:
name: Cross build for ${{ matrix.target }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: ubuntu-latest
target: x86_64-unknown-linux-gnu
exe: rgrc
- os: ubuntu-latest
target: x86_64-unknown-linux-musl
exe: rgrc
- os: ubuntu-latest
target: aarch64-unknown-linux-musl
exe: rgrc
- os: ubuntu-latest
target: i686-unknown-linux-musl
exe: rgrc
- os: ubuntu-latest
target: arm-unknown-linux-musleabihf
exe: rgrc
- os: macos-latest
target: x86_64-apple-darwin
exe: rgrc
- os: macos-latest
target: aarch64-apple-darwin
exe: rgrc
- os: ubuntu-latest
target: x86_64-unknown-freebsd
exe: rgrc
- os: windows-latest
target: x86_64-pc-windows-msvc
exe: rgrc.exe
- os: windows-latest
target: i686-pc-windows-msvc
exe: rgrc.exe
- os: windows-latest
target: aarch64-pc-windows-msvc
exe: rgrc.exe
steps:
- uses: actions/checkout@v6
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: ${{ matrix.target }}
- name: Install cross
if: matrix.os == 'ubuntu-latest'
run: cargo install --version 0.2.5 cross
- name: Run tests (Linux)
if: matrix.os == 'ubuntu-latest' && contains(matrix.target, 'linux')
run: cross test --release --target ${{ matrix.target }} --verbose
- name: Run tests (macOS/Windows)
if: matrix.os != 'ubuntu-latest' && startsWith(matrix.target, 'x86_64')
run: cargo test --release --target ${{ matrix.target }} --verbose
- name: Build release (Linux)
if: matrix.os == 'ubuntu-latest'
run: cross build --release --features embed-configs,debug --target ${{ matrix.target }}
- name: Build release (macOS/Windows)
if: matrix.os != 'ubuntu-latest'
run: cargo build --release --features embed-configs,debug --target ${{ matrix.target }}
- name: Package release (non-Windows)
if: matrix.os != 'windows-latest'
shell: bash
run: |
set -euo pipefail
TARGET=${{ matrix.target }}
EXE="${{ matrix.exe }}"
DIR=target/${{ matrix.target }}/release
# Ensure the executable exists
ls -lah "$DIR" || true
# Create an unversioned archive matching installer expectations:
# rgrc-<target>.tar.gz
tar czf "$DIR/rgrc-${TARGET}.tar.gz" -C "$DIR" rgrc
- name: Package release (Windows)
if: matrix.os == 'windows-latest'
shell: pwsh
run: |
$TARGET = '${{ matrix.target }}'
$EXE = 'rgr*.exe'
$DIR = "target/${{ matrix.target }}/release"
# Use ${} to avoid accidental variable-token parsing when followed by punctuation
Write-Output "Files in ${DIR}`n"
Get-ChildItem -Path $DIR | Write-Output
# Create an unversioned zip matching installer expectations: rgrc-<target>.zip
Compress-Archive -Path "$DIR/$EXE" -DestinationPath "$DIR/rgrc-$TARGET.zip" -Force
- name: Upload artifact (non-Windows)
if: matrix.os != 'windows-latest'
uses: actions/upload-artifact@v5
with:
name: rgrc-${{ matrix.target }}.tar.gz
path: target/${{ matrix.target }}/release/rgrc-${{ matrix.target }}.tar.gz
- name: Upload artifact (Windows)
if: matrix.os == 'windows-latest'
uses: actions/upload-artifact@v5
with:
name: rgrc-${{ matrix.target }}.zip
path: target/${{ matrix.target }}/release/rgrc-${{ matrix.target }}.zip
data:
name: Package data files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Generate man page
run: |
# pandoc is required by the Makefile to generate the man page
sudo apt-get update
sudo apt-get install -y pandoc
make man
- name: Package data files
run: make data
- uses: actions/upload-artifact@v5
with:
name: rgrc-data.tar.gz
path: target/tarball/rgrc-data.tar.gz
deb:
name: Build Debian packages
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu, armv7-unknown-linux-gnueabihf, i686-unknown-linux-gnu]
fail-fast: false
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Install base system dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential pkg-config curl ca-certificates git libssl-dev dpkg-dev gzip
- name: Set up Rust toolchain
uses: actions-rs/toolchain@v1
with:
toolchain: stable
profile: minimal
override: true
- name: Generate Man Page gzip
run: gzip -fk doc/rgrc.1
- name: Install cargo-deb
run: cargo install --locked cargo-deb
- name: Add Rust target
run: rustup target add ${{ matrix.target }}
- name: Install cross toolchain for aarch64
if: matrix.target == 'aarch64-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu binutils-aarch64-linux-gnu
echo "CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
echo "CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc" >> $GITHUB_ENV
- name: Install cross toolchain for armv7 (armhf)
if: matrix.target == 'armv7-unknown-linux-gnueabihf'
run: |
sudo apt-get update
sudo apt-get install -y gcc-arm-linux-gnueabihf binutils-arm-linux-gnueabihf
echo "CC_armv7_unknown_linux_gnueabihf=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
echo "CARGO_TARGET_ARMV7_UNKNOWN_LINUX_GNUEABIHF_LINKER=arm-linux-gnueabihf-gcc" >> $GITHUB_ENV
- name: Install cross toolchain for i686
if: matrix.target == 'i686-unknown-linux-gnu'
run: |
sudo apt-get update
sudo apt-get install -y gcc-multilib g++-multilib libc6-dev-i386
echo "CC_i686_unknown_linux_gnu=gcc" >> $GITHUB_ENV
echo "CARGO_TARGET_I686_UNKNOWN_LINUX_GNU_LINKER=gcc" >> $GITHUB_ENV
- name: Build project and generate deb for target
env:
PREFIX: /usr/local
run: |
cargo deb --target ${{ matrix.target }} --no-default-features
- name: Find deb artifacts
run: |
echo 'Listing created .deb artifacts:'
find target -type f -name "*.deb" -print || true
- name: Get version
shell: bash
run: |
VERSION=$(grep '^version =' Cargo.toml | head -1 | sed 's/version = "\(.*\)"/\1/')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Upload built .deb artifacts
uses: actions/upload-artifact@v5
with:
name: rgrc-${{ env.VERSION }}-${{ matrix.target }}.deb
path: |
target/debian/*.deb
publish:
name: Publish release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs: [release, data, deb]
steps:
- name: Download all artifacts
uses: actions/download-artifact@v6
with:
path: artifacts
- name: List artifacts
run: |
# List only release assets we intend to attach to the GitHub release
find artifacts -type f \( -name "*.zip" -o -name "*.tar.gz" -o -name "*.deb" \) | sort
- name: Create release
uses: softprops/action-gh-release@v2
with:
files: |
artifacts/**/*.{zip,tar.gz,deb}
generate_release_notes: true
draft: true
publish-crate:
name: Publish to crates.io
if: startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
needs: publish
steps:
- uses: actions/checkout@v6
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
- name: Publish
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_API_TOKEN }}
run: cargo publish