name: Version Bump

on:
  workflow_dispatch:
    inputs:
      current_version:
        description: 'Current version (e.g., 1.3.7)'
        required: true
      new_version:
        description: 'New version (e.g., 1.3.8)'
        required: true

jobs:
  bump-version:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout code
        uses: actions/checkout@f43a0e5ff2bd294095638e18286ca9a3d1956744 # v3.6.0
        
      - name: Setup PHP
        uses: shivammathur/setup-php@bf6b4fbd49ca58e4608c9c89fba0b8d90bd2a39f # 2.35.5
        with:
          php-version: '7.4'
          
      - name: Run version bump script
        run: php build/version-bump.php ${{ github.event.inputs.current_version }} ${{ github.event.inputs.new_version }}
        
      - name: Create Pull Request
        uses: peter-evans/create-pull-request@38e0b6e68b4c852a5500a94740f0e535e0d7ba54 # v4.2.4
        with:
          commit-message: "Bump version from ${{ github.event.inputs.current_version }} to ${{ github.event.inputs.new_version }}"
          title: "Bump version to ${{ github.event.inputs.new_version }}"
          body: |
            Automated version bump from ${{ github.event.inputs.current_version }} to ${{ github.event.inputs.new_version }}
            
            Please update the changelog with actual changes before merging.
          branch: "version-bump-${{ github.event.inputs.new_version }}"
