git-worktree-manager 0.0.39

CLI tool integrating git worktree with AI coding assistants
Documentation
name: Release Please

on:
  push:
    branches:
      - main

permissions:
  contents: write
  pull-requests: write

env:
  CARGO_TERM_COLOR: always

jobs:
  release-please:
    runs-on: ubuntu-latest
    outputs:
      release_created: ${{ steps.release.outputs.release_created }}
      tag_name: ${{ steps.release.outputs.tag_name }}
    steps:
      - uses: googleapis/release-please-action@v4
        id: release
        with:
          config-file: release-please-config.json
          manifest-file: .release-please-manifest.json

  build:
    needs: release-please
    if: ${{ needs.release-please.outputs.release_created }}
    strategy:
      matrix:
        include:
          - target: x86_64-unknown-linux-musl
            os: ubuntu-latest
            use_cross: true
          - target: aarch64-unknown-linux-musl
            os: ubuntu-latest
            use_cross: true
          - target: x86_64-apple-darwin
            os: macos-latest
            use_cross: false
          - target: aarch64-apple-darwin
            os: macos-latest
            use_cross: false
          - target: x86_64-pc-windows-msvc
            os: windows-latest
            use_cross: false

    runs-on: ${{ matrix.os }}

    steps:
      - uses: actions/checkout@v6

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

      - name: Install cross
        if: matrix.use_cross
        run: cargo install cross --git https://github.com/cross-rs/cross

      - name: Build
        run: |
          if [ "${{ matrix.use_cross }}" = "true" ]; then
            cross build --release --target ${{ matrix.target }}
          else
            cargo build --release --target ${{ matrix.target }}
          fi
        shell: bash

      - name: Package (Unix)
        if: matrix.os != 'windows-latest'
        run: |
          cd target/${{ matrix.target }}/release
          tar czf ../../../gw-${{ matrix.target }}.tar.gz gw cw
          cd ../../..

      - name: Package (Windows)
        if: matrix.os == 'windows-latest'
        run: |
          cd target/${{ matrix.target }}/release
          7z a ../../../gw-${{ matrix.target }}.zip gw.exe cw.exe
          cd ../../..
        shell: bash

      - name: Upload artifact
        uses: actions/upload-artifact@v7
        with:
          name: gw-${{ matrix.target }}
          path: gw-${{ matrix.target }}.*

  upload-assets:
    needs: [release-please, build]
    if: ${{ needs.release-please.outputs.release_created }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6

      - name: Download all artifacts
        uses: actions/download-artifact@v8
        with:
          path: artifacts

      - name: Generate SHA256 checksums
        run: |
          cd artifacts
          sha256sum gw-*/* > ../SHA256SUMS.txt
          cat ../SHA256SUMS.txt

      - name: Upload release assets
        uses: softprops/action-gh-release@v3
        with:
          tag_name: ${{ needs.release-please.outputs.tag_name }}
          files: |
            artifacts/gw-*/*
            SHA256SUMS.txt

      - name: Publish release
        run: gh release edit "$TAG" --draft=false
        env:
          GH_TOKEN: ${{ github.token }}
          TAG: ${{ needs.release-please.outputs.tag_name }}

      - name: Update Homebrew formula
        env:
          GH_TOKEN: ${{ secrets.HOMEBREW_TAP_TOKEN }}
          TAG: ${{ needs.release-please.outputs.tag_name }}
        run: |
          if [ -z "${GH_TOKEN}" ]; then
            echo "::warning::HOMEBREW_TAP_TOKEN not set, skipping formula update"
            exit 0
          fi

          VERSION="${TAG#v}"
          export VERSION
          export SHA_DARWIN_ARM64=$(grep -m1 'aarch64-apple-darwin' SHA256SUMS.txt | awk '{print $1}')
          export SHA_DARWIN_X86_64=$(grep -m1 'x86_64-apple-darwin' SHA256SUMS.txt | awk '{print $1}')
          export SHA_LINUX_ARM64=$(grep -m1 'aarch64-unknown-linux-musl' SHA256SUMS.txt | awk '{print $1}')
          export SHA_LINUX_X86_64=$(grep -m1 'x86_64-unknown-linux-musl' SHA256SUMS.txt | awk '{print $1}')

          for var in SHA_DARWIN_ARM64 SHA_DARWIN_X86_64 SHA_LINUX_ARM64 SHA_LINUX_X86_64; do
            if [ -z "${!var}" ]; then
              echo "::error::Failed to extract checksum for ${var}"
              exit 1
            fi
          done

          # Single-quoted heredoc preserves Ruby #{version}/#{bin},
          # envsubst replaces only the listed shell variables
          cat <<'FORMULA' | envsubst '$VERSION $SHA_DARWIN_ARM64 $SHA_DARWIN_X86_64 $SHA_LINUX_ARM64 $SHA_LINUX_X86_64' > /tmp/git-worktree-manager.rb
          class GitWorktreeManager < Formula
            desc "CLI tool integrating git worktree with AI coding assistants"
            homepage "https://github.com/DaveDev42/git-worktree-manager"
            version "$VERSION"
            license "BSD-3-Clause"

            on_macos do
              if Hardware::CPU.arm?
                url "https://github.com/DaveDev42/git-worktree-manager/releases/download/v#{version}/gw-aarch64-apple-darwin.tar.gz"
                sha256 "$SHA_DARWIN_ARM64"
              else
                url "https://github.com/DaveDev42/git-worktree-manager/releases/download/v#{version}/gw-x86_64-apple-darwin.tar.gz"
                sha256 "$SHA_DARWIN_X86_64"
              end
            end

            on_linux do
              if Hardware::CPU.arm?
                url "https://github.com/DaveDev42/git-worktree-manager/releases/download/v#{version}/gw-aarch64-unknown-linux-musl.tar.gz"
                sha256 "$SHA_LINUX_ARM64"
              else
                url "https://github.com/DaveDev42/git-worktree-manager/releases/download/v#{version}/gw-x86_64-unknown-linux-musl.tar.gz"
                sha256 "$SHA_LINUX_X86_64"
              end
            end

            def install
              bin.install "gw"
              bin.install "cw"
            end

            test do
              assert_match "gw #{version}", shell_output("#{bin}/gw --version")
            end
          end
          FORMULA

          git clone --branch main --single-branch https://github.com/DaveDev42/homebrew-tap.git /tmp/homebrew-tap
          cd /tmp/homebrew-tap
          git remote set-url origin "https://x-access-token:${GH_TOKEN}@github.com/DaveDev42/homebrew-tap.git"
          mkdir -p Formula
          cp /tmp/git-worktree-manager.rb Formula/git-worktree-manager.rb
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"
          git add Formula/git-worktree-manager.rb
          git commit -m "chore: update git-worktree-manager to ${VERSION}"
          git push || echo "::warning::Homebrew tap push failed (non-fatal)"

  publish-crate:
    needs: release-please
    if: ${{ needs.release-please.outputs.release_created }}
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6

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

      - name: Publish to crates.io
        run: cargo publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}