Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 31 additions & 12 deletions action-templates/actions/action-maven-release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ inputs:
app-path:
description: "Path to the project’s pom.xml file"
required: true
release-method:
description: "Release-Methode = patch, minor oder major"
required: false
default: "patch"
Comment on lines +11 to +14

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🗄️ 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.

releaseVersion:
description: "Version to be released"
required: true
developmentVersion:
description: "Next version with snapshot"
required: true
required: false
default: ""
skipDeployment:
description: "Skip deployment to Maven Central"
default: "true"
Expand Down Expand Up @@ -44,6 +46,9 @@ outputs:
artifact-name:
description: "Name of the artifact upload"
value: ${{steps.artifact-name.outputs.artifact-name}}
release-version:
description: "calculated release version"
value: ${{steps.maven-release-step.outputs.FINAL_RELEASE_VERSION }}

runs:
using: "composite"
Expand Down Expand Up @@ -97,13 +102,30 @@ runs:
USE_PR: ${{ inputs.use-pr != 'true' }}
APP_PATH: ${{inputs.app-path}}
RELEASE_VERSION: ${{ inputs.releaseVersion }}
DEPLOYMENT_VERSION: ${{ inputs.developmentVersion }}
RELEASE_METHOD: ${{ inputs.release-method }}
DARGUMENTS: ${{ inputs.mavenDArgsInput }}
run: |
# configure git
git config --global user.email "github-actions@github.com"
git config --global user.name "GitHub Actions"

# get maven artifact id and provide as output
MVN_ARTIFACT_ID=$(mvn -f ./$APP_PATH/pom.xml org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.artifactId -DforceStdout | tee /dev/stderr | tail -n 1)
echo $MVN_ARTIFACT_ID
echo "MVN_ARTIFACT_ID=$MVN_ARTIFACT_ID" >> $GITHUB_OUTPUT

MVN_VERSION=$(mvn -f $APP_PATH/pom.xml $MAVEN_CLI_OPTS org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout )

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

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 FINAL_RELEASE_VERSION=$RELEASE >> $GITHUB_OUTPUT
echo "DEVELOPMENT_VERSION=$DEVELOPMENT_VERSION" >> $GITHUB_OUTPUT

# prepare the maven arguments
MAVEN_ARGS="-DpushChanges=$USE_PR -DremoteTagging=false -DlocalCheckout=true"
# set maven deploy skip if skipDeployment is true
Expand All @@ -113,13 +135,10 @@ runs:

# run maven release
mvn release:prepare release:perform -f ./$APP_PATH/pom.xml -B \
-DreleaseVersion=$RELEASE_VERSION -DdevelopmentVersion=$DEPLOYMENT_VERSION \
-DreleaseVersion=$RELEASE -DdevelopmentVersion=$DEVELOPMENT_VERSION \
$MAVEN_ARGS \
-Darguments="$DARGUMENTS"
# get maven artifact id and provide as output
MVN_ARTIFACT_ID=$(mvn -f ./$APP_PATH/pom.xml org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.artifactId -q -DforceStdout)
echo $MVN_ARTIFACT_ID
echo "MVN_ARTIFACT_ID=$MVN_ARTIFACT_ID" >> $GITHUB_OUTPUT

- id: artifact-name
name: Set output variable $GITHUB_OUTPUT
run: echo "artifact-name=${{hashFiles(format('./{0}/pom.xml', inputs.app-path))}}" >> "$GITHUB_OUTPUT"
Expand All @@ -135,8 +154,8 @@ runs:
if: ${{ inputs.use-pr == 'true' }}
uses: peter-evans/create-pull-request@5f6978faf089d4d20b00c7766989d076bb2fc7f1 # v8.1.1
with:
title: "chore(${{ inputs.app-path }}): bump release version to ${{ inputs.developmentVersion }}"
branch: "release-${{ inputs.app-path }}-${{ inputs.developmentVersion }}"
title: "chore(${{ inputs.app-path }}): bump release version to ${{ steps.maven-release-step.outputs.DEVELOPMENT_VERSION }}"
branch: "release-${{ inputs.app-path }}-${{ steps.maven-release-step.outputs.DEVELOPMENT_VERSION }}"
base: "${{ github.ref_name }}"
body: "This PR is auto-generated"
assignees: "${{ github.actor }}"