---
name: Deploy to crates.io

on:
  workflow_run:
    workflows: ["Weekly Release"]
    types:
      - completed

jobs:
  build:
    if: ${{ github.event.workflow_run.conclusion == 'success' }}
    runs-on: ubuntu-latest
    container:
      image: arthurdw/rust-ci:latest

    strategy:
      matrix:
        include:
          - crate: rovo-macros
            path: rovo-macros
          - crate: rovo-lsp
            path: rovo-lsp
          - crate: rovo
            path: .
      max-parallel: 1

    steps:
      - name: Checkout repository
        uses: actions/checkout@v5

      - uses: Swatinem/rust-cache@v2

      - name: Publish ${{ matrix.crate }} to crates.io
        working-directory: ${{ matrix.path }}
        env:
          CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
        run: |
          cargo publish
