context7-cli 0.2.4

Search library documentation from your terminal — zero runtime, bilingual (EN/PT), multi-key rotation
Documentation
name: Release

on:
  workflow_dispatch:
    inputs:
      dry_run:
        description: 'Dry run (não publica de verdade)'
        required: false
        default: 'true'
        type: boolean

concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: false

permissions:
  contents: read

env:
  CARGO_TERM_COLOR: always
  CARGO_INCREMENTAL: 0

jobs:
  validate:
    name: Validar antes de publicar
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Instalar toolchain Rust estável
        uses: dtolnay/rust-toolchain@stable
        with:
          components: rustfmt, clippy

      - name: Cache de dependências Rust
        uses: Swatinem/rust-cache@v2
        with:
          shared-key: ubuntu-stable-release

      - name: Verificar formatação
        run: cargo fmt --all --check

      - name: Clippy sem warnings
        run: cargo clippy --all-targets --all-features -- -D warnings

      - name: Testes completos
        run: cargo test --all-features

      - name: Documentação sem warnings
        run: cargo doc --no-deps --all-features
        env:
          RUSTDOCFLAGS: -D warnings

      - name: Dry-run de publicação
        run: cargo publish --dry-run

  build-matrix:
    name: Build release (${{ matrix.target }})
    needs: validate
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
        include:
          - os: ubuntu-latest
            target: x86_64-unknown-linux-gnu
          - os: ubuntu-latest
            target: x86_64-unknown-linux-musl
          - os: macos-latest
            target: aarch64-apple-darwin
          - os: macos-13
            target: x86_64-apple-darwin
          - os: windows-latest
            target: x86_64-pc-windows-msvc
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Instalar toolchain Rust estável
        uses: dtolnay/rust-toolchain@stable
        with:
          targets: ${{ matrix.target }}

      - name: Instalar musl-tools (Linux musl)
        if: matrix.target == 'x86_64-unknown-linux-musl'
        run: sudo apt-get update && sudo apt-get install -y musl-tools

      - name: Cache de dependências Rust
        uses: Swatinem/rust-cache@v2
        with:
          shared-key: ${{ matrix.os }}-${{ matrix.target }}-release

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

  publish:
    name: Publicar no crates.io
    needs: [validate, build-matrix]
    runs-on: ubuntu-latest
    if: ${{ github.event.inputs.dry_run == 'false' }}
    permissions:
      contents: read
    steps:
      - name: Checkout
        uses: actions/checkout@v4

      - name: Instalar toolchain Rust estável
        uses: dtolnay/rust-toolchain@stable

      - name: Cache de dependências Rust
        uses: Swatinem/rust-cache@v2
        with:
          shared-key: ubuntu-stable-publish

      - name: Publicar no crates.io
        run: cargo publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}