matchcore 0.4.0

A high-performance order book and price-time matching engine implemented as a single-threaded, deterministic, in-memory state machine
Documentation
name: Release

on:
  workflow_dispatch:
  push:
    branches: [main]
    paths:
      - "Cargo.toml"

permissions:
  contents: write

jobs:
  release:
    name: Release crate
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v6
        with:
          fetch-depth: 0

      - name: Set up Rust
        uses: dtolnay/rust-toolchain@stable

      - name: Read version from Cargo.toml
        id: version
        run: |
          version=$(python3 - << 'PY'
          import tomllib
          from pathlib import Path

          data = tomllib.loads(Path("Cargo.toml").read_text())
          print(data["package"]["version"])
          PY
          )
          echo "value=$version" >> "$GITHUB_OUTPUT"
          echo "Crate version: $version"

      - name: Determine tag name
        id: tag
        run: |
          TAG="v${{ steps.version.outputs.value }}"
          echo "value=$TAG" >> "$GITHUB_OUTPUT"
          echo "Tag: $TAG"

      - name: Check if tag already exists
        id: check_tag
        run: |
          git fetch --tags
          TAG="${{ steps.tag.outputs.value }}"

          if git tag -l "$TAG" | grep -q "^$TAG$"; then
            echo "exists=true" >> "$GITHUB_OUTPUT"
            echo "Tag $TAG already exists. Skipping release."
          else
            echo "exists=false" >> "$GITHUB_OUTPUT"
            echo "Tag $TAG does not exist yet."
          fi

      - name: Set Git identity
        if: steps.check_tag.outputs.exists == 'false'
        run: |
          git config user.name "github-actions[bot]"
          git config user.email "github-actions[bot]@users.noreply.github.com"

      - name: Run publish dry-run
        if: steps.check_tag.outputs.exists == 'false'
        run: cargo publish --dry-run

      - name: Create and push tag
        if: steps.check_tag.outputs.exists == 'false'
        run: |
          TAG="${{ steps.tag.outputs.value }}"
          echo "Creating annotated tag $TAG"
          git tag -a "$TAG" -m "Release $TAG"
          git push origin "$TAG"

      - name: Create GitHub Release
        if: steps.check_tag.outputs.exists == 'false'
        env:
          GH_TOKEN: ${{ github.token }}
        run: |
          TAG="${{ steps.tag.outputs.value }}"
          gh release create "$TAG" \
            --title "$TAG" \
            --generate-notes

      - name: Publish to crates.io
        if: steps.check_tag.outputs.exists == 'false'
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_IO_TOKEN }}
        run: cargo publish