gpu-histop 0.1.0

High-resolution GPU history monitor for NVIDIA, AMDGPU, and Apple Silicon
Documentation
name: Release

on:
  push:
    tags:
      - "v*"

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always

jobs:
  create-release:
    name: Create GitHub release
    runs-on: ubuntu-latest
    steps:
      - name: Create release
        env:
          GH_TOKEN: ${{ github.token }}
          TAG: ${{ github.ref_name }}
        run: |
          gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1 || \
            gh release create "$TAG" --repo "$GITHUB_REPOSITORY" --title "$TAG" --generate-notes

  build:
    name: Build ${{ matrix.target }}
    needs: create-release
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            archive: tar.gz
          - os: macos-14
            target: aarch64-apple-darwin
            archive: tar.gz

    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Install Linux system dependencies
        if: runner.os == 'Linux'
        run: |
          sudo apt-get update
          sudo apt-get install -y libudev-dev libwayland-dev libx11-dev libxkbcommon-dev

      - name: Install Rust
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Build release binaries
        run: cargo build --release --target "${{ matrix.target }}"

      - name: Package archive
        shell: bash
        env:
          TARGET: ${{ matrix.target }}
          TAG: ${{ github.ref_name }}
        run: |
          set -euo pipefail
          name="gpu-histop-${TAG}-${TARGET}"
          mkdir -p "dist/${name}"
          cp "target/${TARGET}/release/gpu-histop" "dist/${name}/"
          cp "target/${TARGET}/release/gpu-histop-gui" "dist/${name}/"
          cp README.md LICENSE "dist/${name}/"
          tar -C dist -czf "${name}.tar.gz" "${name}"
          shasum -a 256 "${name}.tar.gz" > "${name}.tar.gz.sha256"

      - name: Upload release assets
        env:
          GH_TOKEN: ${{ github.token }}
          TAG: ${{ github.ref_name }}
        run: gh release upload "$TAG" gpu-histop-"$TAG"-${{ matrix.target }}.tar.gz* --repo "$GITHUB_REPOSITORY" --clobber