mirror of
https://github.com/uutils/red.git
synced 2026-06-10 16:14:42 -07:00
171 lines
4.6 KiB
YAML
171 lines
4.6 KiB
YAML
name: Release
|
|
|
|
on:
|
|
push:
|
|
tags:
|
|
- 'v*'
|
|
|
|
env:
|
|
CARGO_TERM_COLOR: always
|
|
|
|
jobs:
|
|
build:
|
|
name: Build ${{ matrix.name }}
|
|
runs-on: ${{ matrix.os }}
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include:
|
|
# Linux musl (static, portable)
|
|
- name: linux-x86_64-musl
|
|
os: ubuntu-latest
|
|
target: x86_64-unknown-linux-musl
|
|
artifact: red-linux-x86_64-musl
|
|
features: ""
|
|
cross: true
|
|
|
|
- name: linux-aarch64-musl
|
|
os: ubuntu-latest
|
|
target: aarch64-unknown-linux-musl
|
|
artifact: red-linux-aarch64-musl
|
|
features: ""
|
|
cross: true
|
|
|
|
# Linux gnu with SELinux
|
|
- name: linux-x86_64-gnu-selinux
|
|
os: ubuntu-latest
|
|
target: x86_64-unknown-linux-gnu
|
|
artifact: red-linux-x86_64-gnu-selinux
|
|
features: "selinux"
|
|
cross: false
|
|
|
|
- name: linux-aarch64-gnu-selinux
|
|
os: ubuntu-latest
|
|
target: aarch64-unknown-linux-gnu
|
|
artifact: red-linux-aarch64-gnu-selinux
|
|
features: "selinux"
|
|
cross: true
|
|
|
|
# macOS
|
|
- name: darwin-x86_64
|
|
os: macos-15-intel
|
|
target: x86_64-apple-darwin
|
|
artifact: red-darwin-x86_64
|
|
features: ""
|
|
cross: false
|
|
|
|
- name: darwin-aarch64
|
|
os: macos-latest
|
|
target: aarch64-apple-darwin
|
|
artifact: red-darwin-aarch64
|
|
features: ""
|
|
cross: false
|
|
|
|
# Windows
|
|
- name: windows-x86_64
|
|
os: windows-latest
|
|
target: x86_64-pc-windows-msvc
|
|
artifact: red-windows-x86_64
|
|
features: ""
|
|
cross: false
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Set up Rust
|
|
uses: dtolnay/rust-toolchain@stable
|
|
with:
|
|
targets: ${{ matrix.target }}
|
|
|
|
- name: Install cross
|
|
if: matrix.cross
|
|
run: cargo install cross --git https://github.com/cross-rs/cross
|
|
|
|
- name: Install SELinux dependencies
|
|
if: contains(matrix.features, 'selinux') && !matrix.cross
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y libselinux1-dev
|
|
|
|
- name: Build with cargo
|
|
if: ${{ !matrix.cross }}
|
|
working-directory: ./red
|
|
run: |
|
|
if [ -n "${{ matrix.features }}" ]; then
|
|
cargo build --release --target ${{ matrix.target }} --features ${{ matrix.features }}
|
|
else
|
|
cargo build --release --target ${{ matrix.target }}
|
|
fi
|
|
shell: bash
|
|
|
|
- name: Build with cross
|
|
if: matrix.cross
|
|
working-directory: ./red
|
|
run: |
|
|
if [ -n "${{ matrix.features }}" ]; then
|
|
cross build --release --target ${{ matrix.target }} --features ${{ matrix.features }}
|
|
else
|
|
cross build --release --target ${{ matrix.target }}
|
|
fi
|
|
shell: bash
|
|
|
|
- name: Package (Unix)
|
|
if: runner.os != 'Windows'
|
|
run: |
|
|
cd red/target/${{ matrix.target }}/release
|
|
tar -czvf ${{ matrix.artifact }}.tar.gz red
|
|
mv ${{ matrix.artifact }}.tar.gz ../../../../
|
|
|
|
- name: Package (Windows)
|
|
if: runner.os == 'Windows'
|
|
run: |
|
|
cd red/target/${{ matrix.target }}/release
|
|
7z a ${{ matrix.artifact }}.zip red.exe
|
|
mv ${{ matrix.artifact }}.zip ../../../../
|
|
shell: bash
|
|
|
|
- name: Upload artifact
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: ${{ matrix.artifact }}
|
|
path: |
|
|
${{ matrix.artifact }}.tar.gz
|
|
${{ matrix.artifact }}.zip
|
|
|
|
release:
|
|
name: Create Release
|
|
needs: build
|
|
runs-on: ubuntu-latest
|
|
permissions:
|
|
contents: write
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Download all artifacts
|
|
uses: actions/download-artifact@v4
|
|
with:
|
|
path: artifacts
|
|
|
|
- name: Prepare release files
|
|
run: |
|
|
mkdir -p release
|
|
find artifacts -type f \( -name "*.tar.gz" -o -name "*.zip" \) -exec mv {} release/ \;
|
|
ls -la release/
|
|
|
|
- name: Generate checksums
|
|
run: |
|
|
cd release
|
|
sha256sum * > SHA256SUMS.txt
|
|
cat SHA256SUMS.txt
|
|
|
|
- name: Create Release
|
|
uses: softprops/action-gh-release@v2
|
|
with:
|
|
files: |
|
|
release/*
|
|
generate_release_notes: true
|
|
draft: false
|
|
prerelease: ${{ contains(github.ref, '-') }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|