gitsnitch 0.2.2

Lints your Git commit history against a declarative ruleset
name: Release
on:
  push:
    tags:
      - "v*"
  workflow_dispatch:

permissions:
  contents: write

jobs:
  release:
    strategy:
      fail-fast: false
      matrix:
        platform:
          - runs-on: ubuntu-24.04
            target: x86_64-unknown-linux-musl
          - runs-on: ubuntu-24.04
            target: aarch64-unknown-linux-musl
          - runs-on: ubuntu-24.04
            target: armv7-unknown-linux-musleabihf
          - runs-on: macos-latest
            target: x86_64-apple-darwin
          - runs-on: macos-latest
            target: aarch64-apple-darwin
          - runs-on: windows-latest
            target: aarch64-pc-windows-msvc
          - runs-on: windows-latest
            target: x86_64-pc-windows-msvc
    runs-on: ${{ matrix.platform.runs-on }}
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0

      - name: Generate changelog
        uses: orhun/git-cliff-action@v4
        with:
          config: cliff.toml
          args: --output CHANGELOG.md

      - name: Build
        uses: houseabsolute/actions-rust-cross@v1
        with:
          target: ${{ matrix.platform.target }}
          args: "--release"

      - name: Import GPG key
        id: import_gpg
        uses: crazy-max/ghaction-import-gpg@v7
        with:
          gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
          passphrase: ${{ secrets.GPG_PASSPHRASE }}

      - name: Sign binaries
        shell: bash
        run: |
          target_dir="target/${{ matrix.platform.target }}/release"
          binary_name="gitsnitch"

          case "${{ matrix.platform.target }}" in
            *windows*) binary_name="${binary_name}.exe" ;;
          esac

          gpg --batch --sign --detach-sign \
            --local-user "${{ steps.import_gpg.outputs.keyid }}" \
            "${target_dir}/${binary_name}"

          mv \
            "${target_dir}/${binary_name}.sig" \
            "gitsnitch-${{ matrix.platform.target }}.sig"

      - name: Release
        uses: houseabsolute/actions-rust-release@v0.0.7
        with:
          changes-file: CHANGELOG.md
          executable-name: gitsnitch
          target: ${{ matrix.platform.target }}
          action-gh-release-parameters: '{"token":"${{ secrets.GITHUB_TOKEN }}"}'

      - name: Upload detached signature
        uses: softprops/action-gh-release@v3
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          files: gitsnitch-${{ matrix.platform.target }}.sig

  release-macos-universal2:
    runs-on: macos-latest
    steps:
      - uses: actions/checkout@v6
        with:
          fetch-depth: 0

      - name: Generate changelog
        uses: orhun/git-cliff-action@v4
        with:
          config: cliff.toml
          args: --output CHANGELOG.md

      - name: Build x86_64 macOS binary
        uses: houseabsolute/actions-rust-cross@v1
        with:
          target: x86_64-apple-darwin
          args: "--release"

      - name: Build arm64 macOS binary
        uses: houseabsolute/actions-rust-cross@v1
        with:
          target: aarch64-apple-darwin
          args: "--release"

      - name: Create universal2 binary
        shell: bash
        run: |
          mkdir -p target/release
          lipo -create \
            target/x86_64-apple-darwin/release/gitsnitch \
            target/aarch64-apple-darwin/release/gitsnitch \
            -output target/release/gitsnitch
          chmod 755 target/release/gitsnitch

      - name: Import GPG key
        id: import_gpg_universal2
        uses: crazy-max/ghaction-import-gpg@v7
        with:
          gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
          passphrase: ${{ secrets.GPG_PASSPHRASE }}

      - name: Sign universal2 binary
        shell: bash
        run: |
          gpg --batch --sign --detach-sign \
            --local-user "${{ steps.import_gpg_universal2.outputs.keyid }}" \
            target/release/gitsnitch

          mv target/release/gitsnitch.sig gitsnitch-universal2-apple-darwin.sig

      - name: Release universal2 archive
        uses: houseabsolute/actions-rust-release@v0
        with:
          changes-file: CHANGELOG.md
          executable-name: gitsnitch
          archive-name: gitsnitch-macOS-universal2
          action-gh-release-parameters: '{"token":"${{ secrets.GITHUB_TOKEN }}"}'

      - name: Upload detached signature
        uses: softprops/action-gh-release@v3
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          files: gitsnitch-universal2-apple-darwin.sig