name: Rust
on:
push:
branches: [ "main" ]
tags:
- 'v*'
pull_request:
branches: [ "main" ]
env:
CARGO_TERM_COLOR: always
jobs:
build:
runs-on: ubuntu-latest
if: github.ref_type != 'tag'
steps:
- 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
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)"
release:
needs: full-test
runs-on: ubuntu-latest
if: github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v')
permissions:
contents: write
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
- name: Build release binary
run: cargo build --release
- name: Prepare release assets
run: |
mkdir -p release
cp target/release/retch release/
cp docs/retch.1 release/ || true
- 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