zipatch-rs 1.2.0

Parser for FFXIV ZiPatch patch files
Documentation
name: CI

on:
  push:
    branches: [main]
  pull_request:
    branches: [main]

env:
  CARGO_TERM_COLOR: always

jobs:
  msrv:
    name: MSRV
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
    steps:
      - uses: actions/checkout@v6.0.2
      - uses: dtolnay/rust-toolchain@1.85
      - uses: Swatinem/rust-cache@v2.9.1
      - run: cargo test --features test-utils

  test:
    name: Test
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
    steps:
      - uses: actions/checkout@v6.0.2
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2.9.1
      - run: cargo test --features test-utils

  clippy:
    name: Clippy
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        os: [ubuntu-latest, windows-latest, macos-latest]
    steps:
      - uses: actions/checkout@v6.0.2
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - uses: Swatinem/rust-cache@v2.9.1
      - run: cargo clippy --features test-utils -- -D warnings

  fmt:
    name: Format
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6.0.2
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt
      - uses: Swatinem/rust-cache@v2.9.1
      - run: cargo fmt --check

  audit:
    name: Audit
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6.0.2
      - uses: dtolnay/rust-toolchain@stable
      - run: cargo generate-lockfile
      - uses: taiki-e/install-action@cargo-audit
      - run: cargo audit

  version-bump:
    name: Version bump
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6.0.2
        with:
          fetch-depth: 0
      - name: Check version was incremented if source changed
        run: |
          if [ "${{ github.event_name }}" != "pull_request" ] || [ "${{ github.base_ref }}" != "main" ]; then
            echo "Not a PR targeting main — skipping version check."
            exit 0
          fi
          # Version bumps are only required on `release/*` PRs. Day-to-day
          # `chore/`, `feature/`, `bug/`, `hotfix/`, and `docs/` PRs accumulate
          # changes under `[Unreleased]` in CHANGELOG.md and land on `main`
          # without touching Cargo.toml; the release workflow's idempotent
          # tag/release/publish checks make those no-op merges skip cleanly.
          # A separate `release/vX.Y.Z` PR bumps the version and renames
          # `[Unreleased]` → `[X.Y.Z]` when you're ready to ship.
          if [[ "${{ github.head_ref }}" != release/* ]]; then
            echo "Not a release/* branch — version bump not required."
            exit 0
          fi
          # Only require a bump when Rust source actually changed; infra/docs-only
          # PRs (workflows, CLAUDE.md, README, bundled rustdoc) don't need a release.
          if ! git diff --name-only origin/main...HEAD | grep -qE '\.rs$'; then
            echo "No .rs files changed; version bump not required."
            exit 0
          fi
          base=$(git show origin/main:Cargo.toml | grep '^version' | head -1)
          head=$(grep '^version' Cargo.toml | head -1)
          if [ "$base" = "$head" ]; then
            echo "Rust source changed but version in Cargo.toml was not bumped (still $head). Increment it before merging to main."
            exit 1
          fi
          echo "Version bumped: $base → $head"

  coverage:
    name: Coverage
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6.0.2
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2.9.1
      - uses: taiki-e/install-action@cargo-tarpaulin
      - run: cargo tarpaulin --features test-utils --out Xml
      - uses: codecov/codecov-action@v6.0.0
        with:
          fail_ci_if_error: true
          token: ${{ secrets.CODECOV_TOKEN }}