Skip to content

Commit 5b6f2f2

Browse files
committed
feat: extract version bump logic into reusable script
1 parent cc40d6c commit 5b6f2f2

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

.github/scripts/README.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# GitHub Scripts
2+
3+
This directory contains reusable scripts for GitHub Actions workflows.
4+
5+
## version-bump.sh
6+
7+
Extracts version bump logic from GitHub Actions workflows into a reusable script.
8+
9+
### Usage
10+
11+
```bash
12+
./version-bump.sh <bump_type> [base_ref]
13+
```
14+
15+
**Parameters:**
16+
- `bump_type`: Type of version bump (`patch`, `minor`, or `major`)
17+
- `base_ref`: Base reference for diff comparison (default: `origin/main`)
18+
19+
### Examples
20+
21+
```bash
22+
# Bump patch version for modules changed since origin/main
23+
./version-bump.sh patch
24+
25+
# Bump minor version for modules changed since a specific commit
26+
./version-bump.sh minor abc123
27+
28+
# Bump major version for modules changed since a specific branch
29+
./version-bump.sh major origin/develop
30+
```
31+
32+
### What it does
33+
34+
1. **Detects modified modules** from git diff changes
35+
2. **Gets current version** from latest release tag or README
36+
3. **Calculates new version** based on bump type
37+
4. **Updates README versions** in module documentation
38+
5. **Provides summary** of changes and next steps
39+
40+
### Version Detection
41+
42+
- **Tagged modules**: Uses latest `release/namespace/module/vX.Y.Z` tag
43+
- **Untagged modules**: Extracts version from README `version = "X.Y.Z"`
44+
- **New modules**: Start from v1.0.0
45+
46+
### Exit Codes
47+
48+
- `0`: Success (with or without changes)
49+
- `1`: Error (invalid arguments, no modules found, invalid version format, etc.)
50+
51+
### Integration with GitHub Actions
52+
53+
This script is designed to be called from GitHub Actions workflows. See `.github/workflows/version-bump.yaml` for an example implementation that:
54+
55+
- Triggers on PR labels (`version:patch`, `version:minor`, `version:major`)
56+
- Runs the script with appropriate parameters
57+
- Commits any README changes
58+
- Comments on the PR with results
59+
60+
### Notes
61+
62+
- Only updates READMEs that contain version references matching the module source
63+
- Warns about modules missing proper git tags
64+
- Follows semantic versioning (X.Y.Z format)
65+
- Validates all version components are numeric

0 commit comments

Comments
 (0)