Enhance action.yml with releaseMethod input - #342
Conversation
Added releaseMethod input for specifying release type and updated deployment version logic.
📝 WalkthroughWalkthroughThe Maven release action adds release method selection, computes release and development versions from the input and ChangesMaven release versioning
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant Inputs as ActionInputs
participant ReleaseStep as maven-release-step
participant Pom as pom.xml
participant Maven as MavenRelease
participant PullRequest as create-pull-request
Inputs->>ReleaseStep: provide releaseVersion and release-method
ReleaseStep->>Pom: evaluate artifactId and project version
Pom-->>ReleaseStep: return artifactId and version
ReleaseStep->>ReleaseStep: compute RELEASE and DEVELOPMENT_VERSION
ReleaseStep->>Maven: pass computed release arguments
ReleaseStep->>PullRequest: use computed development version
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-authored-by: Hans <11695964+hupling@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@action-templates/actions/action-maven-release/action.yml`:
- Around line 43-45: Update the MVN_ARTIFACT_ID output mapping in the action
metadata to reference the maven-release-step’s MVN_ARTIFACT_ID output instead of
RELEASE. Preserve the existing description and align it with the output already
exported by the step.
- Around line 11-13: Update the releaseMethod input in the action configuration
to default to patch and validate that its value is exactly patch, minor, or
major before the next-version calculation. Reject unset or invalid values such
as mionr instead of allowing them to fall through to patch behavior.
- Around line 116-125: Update the release-version selection in the Maven release
step to treat an omitted or empty RELEASE_VERSION as missing and default RELEASE
to MVN_VERSION with the -SNAPSHOT suffix removed. Preserve the explicit
RELEASE_VERSION value when it is non-empty, and ensure the resulting RELEASE is
used for the existing Maven output flow.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 913c6827-3c76-4bad-929a-747ff31e726b
📒 Files selected for processing (1)
action-templates/actions/action-maven-release/action.yml
| releaseMethod: | ||
| description: "Release-Methode = patch, minor oder major" | ||
| required: false |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Reject invalid release methods instead of silently producing a patch release.
An unset or misspelled value (for example, mionr) falls through to the patch path. Declare patch as the default and validate patch|minor|major before computing the next version.
Proposed fix
releaseMethod:
description: "Release-Methode = patch, minor oder major"
required: false
+ default: "patch"+ case "$RELEASE_METHOD" in
+ patch|minor|major) ;;
+ *) echo "Invalid releaseMethod: $RELEASE_METHOD" >&2; exit 1 ;;
+ esac📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| releaseMethod: | |
| description: "Release-Methode = patch, minor oder major" | |
| required: false | |
| releaseMethod: | |
| description: "Release-Methode = patch, minor oder major" | |
| required: false | |
| default: "patch" |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@action-templates/actions/action-maven-release/action.yml` around lines 11 -
13, Update the releaseMethod input in the action configuration to default to
patch and validate that its value is exactly patch, minor, or major before the
next-version calculation. Reject unset or invalid values such as mionr instead
of allowing them to fall through to patch behavior.
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
gh api graphql \
-F owner="it-at-m" \
-F name="lhm_actions" \
-F number="342" \
-f query='
query($owner: String!, $name: String!, $number: Int!) {
repository(owner: $owner, name: $name) {
pullRequest(number: $number) {
reviewThreads(first: 100) {
nodes {
id
isResolved
resolvedBy { login }
comments(first: 20) {
nodes {
databaseId
author { login }
body
createdAt
}
}
}
}
}
}
}' \
--jq '
.data.repository.pullRequest.reviewThreads.nodes[]
| select(any(.comments.nodes[]; .databaseId == 3672365573))
| {
id,
isResolved,
resolvedBy: (.resolvedBy.login // null),
comments: [.comments.nodes[] | {
databaseId,
author: .author.login,
createdAt,
body
}]
}
'Length of output: 3660
@simonhir, I didn’t close it—the GitHub API reports that the thread is still unresolved, with no resolvedBy user.
The patch default is now present, which covers an omitted input, but invalid values such as mionr are still not validated and would silently follow the patch path.
There was a problem hiding this comment.
how should i validate?
There was a problem hiding this comment.
Seems like the humans are having a chat. I'll hop back into my burrow for now. If you need me again, just tag @coderabbitai in a new comment, and I'll come hopping out!
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: Hans <11695964+hupling@users.noreply.github.com>
Co-authored-by: Hans <11695964+hupling@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
action-templates/actions/action-maven-release/action.yml (1)
120-125: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winValidate the release version before deriving numeric components.
RELEASEmay be caller-provided or a Maven version with only-SNAPSHOTremoved, but it is then parsed asMAJOR.MINOR.PATCHwithout validation. Qualified or malformed versions can produce an incorrectDEVELOPMENT_VERSION; unquoted values can also split Maven arguments. Require the documented version format, quote the shell expansions, and fail before exporting outputs.Proposed fix
- if [ -z $RELEASE_VERSION ]; then RELEASE="${MVN_VERSION/-SNAPSHOT/""}"; else RELEASE=$RELEASE_VERSION; fi + if [[ -z "$RELEASE_VERSION" ]]; then + RELEASE="${MVN_VERSION%-SNAPSHOT}" + else + RELEASE="$RELEASE_VERSION" + fi + if [[ ! "$RELEASE" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then + echo "Invalid release version: $RELEASE" >&2 + exit 1 + fiAlso applies to: 143-145
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@action-templates/actions/action-maven-release/action.yml` around lines 120 - 125, Validate RELEASE before parsing it in the release-version calculation block: require the documented numeric MAJOR.MINOR.PATCH format, reject malformed or qualified versions, and fail before deriving components or exporting outputs. Quote RELEASE_VERSION, MVN_VERSION, and related shell expansions to prevent word splitting while preserving the existing release-method calculations.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@action-templates/actions/action-maven-release/action.yml`:
- Around line 50-52: Update the description of the RELEASE output in the Maven
release action to state that it contains the release version, while leaving its
existing output mapping to steps.maven-release-step.outputs.RELEASE unchanged.
---
Outside diff comments:
In `@action-templates/actions/action-maven-release/action.yml`:
- Around line 120-125: Validate RELEASE before parsing it in the release-version
calculation block: require the documented numeric MAJOR.MINOR.PATCH format,
reject malformed or qualified versions, and fail before deriving components or
exporting outputs. Quote RELEASE_VERSION, MVN_VERSION, and related shell
expansions to prevent word splitting while preserving the existing
release-method calculations.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 34f05a4a-c701-45b2-9e62-4f5de5e42725
📒 Files selected for processing (1)
action-templates/actions/action-maven-release/action.yml
| RELEASE: | ||
| description: "Name of the artifact upload" | ||
| value: ${{steps.maven-release-step.outputs.RELEASE }} |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
Correct the RELEASE output description.
This output contains the release version, not the artifact upload name. The current description can mislead action consumers.
Proposed fix
RELEASE:
- description: "Name of the artifact upload"
+ description: "Version to be released"📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| RELEASE: | |
| description: "Name of the artifact upload" | |
| value: ${{steps.maven-release-step.outputs.RELEASE }} | |
| RELEASE: | |
| description: "Version to be released" | |
| value: ${{steps.maven-release-step.outputs.RELEASE }} |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@action-templates/actions/action-maven-release/action.yml` around lines 50 -
52, Update the description of the RELEASE output in the Maven release action to
state that it contains the release version, while leaving its existing output
mapping to steps.maven-release-step.outputs.RELEASE unchanged.
simonhir
left a comment
There was a problem hiding this comment.
Did you test that somewhere?
| artifact-name: | ||
| description: "Name of the artifact upload" | ||
| value: ${{steps.artifact-name.outputs.artifact-name}} | ||
| RELEASE: |
There was a problem hiding this comment.
why not kebab-case and why not add -version suffix?
There was a problem hiding this comment.
ich habe das vom internen code kopiert. release-version war der input und release war der output. aber dann eher final-release-version nennen.
| app-path: | ||
| description: "Path to the project’s pom.xml file" | ||
| required: true | ||
| releaseMethod: |
There was a problem hiding this comment.
ja, weil ich es so gemacht habe, wie bei releaseVersion. dann machen wir alles in kebal case außer releaseVersiom wegen Altbestand
| releaseMethod: | ||
| description: "Release-Methode = patch, minor oder major" | ||
| required: false |
| if [ "$RELEASE_METHOD" == "major" ]; then MINOR=0; elif [ "$RELEASE_METHOD" == "minor" ]; then MINOR=$(( $(echo $RELEASE | awk -F. '{print $2}' ) + 1 )); else MINOR=$(echo $RELEASE | awk -F. '{print $2}' ); fi | ||
| if [ "$RELEASE_METHOD" != "major" ] && [ "$RELEASE_METHOD" != "minor" ]; then PATCH=$(( $(echo $RELEASE | awk -F. '{print $3}') + 1 )); else PATCH=0; fi | ||
| DEVELOPMENT_VERSION=$(echo $MAJOR.$MINOR.$PATCH-SNAPSHOT) | ||
| echo $MVN_ARTIFACT_IDe |
There was a problem hiding this comment.
| echo $MVN_ARTIFACT_IDe | |
| echo $MVN_ARTIFACT_ID |
why print again?
There was a problem hiding this comment.
das war zu test zwecken. weil es einfach nicht funktioniert hat entferne ich wieder
Co-authored-by: Simon Hirtreiter <14137977+simonhir@users.noreply.github.com>
Co-authored-by: Simon Hirtreiter <14137977+simonhir@users.noreply.github.com>
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@action-templates/actions/action-maven-release/action.yml`:
- Around line 11-14: Update the action documentation section for the Maven
release action to remove references to the unsupported developmentVersion input,
document the release-method and release-version flow, and revise the example and
outputs to reflect that the development version is computed automatically.
- Line 121: Update the major-version branch in the RELEASE_METHOD arithmetic so
it uses shell arithmetic expansion to increment the extracted major component,
rather than executing it as a command. Preserve the existing parsing and
non-major branch, ensuring MAJOR is correctly set for versions such as 1.2.3.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: ebfdf8e9-9087-4ed4-bf96-94e172ac6c16
📒 Files selected for processing (1)
action-templates/actions/action-maven-release/action.yml
| release-method: | ||
| description: "Release-Methode = patch, minor oder major" | ||
| required: false | ||
| default: "patch" |
There was a problem hiding this comment.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
Update the documented action contract.
docs/actions.md:441-507 still describes callers supplying developmentVersion, which this action no longer accepts, and does not document the new release-method/release-version flow. Update the example and output list so consumers do not believe they control a development version that is now computed automatically.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@action-templates/actions/action-maven-release/action.yml` around lines 11 -
14, Update the action documentation section for the Maven release action to
remove references to the unsupported developmentVersion input, document the
release-method and release-version flow, and revise the example and outputs to
reflect that the development version is computed automatically.
|
|
||
| if [ -z $RELEASE_VERSION ]; then RELEASE="${MVN_VERSION/-SNAPSHOT/""}"; else RELEASE=$RELEASE_VERSION; fi | ||
| echo $RELEASE | ||
| if [ "$RELEASE_METHOD" == "major" ]; then MAJOR=$( $(echo $RELEASE | awk -F. '{print $1}') + 1 ); else MAJOR=$(echo $RELEASE | awk -F. '{print $1}'); fi |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
RELEASE=1.2.3
MAJOR=$( $(printf '%s\n' "$RELEASE" | awk -F. '{print $1}') + 1 )Repository: it-at-m/lhm_actions
Length of output: 196
🏁 Script executed:
#!/usr/bin/env bash
set -euo pipefail
echo "--- action snippet around line 121 ---"
if [ -f action-templates/actions/action-maven-release/action.yml ]; then
sed -n '110,130p' action-templates/actions/action-maven-release/action.yml | nl -ba -v110
else
echo "file not found"
fi
echo "--- usages of MAJOR and RELEASE_METHOD/maven release ---"
rg -n 'MAJOR|RELEASE_METHOD|major|mvn release|set-maven|Maven' action-templates/actions/action-maven-release/action.yml action-templates/actions -S || true
echo "--- relevant file excerpt ---"
wc -l action-templates/actions/action-maven-release/action.yml
cat -n action-templates/actions/action-maven-release/action.yml | sed -n '1,180p'Repository: it-at-m/lhm_actions
Length of output: 236
🏁 Script executed:
#!/usr/bin/env bash
set -uo pipefail
echo "file_exists=$(test -f action-templates/actions/action-maven-release/action.yml && echo yes || echo no)"
echo "--- action snippet around line 121 ---"
sed -n '110,130p' action-templates/actions/action-maven-release/action.yml | cat -n | sed 's/^//'
echo "--- relevant excerpts for RELEASE_METHOD and MAJOR release construction ---"
grep -nE 'RELEASE_METHOD|MAJOR|SNAPSHOT|VERSION|RELEASE' action-templates/actions/action-maven-release/action.yml | cat -n | sed 's/^//'
echo "--- file length ---"
wc -l < action-templates/actions/action-maven-release/action.yml
echo "--- full action.yml (first 180 lines) ---"
sed -n '1,180p' action-templates/actions/action-maven-release/action.yml | cat -n | sed 's/^//'
echo "--- behavioral probe of current expression ---"
bash -c 'set -euo pipefail; RELEASE=1.2.3; MAJOR=$( $(printf "%s\n" "$RELEASE" | awk -F. "{print \$1}") + 1 ); printf "MAJOR=[%s]\n" "$MAJOR"' || cat /dev/stderr >/tmp/current_expr_err.txt; cat /tmp/current_expr_err.txt
echo "--- behavioral probe of proposed arithmetic expression ---"
bash -c 'set -euo pipefail; RELEASE=1.2.3; MAJOR=$(( $(printf "%s\n" "$RELEASE" | awk -F. "{print \$1}") + 1 )); printf "MAJOR=[%s]\n" "$MAJOR"'Repository: it-at-m/lhm_actions
Length of output: 12356
Fix the major-version arithmetic before releasing as major.
$( $(echo $RELEASE | awk -F. '{print $1}') + 1 ) executes the extracted component as a command (1 + 1), so MAJOR is unset for versions like 1.2.3. That makes DEVELOPMENT_VERSION=.0.0-SNAPSHOT, which can make the Maven release fail or create an invalid release PR. Use an arithmetic expansion such as MAJOR=$(( $(printf '%s\n' "$RELEASE" | awk -F. '{print $1}') + 1 )).
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@action-templates/actions/action-maven-release/action.yml` at line 121, Update
the major-version branch in the RELEASE_METHOD arithmetic so it uses shell
arithmetic expansion to increment the extracted major component, rather than
executing it as a command. Preserve the existing parsing and non-major branch,
ensuring MAJOR is correctly set for versions such as 1.2.3.
Added releaseMethod input for specifying release type and updated deployment version logic.
Pull Request
Changes
Reference
Relates to #330
Testing
URL to pull request or branch for testing your changes in sps-repo : ...
https://github.com/it-at-m/sps-test/actions/runs/30521133992
Checklist
Note: If some checklist items are not relevant for your PR, just remove them.
General
Code
Summary by CodeRabbit