gitru 0.2.11

a lightweight, configurable Git commit message validation tool
Documentation
name: Rust Cross-Platform Release Build

on:
  push:
    tags:
      - "v*"

jobs:
  build:
    name: Build for ${{ matrix.target }}
    runs-on: ${{ matrix.os }}

    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
            archive: tar.gz

          - os: macos-latest
            target: x86_64-apple-darwin
            archive: zip

          - os: macos-latest
            target: aarch64-apple-darwin
            archive: zip

          - os: windows-latest
            target: x86_64-pc-windows-msvc
            archive: zip

    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
          fetch-tags: true

      # -----------------------------
      # Install OpenSSL (Linux)
      # -----------------------------
      - name: Install OpenSSL (Linux)
        if: runner.os == 'Linux'
        run: |
          sudo apt-get update
          sudo apt-get install -y libssl-dev pkg-config

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

      # -----------------------------
      # Build
      # -----------------------------
      - name: Build release binary
        run: cargo build --release --target ${{ matrix.target }}

      # -----------------------------
      # Prepare artifact
      # -----------------------------
      - name: Prepare artifact
        shell: bash
        run: |
          BIN_NAME="gitru"
          TARGET_DIR="target/${{ matrix.target }}/release"
          OUT_DIR="dist"
          mkdir -p "$OUT_DIR"

          if [[ "${{ matrix.os }}" == "windows-latest" ]]; then
            BIN_FILE="${BIN_NAME}.exe"
          else
            BIN_FILE="${BIN_NAME}"
          fi

          cp "$TARGET_DIR/$BIN_FILE" "$OUT_DIR/"

          ARCHIVE_NAME="${BIN_NAME}-${{ matrix.target }}.${{ matrix.archive }}"
          echo "ARCHIVE_NAME=$ARCHIVE_NAME" >> $GITHUB_ENV

      # -----------------------------
      # Archive
      # -----------------------------
      - name: Zip on Windows
        if: runner.os == 'Windows'
        run: powershell Compress-Archive -Path dist/* -DestinationPath $env:ARCHIVE_NAME

      - name: Zip/Tar on Unix
        if: runner.os != 'Windows'
        shell: bash
        run: |
          if [[ "${{ matrix.archive }}" == "zip" ]]; then
            zip -j "$ARCHIVE_NAME" dist/*
          else
            tar -czvf "$ARCHIVE_NAME" -C dist .
          fi

      # -----------------------------
      # Generate Release Notes
      # -----------------------------
      - name: Install git-cliff
        run: cargo install git-cliff

      - name: Generate Release Notes
        run: git-cliff --latest --strip header > RELEASE_NOTES.md

      # -----------------------------
      # Publish Release
      # -----------------------------
      - name: Create Release
        uses: softprops/action-gh-release@v2
        with:
          tag_name: ${{ github.ref_name }}
          name: ${{ github.ref_name }}
          body_path: RELEASE_NOTES.md
          files: ${{ env.ARCHIVE_NAME }}