on:
  workflow_call:

env:
  CARGO_DIST_VERSION: "0.31.0"
  CARGO_DIST_CHECKSUM: "cd355dab0b4c02fb59038fef87655550021d07f45f1d82f947a34ef98560abb8"

jobs:
  dist-plan:
    name: "dist plan"
    runs-on: ubuntu-latest
    env:
      GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
    steps:
      - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
        with:
          persist-credentials: false
          submodules: recursive

      - name: Install dist
        shell: bash
        run: |
          curl --proto '=https' --tlsv1.2 -LsSf "https://github.com/axodotdev/cargo-dist/releases/download/v${CARGO_DIST_VERSION}/cargo-dist-x86_64-unknown-linux-gnu.tar.xz" -o /tmp/cargo-dist.tar.xz
          echo "${CARGO_DIST_CHECKSUM}  /tmp/cargo-dist.tar.xz" | sha256sum -c -
          tar -xf /tmp/cargo-dist.tar.xz -C /tmp
          install /tmp/cargo-dist-x86_64-unknown-linux-gnu/dist ~/.cargo/bin/

      - name: Run dist plan
        run: |
          dist plan --output-format=json > plan-dist-manifest.json
          echo "dist plan completed successfully"
          cat plan-dist-manifest.json
