Files
traudit/.github/workflows/release.yml

92 lines
2.8 KiB
YAML

name: Release
on:
push:
tags:
- 'v*'
workflow_dispatch:
permissions:
contents: write
jobs:
test:
name: Run Tests
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Run Tests
# Docker is pre-installed on ubuntu-latest, so testcontainers will work automatically.
run: cargo test
build-and-release:
needs: test
name: Build and Release
runs-on: ubuntu-latest
strategy:
matrix:
include:
# The target name ending in '-musl' guarantees static linking against musl libc
- target: x86_64-unknown-linux-musl
arch: amd64
- target: aarch64-unknown-linux-musl
arch: arm64
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
targets: ${{ matrix.target }}
- name: Install Cross
run: cargo install cross --git https://github.com/cross-rs/cross
- name: Install Packaging Tools
run: |
cargo install cargo-deb
cargo install cargo-generate-rpm
- name: Build
# 'cross' handles the containerized build environment for the specified target (musl)
run: cross build --release --target ${{ matrix.target }} --features static-musl
- name: Prepare Packaging Assets
run: |
# Move binary to expected location for cargo-deb and cargo-generate-rpm which read Cargo.toml assets
mkdir -p target/package_tmp
cp target/${{ matrix.target }}/release/traudit target/package_tmp/traudit
- name: Package DEB
run: |
cargo deb --target ${{ matrix.target }} --no-build --output target/${{ matrix.target }}/debian/traudit_${{ matrix.arch }}.deb
- name: Package RPM
run: |
cargo generate-rpm --target ${{ matrix.target }} --output target/${{ matrix.target }}/rpm/traudit-${{ matrix.arch }}.rpm
- name: Package Tarball
run: |
# Copy extra files to release dir to bundle them
cp config_example.yaml target/${{ matrix.target }}/release/config.yaml
cp traudit.service target/${{ matrix.target }}/release/
cd target/${{ matrix.target }}/release
tar -czvf traudit-${{ matrix.target }}.tar.gz traudit config.yaml traudit.service
mv traudit-${{ matrix.target }}.tar.gz ../../../
- name: Upload Release Assets
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
target/${{ matrix.target }}/debian/*.deb
target/${{ matrix.target }}/rpm/*.rpm
traudit-${{ matrix.target }}.tar.gz