trauma 2.4.0

Simplify and prettify HTTP downloads
Documentation
name: ci

on:
  pull_request:
    types:
      - opened
      - synchronize
      - reopened
  push:
    branches:
      - main
    tags:
      - "[0-9]+.[0-9]+.[0-9]+"

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - name: Run the unit/doc tests
        run: cargo test
      - name: Test examples
        run: |
          EXAMPLES="simple
          with-report
          with-style
          with-resume
          "
          for example in $EXAMPLES; do
            echo "==== Testing $example ======================================="
            cargo run -q --example "$example"
            echo "============================================================="
          done

  lint:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: extractions/setup-just@v3
      - uses: dtolnay/rust-toolchain@stable
        with:
          components: clippy, rustfmt
      - uses: Swatinem/rust-cache@v2
      - run: cargo fmt --all -- --check
      - run: cargo check
      - run: cargo clippy -- -D warnings
      - name: Lint markdown
        run: just lint-md

  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - run: cargo build

  # Disabling this for now since it does not really add a lot of value but does
  # add a lot of CI time.
  # attest:
  #   needs:
  #     - build
  #     - lint
  #     - test
  #   runs-on: ubuntu-latest
  #   if: startsWith(github.ref, 'refs/tags/')
  #   steps:
  #     - uses: actions/checkout@v6
  #     - uses: dtolnay/rust-toolchain
  #       with:
  #         profile: minimal
  #         toolchain: stable
  #         override: true
  #     - uses: Swatinem/rust-cache@v2

  #     # Generate attestation.
  #     - uses: actions-rs/cargo@v1
  #       with:
  #         command: package
  #     - run: |
  #         mkdir -p dist
  #         cp target/package/*.crate dist/
  #     - name: Generate provenance
  #       uses: slsa-framework/github-actions-demo@v0.1
  #       with:
  #         artifact_path: dist/
  #         output_path: trauma.${{ github.sha }}.att

  #     # Sign the attestation.
  #     - uses: sigstore/cosign-installer@main
  #     - run: |
  #         export COSIGN_PASSWORD="${{ secrets.COSIGN_PASSWORD }}"
  #         echo -n "${{ secrets.COSIGN_KEY }}" > /tmp/cosign.key
  #         cosign sign-blob --key /tmp/cosign.key trauma.${{ github.sha }}.att > trauma.${{ github.sha }}.sig

  #     # Upload attestation files.
  #     - name: Upload provenance
  #       uses: actions/upload-artifact@v3
  #       with:
  #         path: |
  #           trauma.${{ github.sha }}.att
  #           trauma.${{ github.sha }}.sig

  release:
    needs:
      - build
      - lint
      - test
    runs-on: ubuntu-latest
    if: startsWith(github.ref, 'refs/tags/')
    steps:
      - uses: actions/checkout@v6
      - uses: dtolnay/rust-toolchain@stable
      - uses: Swatinem/rust-cache@v2
      - uses: actions/download-artifact@v7
      - name: Get Changelog Entry
        id: changelog_reader
        uses: mindsers/changelog-reader-action@v2
      - name: Publish the release
        uses: softprops/action-gh-release@v2
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          body: ${{ steps.changelog_reader.outputs.changes }}
      - run: cargo publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}