cargo-fresh 0.12.2

A Rust tool for checking and updating globally installed Cargo packages with interactive mode and smart prerelease detection
Documentation
name: CI

on:
  push:
    branches: [master]
  pull_request:
    branches: [master]

env:
  CARGO_TERM_COLOR: always
  RUSTFLAGS: "-D warnings"

jobs:
  check:
    name: Check / Clippy / Test (stable)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy
      - uses: Swatinem/rust-cache@v2
      - run: cargo check --all-targets
      - run: cargo clippy --all-targets -- -D warnings
      - run: cargo test

  changelog-sync:
    name: CHANGELOG matches Cargo.toml version
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      # release.yml 在 tag push 时硬要求 CHANGELOG 有对应版本节,缺失就 fail——
      # 这里把检查提前到 PR/master push,避免发版那一刻才发现忘了写 changelog。
      - name: Verify CHANGELOG has a section for Cargo.toml version
        run: |
          VERSION=$(awk -F'"' '/^version *=/ {print $2; exit}' Cargo.toml)
          if [ -z "$VERSION" ]; then
            echo "::error::could not parse version from Cargo.toml"
            exit 1
          fi
          ESCAPED="${VERSION//./\\.}"
          if ! grep -qE "^## \[${ESCAPED}\]" CHANGELOG.md; then
            echo "::error::Cargo.toml is at $VERSION but CHANGELOG.md has no '## [$VERSION]' section. Move [Unreleased] content to a dated section before tagging."
            exit 1
          fi
          echo "OK: CHANGELOG.md contains a section for $VERSION"

  msrv:
    name: MSRV (1.88)
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: dtolnay/rust-toolchain@master
        with:
          toolchain: "1.88.0"
      - uses: Swatinem/rust-cache@v2
        with:
          key: msrv
      # MSRV check 只验证 src/(lib + bin)能编译——`--all-targets` 会拉 dev-deps,
      # 它们的 MSRV 与我们承诺给用户的 MSRV 无关。
      - run: cargo check --locked --lib --bins