on:
  push:
    tags:
      - 'v*'           # Push events to every tag not containing /
  workflow_dispatch:

name: Publish

jobs:
  publish:
    name: Publish
    runs-on: ubuntu-latest
    steps:
      - name: Checkout sources
        uses: actions/checkout@v5

      - name: Install dependencies
        run: |
          sudo apt update -y
          sudo apt install -y libapr1-dev libaprutil1-dev libsvn-dev pkg-config libutf8proc-dev libsqlite3-dev subversion
        # Work around https://bugs.debian.org/1055242
      - name: "Fix up Version: field in Subversion .pc files"
        run: |
          svnversion=$(svn --version | grep -oP 'svn, version \K\d+\.\d+\.\d+')
          sudo sed -i "s/^Version: \$/Version: $svnversion/" /usr/lib/*/pkgconfig/libsvn_*.pc

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

      - run: cargo publish -p subversion-sys --token ${CRATES_TOKEN}
        env:
          CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
      - run: cargo publish -p subversion --token ${CRATES_TOKEN}
        env:
          CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
