git-worktree-manager 0.1.14

Lean git worktree manager with AI coding-assistant integration
Documentation
name: Release Please

on:
  push:
    branches:
      - main
  workflow_dispatch:
    inputs:
      tag_name:
        description: "Existing tag to (re)build and publish (e.g. v0.1.0). Skips release-please; runs build/upload/publish against this tag. Use --ref <tag> to check out source at that tag."
        required: true
        type: string

permissions:
  contents: write
  pull-requests: write

env:
  CARGO_TERM_COLOR: always

jobs:
  release-please:
    if: github.event_name == 'push'
    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@v5
        id: release
        with:
          # Prefer a maintainer-supplied PAT (repo secret
          # `RELEASE_PLEASE_TOKEN`, fine-grained with `Contents: r/w` +
          # `Pull requests: r/w` on this repo; or classic with `repo`)
          # so release-please's push to the release-PR branch triggers
          # normal `pull_request` CI. GitHub Actions suppresses
          # workflow re-runs on pushes made by the default
          # `GITHUB_TOKEN`, which leaves the release PR permanently
          # BLOCKED on required status checks (close-and-reopen is the
          # manual workaround). When the secret is unset, fall back to
          # `GITHUB_TOKEN` so the workflow still functions — just
          # without auto-triggered CI on the release PR.
          token: ${{ secrets.RELEASE_PLEASE_TOKEN || secrets.GITHUB_TOKEN }}
          config-file: release-please-config.json
          manifest-file: .release-please-manifest.json

  resolve-release:
    needs: release-please
    if: |
      always() &&
      ((github.event_name == 'push' && needs.release-please.outputs.release_created == 'true') ||
       github.event_name == 'workflow_dispatch')
    runs-on: ubuntu-latest
    outputs:
      tag_name: ${{ steps.pick.outputs.tag_name }}
    steps:
      - id: pick
        run: |
          if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
            echo "tag_name=${{ inputs.tag_name }}" >> "$GITHUB_OUTPUT"
          else
            echo "tag_name=${{ needs.release-please.outputs.tag_name }}" >> "$GITHUB_OUTPUT"
          fi

  build:
    needs: resolve-release
    if: ${{ !cancelled() && needs.resolve-release.result == 'success' }}
    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: 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
          cd ../../..

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

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

  upload-assets:
    needs: [resolve-release, build]
    if: ${{ !cancelled() && needs.resolve-release.result == 'success' && needs.build.result == 'success' }}
    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.resolve-release.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.resolve-release.outputs.tag_name }}

      - name: Bump Formula/git-worktree-manager.rb in DaveDev42/homebrew-tap
        uses: DaveDev42/homebrew-tap-release@v1
        with:
          formula-name: git-worktree-manager
          version: ${{ needs.resolve-release.outputs.tag_name }}
          download-url: https://github.com/DaveDev42/git-worktree-manager/releases/download/${{ needs.resolve-release.outputs.tag_name }}/gw-aarch64-apple-darwin.tar.gz
          tap-token: ${{ secrets.HOMEBREW_TAP_TOKEN }}

  publish-crate:
    needs: resolve-release
    if: ${{ !cancelled() && needs.resolve-release.result == 'success' }}
    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 }}