name: Rust
on:
push:
branches: [ "main" ]
tags:
- 'v*'
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ${{ matrix.os }}
container: ${{ matrix.container }}
if: github.ref_type != 'tag'
strategy:
matrix:
platform: [ubuntu, fedora, macos, windows]
include:
- platform: ubuntu
os: ubuntu-latest
- platform: fedora
os: ubuntu-latest
container: fedora:latest
- platform: macos
os: macos-latest
- platform: windows
os: windows-latest
steps:
- name: Install dependencies (Fedora)
if: matrix.container == 'fedora:latest'
run: |
dnf install -y git curl gcc make sqlite-devel
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Format check
run: cargo fmt -- --check
- name: Clippy
run: cargo clippy -- -D warnings
- name: Build
run: cargo build --verbose
- name: Run tests
run: cargo test --verbose
- name: Run fetcher (dry run)
run: cargo run -- --long
- name: Print system_profiler SPDisplaysDataType (macOS)
if: matrix.os == 'macos-latest'
run: system_profiler SPDisplaysDataType
full-test:
runs-on: ubuntu-latest
if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v')
strategy:
matrix:
container:
- ubuntu:latest
- fedora:latest
container: ${{ matrix.container }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Install Rust toolchain (Ubuntu)
if: matrix.container == 'ubuntu:latest'
run: |
apt-get update
apt-get install -y curl build-essential pandoc
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Install Rust toolchain (Fedora)
if: matrix.container == 'fedora:latest'
run: |
dnf install -y curl gcc make pandoc
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Build (release)
run: cargo build --release --verbose
- name: Run tests (all features)
run: cargo test --all-features --verbose
- name: Clippy
run: cargo clippy -- -D warnings
- name: Format check
run: cargo fmt -- --check
- name: Generate man page
run: just man || echo "Man page generation skipped (just may not be installed)"
build-release:
needs: full-test
runs-on: ubuntu-latest
container: fedora:latest
if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v')
steps:
- name: Install system dependencies (Fedora)
run: |
dnf install -y git curl gcc make pandoc sqlite-devel
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Install Rust toolchain
run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" >> $GITHUB_PATH
- name: Build release binary
run: |
$HOME/.cargo/bin/cargo build --release --verbose
- name: Prepare release assets
run: |
mkdir -p release
cp target/release/retch release/
cp docs/retch.1 release/ || true
- name: Upload release assets
uses: actions/upload-artifact@v4
with:
name: release-assets
path: release/
release:
needs: build-release
runs-on: ubuntu-latest
if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- name: Download release assets
uses: actions/download-artifact@v4
with:
name: release-assets
path: release
- name: Create Release
uses: softprops/action-gh-release@b4309332981a82ec1c5618f44dd2e27cc8bfbfda
with:
tag_name: ${{ github.ref_name }}
name: retch ${{ github.ref_name }}
draft: false
prerelease: false
files: |
release/retch
release/retch.1
generate_release_notes: true