-
Notifications
You must be signed in to change notification settings - Fork 6
feat: add GitHub Actions workflow for automatic version bumping #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This commit introduces a new workflow that triggers on pull request labeling to automatically detect version bumps (patch, minor, major) for Coder modules. It processes modified modules, updates their version references in README files, and commits the changes. Additionally, it comments on the pull request with a summary of the version bumps and any modules without existing git tags.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you extract this to a script in ./scripts/update_veraion.sh
that we can reuse in GitHub workflow?
Also the script should be able to run locally and bump versions for individual or multiple modules.
- Add .github/scripts/version-bump.sh with extracted logic from PR #137 - Add version-check.yaml workflow to verify module versions are updated - Add version-bump.yaml workflow that uses the script for label-triggered bumps - Update CONTRIBUTING.md with instructions on using the version bump script - Script supports patch/minor/major bumps and validates semantic versioning - CI will now check that module versions are properly updated in PRs
# Extract Version Bump Logic into Reusable Script This PR extracts the version bump logic from the GitHub Actions workflow (PR #137) into a reusable script and implements the requirements as requested. ## ✅ What This PR Delivers ### 🔧 **Version Bump Script**: `.github/scripts/version-bump.sh` - Extracts all version bump logic from the original workflow - Supports `patch`, `minor`, and `major` version bumps - Configurable base reference for diff comparison (defaults to `origin/main`) - Comprehensive error handling and semantic version validation - Can be used standalone or in workflows ### 🔍 **Version Check Workflow**: `.github/workflows/version-check.yaml` - **Required CI check** that runs on all PRs modifying modules - Verifies that module versions have been properly updated - Fails if versions need bumping but haven't been updated - Provides clear instructions on how to fix version issues ### 🚀 **Version Bump Workflow**: `.github/workflows/version-bump.yaml` - Simplified workflow that uses the extracted script - Triggered by PR labels (`version:patch`, `version:minor`, `version:major`) - Automatically commits version updates and comments on PR ### 📚 **Updated Documentation**: `CONTRIBUTING.md` - Clear instructions on how to use the version bump script - Examples for different bump types - Information about PR labels as an alternative - Explains that CI will check version updates ## 🎯 Key Features ✅ **Script Logic Extracted**: All complex bash logic moved from workflow to reusable script ✅ **Required CI Check**: Version check workflow ensures versions are updated ✅ **Diff Verification**: Script checks git diff to detect modified modules ✅ **Contribution Docs Updated**: Clear instructions for contributors ✅ **Backward Compatible**: Maintains all original functionality ✅ **Error Handling**: Comprehensive validation and clear error messages ## 📖 Usage Examples ```bash # For bug fixes ./.github/scripts/version-bump.sh patch # For new features ./.github/scripts/version-bump.sh minor # For breaking changes ./.github/scripts/version-bump.sh major ``` ## 🔄 Workflow Integration 1. **Developer makes changes** to modules 2. **CI runs version-check** workflow automatically 3. **If versions need updating**, CI fails with instructions 4. **Developer runs script** or adds PR label 5. **Versions get updated** automatically 6. **CI passes** and PR can be merged ## 🧪 Testing The script has been tested with: - ✅ Valid and invalid bump types - ✅ Module detection from git diff - ✅ Version calculation and validation - ✅ README version updates - ✅ Error handling for edge cases This implementation addresses all the original requirements while making the logic more maintainable and reusable. --------- Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com> Co-authored-by: DevelopmentCats <[email protected]>
Script exists. Is there a way we can test this workflow in an existing PR before Pushing? I ran some simulated tests that worked fine, but I haven't run this in an actual GH Workflow so i'm not entirely sure if this works as intended in the context of being run as a workflow. |
Let me know if you are good with merging this now. @matifali |
I still think we should not try to commit changes and instead check for diff and fail CI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of committing opt for failing CI and making it a required check.
Version Bump Workflow
Automates module version bumping when PR labels are applied.
Usage
Add one of these labels to a PR:
version:patch
- Bug fixes (1.2.3 → 1.2.4)version:minor
- New features (1.2.3 → 1.3.0)version:major
- Breaking changes (1.2.3 → 2.0.0)What it does
Example
If a PR modifies
registry/coder/git-clone/
and has labelversion:patch
:Version Detection
release/namespace/module/vX.Y.Z
tagversion = "X.Y.Z"
Notes