git-nav 0.2.2

Fast interactive TUI to list local git repositories and jump into one.
Documentation
name: release

# Triggered by pushing a version tag, e.g. `git tag v0.2.1 && git push --tags`.
# Builds one binary per target, packages it as a tarball, and attaches the
# tarballs (plus SHA-256 checksums) to a GitHub Release.
#
# Publishing to crates.io is intentionally left manual — run `cargo publish`
# yourself once you're happy with a release. To automate it later, add a
# CARGO_REGISTRY_TOKEN secret and uncomment the `publish-crates` job below.

on:
  push:
    tags: ["v*"]

permissions:
  contents: write

jobs:
  build:
    name: build / ${{ matrix.target }}
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          # Both Darwin targets cross-compile from the ARM `macos-latest`
          # pool. GitHub's Intel `macos-13` pool has long queues on public
          # repos, and Apple's own clang/ld can emit for either arch with
          # no extra tooling — `rustup target add` (done by the toolchain
          # step below) just fetches the right prebuilt libstd.
          - target: x86_64-apple-darwin
            os: macos-latest
          - target: aarch64-apple-darwin
            os: macos-latest
          - target: x86_64-unknown-linux-gnu
            os: ubuntu-latest
          - target: aarch64-unknown-linux-gnu
            os: ubuntu-latest
            linker: aarch64-linux-gnu-gcc
            apt: gcc-aarch64-linux-gnu

    steps:
      - uses: actions/checkout@v7

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

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

      - name: Install cross-linker (aarch64 linux only)
        if: matrix.apt
        run: |
          sudo apt-get update
          sudo apt-get install -y ${{ matrix.apt }}
          mkdir -p .cargo
          {
            echo "[target.${{ matrix.target }}]"
            echo "linker = \"${{ matrix.linker }}\""
          } >> .cargo/config.toml

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

      - name: Package
        id: pkg
        shell: bash
        run: |
          VERSION="${GITHUB_REF_NAME#v}"
          NAME="git-nav-${VERSION}-${{ matrix.target }}"
          mkdir -p "dist/${NAME}"
          cp "target/${{ matrix.target }}/release/git-nav" "dist/${NAME}/"
          cp README.md LICENSE-MIT LICENSE-APACHE "dist/${NAME}/"
          ( cd dist && tar -czf "${NAME}.tar.gz" "${NAME}" )
          ( cd dist && shasum -a 256 "${NAME}.tar.gz" > "${NAME}.tar.gz.sha256" )
          echo "asset=dist/${NAME}.tar.gz" >> "$GITHUB_OUTPUT"
          echo "checksum=dist/${NAME}.tar.gz.sha256" >> "$GITHUB_OUTPUT"

      - name: Upload artifacts
        uses: actions/upload-artifact@v7
        with:
          name: ${{ matrix.target }}
          path: |
            ${{ steps.pkg.outputs.asset }}
            ${{ steps.pkg.outputs.checksum }}
          retention-days: 7

  release:
    name: publish github release
    needs: build
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7

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

      - name: Create GitHub Release
        uses: softprops/action-gh-release@v3
        with:
          files: |
            dist/*.tar.gz
            dist/*.sha256
          generate_release_notes: true
          fail_on_unmatched_files: true

  # ---------------------------------------------------------------------------
  # Uncomment once you've added a CARGO_REGISTRY_TOKEN secret in
  # repo Settings → Secrets and variables → Actions.
  # ---------------------------------------------------------------------------
  # publish-crates:
  #   name: publish to crates.io
  #   needs: release
  #   runs-on: ubuntu-latest
  #   steps:
  #     - uses: actions/checkout@v7
  #     - uses: dtolnay/rust-toolchain@stable
  #     - run: cargo publish --locked --token ${{ secrets.CARGO_REGISTRY_TOKEN }}