waveshare-ups-hat-e 0.1.3

A crate to monitor the status of a Waveshare UPS HAT E on a Raspberry Pi
Documentation
name: Build and Release

on:
  release:
    types: [published]
  workflow_dispatch:
    inputs:
      tag:
        description: 'Release tag to upload binaries to (e.g., 0.1.1)'
        required: true
        type: string

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    name: Build ${{ matrix.target }}
    runs-on: ubuntu-latest
    strategy:
      matrix:
        target:
          # Raspberry Pi 3/4/5 (64-bit)
          - aarch64-unknown-linux-musl
          # Raspberry Pi 2/3/4 (32-bit)
          - armv7-unknown-linux-musleabihf

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

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

      - name: Install cross
        run: cargo install cross --git https://github.com/cross-rs/cross

      - name: Build examples
        run: cross build --release --examples --target ${{ matrix.target }}

      - name: Rename binaries
        run: |
          cp target/${{ matrix.target }}/release/examples/ups_monitor ups_monitor-${{ matrix.target }}
          cp target/${{ matrix.target }}/release/examples/force_power_off force_power_off-${{ matrix.target }}

      - name: Generate checksums
        run: |
          sha256sum ups_monitor-${{ matrix.target }} > ups_monitor-${{ matrix.target }}.sha256
          sha256sum force_power_off-${{ matrix.target }} > force_power_off-${{ matrix.target }}.sha256

      - name: Upload binaries to release
        uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ inputs.tag || github.ref_name }}
          files: |
            ups_monitor-${{ matrix.target }}
            ups_monitor-${{ matrix.target }}.sha256
            force_power_off-${{ matrix.target }}
            force_power_off-${{ matrix.target }}.sha256