Add workflow to bump version and create pull request#7
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a manually-triggered GitHub Actions workflow to automate version bumping by creating a release branch, running the existing PowerShell bump script, committing/pushing changes, and opening a PR.
Changes:
- Introduces
.github/workflows/bump_version.ymlworkflow_dispatch input for a target version. - Validates the version input, creates a
release/<version>branch, runscommands/bump-version.ps1, commits/pushes, and creates a PR viagh.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| jobs: | ||
| bump-version: | ||
| runs-on: ubuntu-latest | ||
| steps: |
There was a problem hiding this comment.
The workflow doesn’t declare permissions, so git push and/or gh pr create may fail in repos where the default GITHUB_TOKEN permissions are read-only. Add explicit permissions (at workflow or job level) for contents: write and pull-requests: write (and keep other scopes minimal).
| run: | | ||
| if ! [[ "${{ github.event.inputs.version }}" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | ||
| echo "Error: version must be in X.X.X format (got: ${{ github.event.inputs.version }})" | ||
| exit 1 |
There was a problem hiding this comment.
The version validation regex only allows X.Y.Z, but commands/bump-version.ps1 accepts full semver including pre-release/build metadata (e.g. 1.2.3-rc.1, 1.2.3+build.5). Align the workflow validation with the script’s Test-SemanticVersion pattern, or intentionally restrict inputs and update the script/description accordingly.
| git config user.name "IvanMurzak" | ||
| git config user.email "Ivan.D.Murzak@gmail.com" |
There was a problem hiding this comment.
This hard-codes a personal name/email for commits made by the workflow, which can be misleading for auditability and may expose personal contact info in git history. Consider using the standard github-actions[bot] identity (or ${{ github.actor }} where appropriate) and a no-reply email.
| git config user.name "IvanMurzak" | |
| git config user.email "Ivan.D.Murzak@gmail.com" | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" |
| - name: Commit and push version bump | ||
| run: | | ||
| git add -A | ||
| git commit -m "chore: bump version to ${{ github.event.inputs.version }}" | ||
| git push origin release/${{ github.event.inputs.version }} | ||
|
|
||
| - name: Create pull request |
There was a problem hiding this comment.
commands/bump-version.ps1 can exit successfully without changing files (e.g. when the new version equals the current version), which will cause git commit to fail with “nothing to commit” and break the workflow. Add a conditional check for a dirty working tree (or git diff --quiet) and skip commit/push/PR creation when there are no changes.
| - name: Commit and push version bump | |
| run: | | |
| git add -A | |
| git commit -m "chore: bump version to ${{ github.event.inputs.version }}" | |
| git push origin release/${{ github.event.inputs.version }} | |
| - name: Create pull request | |
| - name: Commit and push version bump | |
| id: commit_version_bump | |
| run: | | |
| if git diff --quiet; then | |
| echo "No changes detected after version bump; skipping commit and push." | |
| echo "changes=false" >> "$GITHUB_OUTPUT" | |
| exit 0 | |
| fi | |
| git add -A | |
| git commit -m "chore: bump version to ${{ github.event.inputs.version }}" | |
| git push origin release/${{ github.event.inputs.version }} | |
| echo "changes=true" >> "$GITHUB_OUTPUT" | |
| - name: Create pull request | |
| if: steps.commit_version_bump.outputs.changes == 'true' |
This pull request adds a new GitHub Actions workflow to automate the process of bumping the project version. The workflow allows maintainers to manually trigger a version bump, validates the version format, creates a release branch, runs a version update script, and opens a pull request with the changes.
Automation for version bumping:
.github/workflows/bump_version.ymlthat enables maintainers to manually trigger a version bump via workflow dispatch, validates the version input, creates a release branch, runs thebump-version.ps1script, commits and pushes the changes, and automatically opens a pull request for the version bump.