name: CI
on:
push:
branches: [master, main]
pull_request:
branches: [master, main]
workflow_dispatch:
permissions:
contents: read
env:
CARGO_TERM_COLOR: always
jobs:
rust:
name: Rust
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Vulkan loader
run: |
sudo apt-get update
sudo apt-get install --no-install-recommends -y libvulkan-dev
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
with:
components: clippy,rustfmt
- name: Cache Cargo
uses: Swatinem/rust-cache@v2
- name: Format
run: cargo fmt --all -- --check
- name: Check
run: cargo check --workspace --all-targets --locked
- name: Clippy
run: cargo clippy --workspace --all-targets --all-features --locked -- -D warnings
- name: Test
run: cargo test --workspace --all-targets --all-features --locked --no-fail-fast
- name: Check loaded feature
run: cargo check --workspace --all-targets --no-default-features --features loaded --locked
- name: Docs
run: cargo doc --workspace --all-features --no-deps --locked
env:
RUSTDOCFLAGS: -D warnings
- name: Verify generated files are committed
run: git diff --exit-code
portable-loaded:
name: Loaded Feature (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Cargo
uses: Swatinem/rust-cache@v2
- name: Check loaded feature
run: cargo check --workspace --all-targets --no-default-features --features loaded --locked
nix:
name: Nix Flake
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install Nix
uses: cachix/install-nix-action@v31
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
- name: Flake check
run: nix flake check --print-build-logs
release:
name: Release
runs-on: ubuntu-latest
needs: [rust, portable-loaded, nix]
if: github.event_name == 'push' && (github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main')
permissions:
contents: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Read version bump
id: version
env:
BEFORE_SHA: ${{ github.event.before }}
run: |
current="$(python3 -c 'import tomllib; print(tomllib.load(open("Cargo.toml", "rb"))["package"]["version"])')"
if previous_toml="$(git show "${BEFORE_SHA}:Cargo.toml" 2>/dev/null)"; then
previous="$(printf '%s' "${previous_toml}" | python3 -c 'import sys, tomllib; data=sys.stdin.buffer.read(); print(tomllib.loads(data.decode())["package"]["version"] if data else "")')"
else
previous=""
fi
tag="v${current}"
git fetch --tags --quiet
if [ "${current}" != "${previous}" ] && ! git rev-parse -q --verify "refs/tags/${tag}" >/dev/null; then
changed=true
else
changed=false
fi
echo "version=${current}" >> "$GITHUB_OUTPUT"
echo "tag=${tag}" >> "$GITHUB_OUTPUT"
echo "changed=${changed}" >> "$GITHUB_OUTPUT"
- name: Create GitHub release
if: steps.version.outputs.changed == 'true'
uses: softprops/action-gh-release@v2
with:
tag_name: ${{ steps.version.outputs.tag }}
target_commitish: ${{ github.sha }}
name: vkfetch-rs ${{ steps.version.outputs.tag }}
generate_release_notes: true