mirror of
https://github.com/awfufu/traudit
synced 2026-03-01 05:29:44 +08:00
77 lines
2.4 KiB
YAML
77 lines
2.4 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: write
|
|
|
|
jobs:
|
|
build-and-release:
|
|
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 }}
|
|
|
|
- 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/release
|
|
cp target/${{ matrix.target }}/release/traudit target/release/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
|