granit-parser 0.0.2

A YAML parser in pure Rust with strict compliance
Documentation
name: Release

on:
  workflow_dispatch:

permissions:
  contents: read

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

env:
  CARGO_TERM_COLOR: always
  MSRV: "1.81.0"

jobs:
  test:
    name: Verify release
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
        with:
          submodules: recursive

      - name: Install Rust toolchains
        run: |
          rustup toolchain install stable --profile minimal --component clippy --component rustfmt --no-self-update
          rustup default stable
          rustup target add wasm32v1-none --toolchain stable
          rustup toolchain install "${MSRV}" --profile minimal --no-self-update
          rustc -V
          cargo -V

      - name: Rust cache
        uses: Swatinem/rust-cache@v2

      - name: Check tag matches Cargo.toml version
        shell: bash
        run: |
          set -euo pipefail

          package_version="$(sed -n 's/^version = "\(.*\)"/\1/p' Cargo.toml | head -n 1)"

          if [ -z "${package_version}" ]; then
            echo "Could not read package version from Cargo.toml" >&2
            exit 1
          fi

          if [ "${GITHUB_REF}" != "refs/tags/${package_version}" ]; then
            echo "Ref ${GITHUB_REF} does not match Cargo.toml version ${package_version}." >&2
            echo "Create and push tag ${package_version}, then run this workflow from that tag." >&2
            exit 1
          fi

      - name: Prefetch dependencies
        run: |
          cargo fetch 
          cargo +"${MSRV}" fetch 

      - name: Check formatting
        run: cargo fmt --all -- --check

      - name: Run clippy
        run: cargo clippy  --offline --all-targets --all-features -- -D warnings

      - name: Run tests
        run: cargo test  --offline

      - name: Run tests with debug_prints
        run: cargo test  --offline --features debug_prints

      - name: Run no-default-features library tests
        run: cargo test  --offline --lib --no-default-features

      - name: Check no_std target
        run: cargo check  --offline --lib --no-default-features --target wasm32v1-none

      - name: Check MSRV
        run: cargo +"${MSRV}" check  --offline --all-targets

      - name: Verify crate packaging
        run: cargo publish  --dry-run

  publish:
    name: Publish to crates.io
    runs-on: ubuntu-latest
    needs: test
    environment: publish

    permissions:
      contents: read
      id-token: write

    steps:
      - uses: actions/checkout@v4

      - name: Install Rust toolchain
        run: |
          rustup toolchain install stable --profile minimal
          rustup default stable
          rustc -V
          cargo -V

      - name: Rust cache
        uses: Swatinem/rust-cache@v2

      - name: Authenticate to crates.io
        uses: rust-lang/crates-io-auth-action@v1
        id: auth

      - name: Publish crate
        env:
          CARGO_REGISTRY_TOKEN: ${{ steps.auth.outputs.token }}
        run: cargo publish