osrm-binding 1.0.0

Safe embedded Rust API for OSRM route, table, and trip services.
name: Release to crates.io

on:
  push:
    tags:
      - "v*"

permissions:
  contents: read

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

jobs:
  publish:
    name: Publish crate
    runs-on: ubuntu-latest
    timeout-minutes: 60

    steps:
      - name: Check out tagged source
        uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
        with:
          persist-credentials: false

      - name: Verify tag matches crate version
        shell: bash
        run: |
          crate_version=$(sed -n 's/^version = "\([^"]*\)"/\1/p' Cargo.toml | head -n 1)
          if [[ "${GITHUB_REF_NAME}" != "v${crate_version}" ]]; then
            echo "Tag ${GITHUB_REF_NAME} does not match Cargo.toml version ${crate_version}." >&2
            exit 1
          fi

      - name: Install Nix
        uses: cachix/install-nix-action@13d8dd58da0234aa297dedd986986ccb8e7f3e24 # v31
        with:
          github_access_token: ${{ secrets.GITHUB_TOKEN }}

      - name: Publish to crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CRATES_API_KEY }}
        run: nix develop --command cargo publish