ticksupply 0.2.0

Official Rust client for the Ticksupply market data API
Documentation
name: Release

on:
  push:
    tags:
      - "v[0-9]+.[0-9]+.[0-9]+"
      - "v[0-9]+.[0-9]+.[0-9]+-*"

permissions:
  contents: write

jobs:
  publish:
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@v4
      - uses: dtolnay/rust-toolchain@stable

      - name: Verify tag matches Cargo.toml version
        run: |
          TAG="${GITHUB_REF_NAME#v}"
          CRATE_VERSION="$(cargo pkgid | sed 's/.*@//')"
          if [ "$TAG" != "$CRATE_VERSION" ]; then
            echo "::error::tag $GITHUB_REF_NAME does not match crate version $CRATE_VERSION"
            exit 1
          fi

      - name: Extract CHANGELOG section for this version
        id: changelog
        run: |
          VERSION="${GITHUB_REF_NAME#v}"
          # Extract the block under `## [VERSION]` up to (but not including) the next `## [` heading.
          BODY=$(awk -v ver="$VERSION" '
            $0 ~ "^## \\[" ver "\\]" { grab=1; next }
            grab && /^## \[/ { exit }
            grab { print }
          ' CHANGELOG.md)
          if [ -z "$(echo "$BODY" | tr -d '[:space:]')" ]; then
            echo "::error::CHANGELOG.md has no non-empty section for [$VERSION]"
            exit 1
          fi
          {
            echo "body<<EOF"
            echo "$BODY"
            echo "EOF"
          } >> "$GITHUB_OUTPUT"

      - name: cargo publish
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: cargo publish --all-features

      - name: Create GitHub release
        uses: softprops/action-gh-release@v2
        with:
          body: ${{ steps.changelog.outputs.body }}
          prerelease: ${{ contains(github.ref_name, '-') }}