regular 0.1.1

Regular Expression Manipulation and Analysis
Documentation
name: Rust

on:
  push:
  pull_request:

jobs:
  build:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        rust:
          - stable
          - beta
          - nightly
          - 1.64.0

    steps:
      - uses: actions/checkout@v3

      - uses: actions-rs/toolchain@v1
        id: toolchain
        with:
          profile: minimal
          toolchain: ${{ matrix.rust }}
          override: true
          components: rustfmt, clippy

      - uses: actions/cache@v3
        id: cache-registry
        with:
          path: |
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('~/.cargo/registry/index/**') }}-${{ hashFiles('~/.cargo/registry/cache/**') }}-${{ hashFiles('~/.cargo/git/db/**') }}
          restore-keys: |
            ${{ runner.os }}-cargo-registry-

      - uses: actions/cache@v3
        id: cache-toolchain-dependent
        with:
          path: |
            ~/.cargo/bin/
            target/
          key: ${{ runner.os }}-cargo-${{ steps.toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-${{ steps.toolchain.outputs.rustc_hash }}-

      - uses: actions-rs/cargo@v1
        with:
          command: build
          args: --locked --all-targets

      - uses: actions-rs/cargo@v1
        with:
          command: test

      - uses: actions-rs/cargo@v1
        with:
          command: fmt
          args: --all -- --check

      - uses: actions-rs/cargo@v1
        with:
          command: clippy

  publish:
    runs-on: ubuntu-latest
    needs:
      - build
    if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
    steps:
      - uses: actions/checkout@v3

      - uses: actions-rs/toolchain@v1
        id: toolchain
        with:
          profile: minimal
          toolchain: stable
          override: true

      - uses: actions/cache@v3
        id: cache-registry
        with:
          path: |
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
            ~/.cargo/git/db/
          key: ${{ runner.os }}-cargo-registry-${{ hashFiles('~/.cargo/registry/index/**') }}-${{ hashFiles('~/.cargo/registry/cache/**') }}-${{ hashFiles('~/.cargo/git/db/**') }}
          restore-keys: |
            ${{ runner.os }}-cargo-registry-

      - uses: actions/cache@v3
        id: cache-toolchain-dependent
        with:
          path: |
            ~/.cargo/bin/
            target/
          key: ${{ runner.os }}-cargo-${{ steps.toolchain.outputs.rustc_hash }}-${{ hashFiles('**/Cargo.lock') }}
          restore-keys: |
            ${{ runner.os }}-cargo-${{ steps.toolchain.outputs.rustc_hash }}-

      - uses: katyo/publish-crates@v2
        with:
          registry-token: ${{ secrets.CARGO_REGISTRY_TOKEN }}
          ignore-unpublished-changes: true