rip-cli 0.5.0

Fuzzy find and kill processes from your terminal
name: Release

on:
  push:
    tags:
      - "v*"
      - "[0-9]+.*"
  workflow_dispatch:
    
permissions:
  contents: write

env:
  CARGO_TERM_COLOR: always

jobs:
  build:
    name: Build ${{ matrix.target }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - target: x86_64-apple-darwin
            os: macos-15
          - target: aarch64-apple-darwin
            os: macos-15

    steps:
      - uses: actions/checkout@v4

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

      - name: Cache cargo
        uses: Swatinem/rust-cache@v2
        with:
          key: ${{ matrix.target }}

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

      - name: Package
        run: |
          cd target/${{ matrix.target }}/release
          tar czf ../../../rip-${{ matrix.target }}.tar.gz rip
          cd ../../..

      - name: Upload artifact
        uses: actions/upload-artifact@v4
        with:
          name: rip-${{ matrix.target }}
          path: rip-${{ matrix.target }}.tar.gz

  release:
    name: Release
    needs: build
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - name: Download all artifacts
        uses: actions/download-artifact@v4
        with:
          path: artifacts
          merge-multiple: true

      - name: List artifacts
        run: ls -la artifacts/

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v2
        with:
          files: artifacts/*
          generate_release_notes: true

      - name: Compute checksums
        run: |
          cd artifacts
          echo "ARM_SHA=$(sha256sum rip-aarch64-apple-darwin.tar.gz | cut -d' ' -f1)" >> $GITHUB_ENV
          echo "INTEL_SHA=$(sha256sum rip-x86_64-apple-darwin.tar.gz | cut -d' ' -f1)" >> $GITHUB_ENV

      - name: Checkout Homebrew tap
        uses: actions/checkout@v4
        with:
          repository: cesarferreira/homebrew-tap
          token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
          path: tap

      - name: Update formula
        run: |
          TAG=${GITHUB_REF_NAME}
          VERSION=${TAG#v}
          FORMULA=tap/Formula/rip.rb

          cat > $FORMULA << EOF
          class Rip < Formula
            desc "Fuzzy find and kill processes from your terminal"
            homepage "https://github.com/cesarferreira/rip"
            version "${VERSION}"
            license "MIT"

            on_macos do
              on_arm do
                url "https://github.com/cesarferreira/rip/releases/download/${TAG}/rip-aarch64-apple-darwin.tar.gz"
                sha256 "${ARM_SHA}"
              end
              on_intel do
                url "https://github.com/cesarferreira/rip/releases/download/${TAG}/rip-x86_64-apple-darwin.tar.gz"
                sha256 "${INTEL_SHA}"
              end
            end

            def install
              bin.install "rip"
            end

            test do
              system "#{bin}/rip", "--help"
            end
          end
          EOF

      - name: Commit and push tap
        run: |
          cd tap
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add Formula/rip.rb
          git commit -m "rip ${VERSION}"
          git push
        env:
          VERSION: ${{ github.ref_name }}