Skip to content

feat: extract version bump logic into reusable script #140

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

blink-so[bot]
Copy link

@blink-so blink-so bot commented Jun 5, 2025

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

# 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.

blink-so bot and others added 10 commits June 5, 2025 17:01
- 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
- Modify version-bump.sh to support both update and check modes
- Add --check flag and 'check' command for validation without changes
- Combine version-check and version-bump workflows into single workflow
- Remove separate version-check.yaml workflow (was overcomplicated)
- Update CONTRIBUTING.md to document simplified approach
- Script now exits with proper codes: 0 for success, 1 for needs update
- Workflow runs check job on all PRs, bump job only on labels
- Much cleaner and simpler implementation as requested
…ks diff

- Remove all check mode logic from version-bump.sh script
- Script now only supports patch, minor, major (as requested)
- Workflow runs script with patch and checks if diff exists
- If diff exists, CI fails and tells user to add version label
- Much simpler implementation: script updates, workflow checks diff
- Updated documentation to remove check mode references
- This is exactly what was requested: same script, check diff for validation
- Remove version-check job since it can't be required if it only runs on labels
- Workflow now only triggers on 'labeled' events with version:patch|minor|major
- This is the correct approach: workflow only runs when labels are applied
- No required checks since the workflow is optional/manual via labels
…handling

- Change permissions from 'write' to 'read' for contents
- Remove unnecessary Git setup steps
- Introduce a version check step to validate if module versions need updates
- Update PR comment to guide users on required actions when versions are not up to date
@DevelopmentCats DevelopmentCats requested a review from matifali June 6, 2025 02:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant