vaken 0.1.0

Tiny macOS menu bar utility to keep your Mac awake — Rust wrapper around `caffeinate`.
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]
  workflow_call:

env:
  RUST_BACKTRACE: 1
  CARGO_TERM_COLOR: always

# Vaken is macOS-only (wraps the macOS `caffeinate` command + sets the
# macOS-only LSUIElement Info.plist key). src/main.rs has a top-of-file
# `compile_error!` gate for non-macOS targets, so every compiling job
# below must run on macos-latest. Format checking does not invoke the
# compiler and could theoretically run on ubuntu, but keeping a single
# runner matches what an end user actually builds against.
jobs:
  fmt:
    name: Format
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt
      - run: cargo fmt --all -- --check

  clippy:
    name: Clippy
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - uses: Swatinem/rust-cache@v2
      - run: cargo clippy --all-targets -- -D warnings

  build:
    name: Build
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo build --release

  bundle:
    name: Bundle .app
    runs-on: macos-latest
    needs: build
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      # taiki-e/install-action fetches a precompiled cargo-bundle binary
      # rather than building from source — much faster than `cargo install`.
      - uses: taiki-e/install-action@v2
        with:
          tool: cargo-bundle
      - run: cargo bundle --release
      - uses: actions/upload-artifact@v4
        with:
          name: Vaken.app
          path: target/release/bundle/osx/Vaken.app
          if-no-files-found: error

  # Drift check: regenerate the badges that derive from Cargo.toml
  # (version, license) and fail if the committed SVGs are out of date.
  # Pure bash + sed + awk — no Rust toolchain needed, so ubuntu-latest
  # is fine and faster than macos.
  badges:
    name: Badges in sync
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - name: Regenerate derived badges
        run: ./scripts/update-badges.sh
      - name: Fail if badge drift
        run: |
          if ! git diff --exit-code .github/badges/; then
            echo ""
            echo "Badges are out of sync with Cargo.toml."
            echo "Locally run: ./scripts/update-badges.sh && git add .github/badges/ && git commit"
            exit 1
          fi