genom 1.1.1

Fast reverse geocoding with additional location data
Documentation
name: Publish

on:
  push:
    branches:
      - master
    paths:
      - 'Cargo.toml'
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always

jobs:
  check-version:
    name: Check Version
    runs-on: ubuntu-latest
    outputs:
      changed: ${{ steps.check.outputs.changed }}
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 2
      
      - name: Check if version changed
        id: check
        run: |
          VERSION=$(grep -m1 '^version' Cargo.toml | sed 's/version[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/')
          git show HEAD~1:Cargo.toml > /tmp/old.toml 2>/dev/null || echo 'version = "0.0.0"' > /tmp/old.toml
          OLD=$(grep -m1 '^version' /tmp/old.toml | sed 's/version[[:space:]]*=[[:space:]]*"\([^"]*\)".*/\1/')
          echo "version=$VERSION"
          [ "$VERSION" != "$OLD" ] && echo "changed=true" >> $GITHUB_OUTPUT || echo "changed=false" >> $GITHUB_OUTPUT

  tests:
    name: Tests
    needs: check-version
    if: needs.check-version.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
    uses: ./.github/workflows/tests.yml

  publish:
    name: Publish to crates.io
    runs-on: ubuntu-latest
    needs: [check-version, tests]
    if: needs.check-version.outputs.changed == 'true' || github.event_name == 'workflow_dispatch'
    steps:
      - uses: actions/checkout@v4
      
      - name: Install Rust toolchain
        uses: dtolnay/rust-toolchain@stable
      
      - name: Publish to crates.io
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: cargo publish --no-default-features --features no-build-database