Skip to content

Commit 5f6a2cd

Browse files
feat: Expose bump level as output (#33)
* expose bump level as output Signed-off-by: Mohammad Ghazanfar Ali Danish <mohammad.ghazanfar.ali.danish@sap.com> * chore: build core action dist (auto) * addresses review remarks Signed-off-by: Mohammad Ghazanfar Ali Danish <mohammad.ghazanfar.ali.danish@sap.com> --------- Signed-off-by: Mohammad Ghazanfar Ali Danish <mohammad.ghazanfar.ali.danish@sap.com> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
1 parent e55c536 commit 5f6a2cd

10 files changed

Lines changed: 31 additions & 0 deletions

File tree

.github/actions/core/action.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ outputs:
5858
description: "True if version was bumped"
5959
new-version:
6060
description: "The new version"
61+
bumpLevel:
62+
description: "The computed SemVer bump level (major, minor, patch)"
6163

6264
runs:
6365
using: node20

.github/actions/core/dist/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ async function run() {
179179
const currentVersion = await (0, fetch_version_1.fetchCurrentVersion)(git, buildType, files, defaultBranch, versionPropertyPath);
180180
const level = (0, parse_commit_1.determineVersionLevelFromPRTitle)(prTitle);
181181
const newVersion = (0, bump_version_1.bumpVersion)(currentVersion, level);
182+
core.setOutput('bumpLevel', level);
182183
await (0, update_version_1.updateLocalVersion)(buildType, core.getInput('bump-command') || '', newVersion, files);
183184
if (postCommand) {
184185
core.info(`Executing post-command: ${postCommand}`);
@@ -199,6 +200,7 @@ async function run() {
199200
core.summary.addDetails("Version Bump", `Bumped version from ${currentVersion} to ${newVersion}`);
200201
core.setOutput('new-version', newVersion);
201202
core.setOutput('bumped', true);
203+
core.setOutput("bumpLevel", level);
202204
}
203205
else {
204206
core.info('No changes detected, skipping commit and push.');

.github/actions/core/src/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ async function run(): Promise<void> {
5151
const currentVersion = await fetchCurrentVersion(git, buildType, files, defaultBranch,versionPropertyPath);
5252
const level = determineVersionLevelFromPRTitle(prTitle);
5353
const newVersion = bumpVersion(currentVersion, level);
54+
core.setOutput('bumpLevel', level);
5455

5556
await updateLocalVersion(
5657
buildType,
@@ -81,6 +82,7 @@ async function run(): Promise<void> {
8182
core.summary.addDetails("Version Bump", `Bumped version from ${currentVersion} to ${newVersion}`);
8283
core.setOutput('new-version', newVersion);
8384
core.setOutput('bumped', true);
85+
core.setOutput("bumpLevel", level);
8486
} else {
8587
core.info('No changes detected, skipping commit and push.');
8688
core.setOutput('bumped', false);

.github/actions/version-bumping/maven/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ outputs:
4545
new-version:
4646
description: "The new version"
4747
value: ${{ steps.bump.outputs.new-version }}
48+
bumpLevel:
49+
description: "The computed SemVer bump level (major, minor, patch)"
50+
value: ${{ steps.bump.outputs.bumpLevel }}
4851

4952
runs:
5053
using: composite

.github/actions/version-bumping/npm/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ outputs:
4141
new-version:
4242
description: "The new version"
4343
value: ${{ steps.bump.outputs.new-version }}
44+
bumpLevel:
45+
description: "The computed SemVer bump level (major, minor, patch)"
46+
value: ${{ steps.bump.outputs.bumpLevel }}
4447

4548
runs:
4649
using: composite

.github/actions/version-bumping/python/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ outputs:
4141
new-version:
4242
description: "The new version"
4343
value: ${{ steps.bump.outputs.new-version }}
44+
bumpLevel:
45+
description: "The computed SemVer bump level (major, minor, patch)"
46+
value: ${{ steps.bump.outputs.bumpLevel }}
4447

4548
runs:
4649
using: composite

.github/actions/version-bumping/version-file/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ outputs:
4141
new-version:
4242
description: "The new version"
4343
value: ${{ steps.bump.outputs.new-version }}
44+
bumpLevel:
45+
description: "The computed SemVer bump level (major, minor, patch)"
46+
value: ${{ steps.bump.outputs.bumpLevel }}
4447

4548
runs:
4649
using: composite

.github/workflows/build-and-test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ jobs:
9393
run: |
9494
echo "Bumped: ${{ steps.version_bump.outputs.bumped }}"
9595
echo "New Version: ${{ steps.version_bump.outputs.new-version }}"
96+
echo "Bump Level: ${{ steps.version_bump.outputs.bumpLevel }}"
9697
echo "### Python Test New Version: ${{ steps.version_bump.outputs.new-version }}" >> $GITHUB_STEP_SUMMARY
9798
if [ -z "${{ steps.version_bump.outputs.bumped }}" ]; then
9899
echo "Error: 'bumped' output is empty"
@@ -124,6 +125,7 @@ jobs:
124125
run: |
125126
echo "Bumped: ${{ steps.version_bump.outputs.bumped }}"
126127
echo "New Version: ${{ steps.version_bump.outputs.new-version }}"
128+
echo "Bump Level: ${{ steps.version_bump.outputs.bumpLevel }}"
127129
echo "### NPM Test New Version: ${{ steps.version_bump.outputs.new-version }}" >> $GITHUB_STEP_SUMMARY
128130
if [ -z "${{ steps.version_bump.outputs.bumped }}" ]; then
129131
echo "Error: 'bumped' output is empty"
@@ -157,6 +159,7 @@ jobs:
157159
run: |
158160
echo "Bumped: ${{ steps.version_bump.outputs.bumped }}"
159161
echo "New Version: ${{ steps.version_bump.outputs.new-version }}"
162+
echo "Bump Level: ${{ steps.version_bump.outputs.bumpLevel }}"
160163
echo "### Maven Test New Version: ${{ steps.version_bump.outputs.new-version }}" >> $GITHUB_STEP_SUMMARY
161164
if [ -z "${{ steps.version_bump.outputs.bumped }}" ]; then
162165
echo "Error: 'bumped' output is empty"
@@ -188,6 +191,7 @@ jobs:
188191
run: |
189192
echo "Bumped: ${{ steps.version_bump.outputs.bumped }}"
190193
echo "New Version: ${{ steps.version_bump.outputs.new-version }}"
194+
echo "Bump Level: ${{ steps.version_bump.outputs.bumpLevel }}"
191195
echo "### Version File Test New Version: ${{ steps.version_bump.outputs.new-version }}" >> $GITHUB_STEP_SUMMARY
192196
if [ -z "${{ steps.version_bump.outputs.bumped }}" ]; then
193197
echo "Error: 'bumped' output is empty"

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ with:
5858
| `pyproject-file` | Path to pyproject.toml (python only). | `pyproject.toml` | No |
5959
| `version-file` | Path to version file (version-file only). | `VERSION` | No |
6060

61+
### Outputs
62+
63+
- `bumped`: True if version was bumped
64+
- `new-version`: The new version number
65+
- `bump`: The computed SemVer bump level (`major`, `minor`, or `patch`)
66+
6167
## Contributing
6268

6369
### Forked Repositories

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ outputs:
6464
new-version:
6565
description: "The new version"
6666
value: ${{ steps.bump_maven.outputs.new-version || steps.bump_npm.outputs.new-version || steps.bump_python.outputs.new-version || steps.bump_version_file.outputs.new-version }}
67+
bumpLevel:
68+
description: "The computed SemVer bump level (major, minor, patch)"
69+
value: ${{ steps.bump_maven.outputs.bumpLevel || steps.bump_npm.outputs.bumpLevel || steps.bump_python.outputs.bumpLevel || steps.bump_version_file.outputs.bumpLevel }}
6770

6871
runs:
6972
using: "composite"

0 commit comments

Comments
 (0)