name: Prepare Release

on:
  workflow_dispatch:
    inputs:
      version:
        description: "Version bump type or exact version (patch / minor / major / x.y.z / x.y.z-beta.N)"
        required: true
        default: "patch"
        type: string

  # Ensure this workflow only runs from the default branch
  # (workflow_dispatch already restricts to branches with write access,
  # but we guard the job to main to prevent accidental runs from feature branches)

permissions:
  contents: write
  pull-requests: write
  id-token: write

jobs:
  prepare:
    if: github.ref == 'refs/heads/main'
    runs-on: ubuntu-latest
    steps:
      - name: Check out Git repository
        uses: actions/checkout@v6
        with:
          fetch-depth: 0

      - name: Prepare Release via Claude
        uses: anthropics/claude-code-action@v1.0.66
        with:
          anthropic_api_key: ${{ secrets.CLAUDE_TRANSLATOR_APIKEY }}
          github_token: ${{ secrets.TOKEN_GITHUB_WRITE }}
          claude_args: '--allowed-tools "Bash(git:*),Bash(gh pr create:*),Bash(gh pr view:*),Bash(cat:*),Edit,Read,Write,Glob,Grep"'
          prompt: |
            Run the prepare-release skill with version argument: ${{ github.event.inputs.version }}

            Read the skill instructions from .agents/skills/prepare-release/SKILL.md and follow them exactly.

            Since this is running in CI (non-interactive), skip all interactive confirmation steps.

            Configure git before making commits:
            git config user.name "github-actions[bot]"
            git config user.email "github-actions[bot]@users.noreply.github.com"
        env:
          ANTHROPIC_BASE_URL: ${{ secrets.CLAUDE_TRANSLATOR_BASEURL }}
