name: Version Bump on: pull_request: types: [labeled] paths: - "registry/**/modules/**" concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: version-bump: if: github.event.label.name == 'version:patch' || github.event.label.name == 'version:minor' || github.event.label.name == 'version:major' runs-on: ubuntu-latest permissions: contents: read pull-requests: write steps: - name: Checkout code uses: actions/checkout@v4 with: fetch-depth: 0 token: ${{ secrets.GITHUB_TOKEN }} - name: Extract bump type from label id: bump-type run: | case "${{ github.event.label.name }}" in "version:patch") echo "type=patch" >> $GITHUB_OUTPUT ;; "version:minor") echo "type=minor" >> $GITHUB_OUTPUT ;; "version:major") echo "type=major" >> $GITHUB_OUTPUT ;; *) echo "Invalid version label: ${{ github.event.label.name }}" exit 1 ;; esac - name: Check version bump requirements id: version-check run: | # Run the script to check what versions should be output_file=$(mktemp) if ./.github/scripts/version-bump.sh "${{ steps.bump-type.outputs.type }}" origin/main > "$output_file" 2>&1; then echo "Script completed successfully" else echo "Script failed" cat "$output_file" exit 1 fi # Store output for PR comment { echo "output<> $GITHUB_OUTPUT # Show output cat "$output_file" # Check if any files would be modified by the script if git diff --quiet; then echo "versions_up_to_date=true" >> $GITHUB_OUTPUT echo "✅ All module versions are already up to date" else echo "versions_up_to_date=false" >> $GITHUB_OUTPUT echo "❌ Module versions need to be updated" echo "Files that would be changed:" git diff --name-only echo "" echo "Diff preview:" git diff exit 1 fi - name: Comment on PR - Failure if: failure() && steps.version-check.outputs.versions_up_to_date == 'false' uses: actions/github-script@v7 with: script: | const output = `${{ steps.version-check.outputs.output }}`; const bumpType = `${{ steps.bump-type.outputs.type }}`; let comment = `## ❌ Version Bump Validation Failed\n\n`; comment += `**Bump Type:** \`${bumpType}\`\n\n`; comment += `Module versions need to be updated but haven't been bumped yet.\n\n`; comment += `**Required Actions:**\n`; comment += `1. Run the version bump script locally: \`./.github/scripts/version-bump.sh ${bumpType}\`\n`; comment += `2. Commit the changes: \`git add . && git commit -m "chore: bump module versions (${bumpType})"\`\n`; comment += `3. Push the changes: \`git push\`\n\n`; comment += `### Script Output:\n\`\`\`\n${output}\n\`\`\`\n\n`; comment += `> Please update the module versions and push the changes to continue.`; github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, body: comment });