semantic-diff 0.9.0

A terminal diff viewer with AI-powered semantic grouping (Claude CLI / Copilot)
Documentation
name: Release

on:
  push:
    tags:
      - "v*"

permissions:
  contents: write

jobs:
  build:
    strategy:
      matrix:
        include:
          - target: aarch64-apple-darwin
            os: macos-latest
          - target: x86_64-apple-darwin
            os: macos-latest
    runs-on: ${{ matrix.os }}
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}
      - name: Build
        run: cargo build --release --target ${{ matrix.target }}
      - name: Package
        run: |
          cd target/${{ matrix.target }}/release
          tar -czf semantic-diff-${{ github.ref_name }}-${{ matrix.target }}.tar.gz semantic-diff
          shasum -a 256 semantic-diff-${{ github.ref_name }}-${{ matrix.target }}.tar.gz > semantic-diff-${{ github.ref_name }}-${{ matrix.target }}.tar.gz.sha256
      - uses: actions/upload-artifact@v4
        with:
          name: semantic-diff-${{ matrix.target }}
          path: |
            target/${{ matrix.target }}/release/semantic-diff-${{ github.ref_name }}-${{ matrix.target }}.tar.gz
            target/${{ matrix.target }}/release/semantic-diff-${{ github.ref_name }}-${{ matrix.target }}.tar.gz.sha256

  release:
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v4
        with:
          merge-multiple: true
      - name: Create or update release
        env:
          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          GH_REPO: ${{ github.repository }}
        run: |
          # Upload binaries to the existing release (created by tag push)
          gh release upload ${{ github.ref_name }} \
            semantic-diff-${{ github.ref_name }}-aarch64-apple-darwin.tar.gz \
            semantic-diff-${{ github.ref_name }}-aarch64-apple-darwin.tar.gz.sha256 \
            semantic-diff-${{ github.ref_name }}-x86_64-apple-darwin.tar.gz \
            semantic-diff-${{ github.ref_name }}-x86_64-apple-darwin.tar.gz.sha256 \
            --clobber

  update-homebrew:
    needs: release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/download-artifact@v4
        with:
          merge-multiple: true
      - name: Read SHA256 sums
        id: sha
        run: |
          echo "arm64=$(cat semantic-diff-${{ github.ref_name }}-aarch64-apple-darwin.tar.gz.sha256 | awk '{print $1}')" >> "$GITHUB_OUTPUT"
          echo "x86_64=$(cat semantic-diff-${{ github.ref_name }}-x86_64-apple-darwin.tar.gz.sha256 | awk '{print $1}')" >> "$GITHUB_OUTPUT"
      - uses: actions/checkout@v4
        with:
          repository: alankyshum/homebrew-tap
          token: ${{ secrets.HOMEBREW_TAP_TOKEN }}
      - name: Update formula
        env:
          VERSION: ${{ github.ref_name }}
          SHA_ARM64: ${{ steps.sha.outputs.arm64 }}
          SHA_X86: ${{ steps.sha.outputs.x86_64 }}
        run: |
          VER="${VERSION#v}"
          cat > Formula/semantic-diff.rb << FORMULA
          class SemanticDiff < Formula
            desc "Terminal diff viewer with AI-powered semantic grouping via Claude CLI"
            homepage "https://github.com/alankyshum/semantic-diff"
            version "${VER}"
            license "MIT"

            on_macos do
              if Hardware::CPU.arm?
                url "https://github.com/alankyshum/semantic-diff/releases/download/${VERSION}/semantic-diff-${VERSION}-aarch64-apple-darwin.tar.gz"
                sha256 "${SHA_ARM64}"
              elsif Hardware::CPU.intel?
                url "https://github.com/alankyshum/semantic-diff/releases/download/${VERSION}/semantic-diff-${VERSION}-x86_64-apple-darwin.tar.gz"
                sha256 "${SHA_X86}"
              end
            end

            def install
              bin.install "semantic-diff"
            end

            test do
              assert_match "semantic-diff", shell_output("#{bin}/semantic-diff --help")
            end
          end
          FORMULA
          # Remove leading whitespace from heredoc
          sed -i 's/^          //' Formula/semantic-diff.rb
      - name: Commit and push
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add Formula/semantic-diff.rb
          git commit -m "Update semantic-diff to ${{ github.ref_name }}"
          git push