hfile 0.5.0

Hfile is a command-line interface (CLI) tool for generating hash values of files
Documentation
---
name: deploy

on:
  push:
    tags:
      - '*'
  workflow_dispatch:

permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always

jobs:
  test:
    uses: ./.github/workflows/test.yml

  release:
    name: Release
    runs-on: ubuntu-latest
    needs: test
    permissions:
      contents: write
    steps:
      - name: Checkout code
        uses: actions/checkout@v6
        with:
          ref: ${{ github.ref }}

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

      - name: Cache Rust build artifacts
        uses: Swatinem/rust-cache@v2

      - name: Install packaging tools
        run: cargo install cargo-deb cargo-generate-rpm --locked

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

      - name: Compress binary
        run: gzip -f -k target/release/hfile

      - name: Build DEB package
        run: cargo deb --no-build

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

      - name: Upload release artifacts
        if: startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref_name, 't')
        uses: softprops/action-gh-release@v2
        with:
          generate_release_notes: true
          files: |
            target/release/hfile.gz
            target/debian/*.deb
            target/generate-rpm/*.rpm

  publish:
    name: Publish
    runs-on: ubuntu-latest
    needs:
      - release
    if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && !startsWith(github.ref_name, 't')
    env:
      CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_TOKEN }}
    steps:
      - name: Checkout sources
        uses: actions/checkout@v6
        with:
          ref: ${{ github.ref }}

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

      - name: Cache Rust build artifacts
        uses: Swatinem/rust-cache@v2

      - name: Publish crate
        run: cargo publish --locked

      - name: Deployment Summary
        if: success()
        run: |
          echo "::notice::Deployment completed successfully"
          echo "::notice::Published ${GITHUB_REF#refs/tags/} to crates.io"
          echo "::notice::GitHub release created with binary, RPM, and DEB artifacts"