name: Post-release version bump

# how to trigger: https://docs.github.com/en/actions/managing-workflow-runs/manually-running-a-workflow
on:
  workflow_dispatch:

env:
  CARGO_TERM_COLOR: always

jobs:
  ci:
    if: github.repository == 'blue-build/cli'
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0

      - uses: actions/cache@v4
        with:
          path: |
            target/
            ~/.cargo/bin/
            ~/.cargo/git/db/
            ~/.cargo/registry/index/
            ~/.cargo/registry/cache/
          key: ${{ runner.os }}-cargo-build-stable-${{ hashFiles('**/Cargo.toml') }}

      - name: Install just
        run: sudo snap install --edge --classic just

        # Cargo returns an exit code of 1 if already installed
      - name: Install cargo-release
        continue-on-error: true
        run: cargo install cargo-release --force

      - name: Git setup
        run: just cargo-post-release --execute

      - name: Create PR
        uses: peter-evans/create-pull-request@v5
        with:
          delete-branch: true
          base: "main"
          title: "Bump Version after Release"
          body: |
            Bump version after release
            This PR has been auto-generated