rgm_ui 0.5.1

A Rust GPU Monitor with egui UI for NVIDIA and AMD GPUs on Linux
name: Release

on:
  push:
    tags:
      - "v*"

permissions:
  contents: write

jobs:
  build-and-release:
    # The glibc the binary is linked against sets the floor for every user:
    # building on ubuntu-latest produced binaries requiring glibc 2.39, which
    # fail to start on Ubuntu 22.04 / Debian 12. Building inside a
    # rockylinux:9 container (glibc 2.34) covers RHEL 9 and every newer
    # distro, without depending on retiring runner labels
    # (actions/runner-images#14254).
    runs-on: ubuntu-latest
    container: rockylinux:9
    steps:
      - name: Install system dependencies
        run: dnf install -y gcc pkg-config systemd-devel jq git

      - uses: actions/checkout@v5
        with:
          fetch-depth: 0

      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable

      - name: Verify tag matches Cargo.toml version
        run: |
          CARGO_VERSION=$(cargo metadata --no-deps --format-version 1 | jq -r '.packages[0].version')
          TAG_VERSION="${GITHUB_REF_NAME#v}"
          if [ "$CARGO_VERSION" != "$TAG_VERSION" ]; then
            echo "::error::Tag ${GITHUB_REF_NAME} does not match Cargo.toml version ${CARGO_VERSION}. Bump Cargo.toml before tagging."
            exit 1
          fi

      - name: Install cargo-deb and cargo-generate-rpm
        run: |
          cargo install cargo-deb
          cargo install cargo-generate-rpm

      - name: Build release binary
        run: cargo build --release --locked

      - name: Build Debian package
        run: cargo deb

      - name: Build RPM package
        run: cargo generate-rpm

      - name: Collect artifacts and generate checksums
        run: |
          mkdir -p dist/rgm artifacts
          cp target/release/rgm LICENSE-MIT LICENSE-APACHE README.md dist/rgm/
          tar -czf artifacts/rgm-linux-x86_64.tar.gz -C dist rgm
          cp target/debian/*.deb target/generate-rpm/*.rpm artifacts/
          cd artifacts && sha256sum * > SHA256SUMS

      - name: Create Release
        uses: softprops/action-gh-release@v2
        if: startsWith(github.ref, 'refs/tags/')
        with:
          name: RGM ${{ github.ref_name }}
          body_path: .github/release-template.md
          generate_release_notes: true
          files: artifacts/*
          draft: false
          prerelease: false
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

      # Runs after the GitHub release so a publish failure never blocks
      # artifact delivery. Skips cleanly until the CARGO_REGISTRY_TOKEN
      # repository secret is configured.
      - name: Publish to crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: |
          if [ -z "$CARGO_REGISTRY_TOKEN" ]; then
            echo "::warning::CARGO_REGISTRY_TOKEN is not set; skipping crates.io publish"
            exit 0
          fi
          cargo publish --locked