From b158a3bcff10d12a841837c3268a8a992cb1095b Mon Sep 17 00:00:00 2001
From: Pierre Smeyers <pierre.smeyers@gmail.com>
Date: Sun, 28 May 2023 08:40:05 +0200
Subject: [PATCH] feat(release): allow specifying explicit release version

---
 README.md                     | 1 +
 kicker.json                   | 5 +++++
 templates/gitlab-ci-maven.yml | 1 +
 3 files changed, 7 insertions(+)

diff --git a/README.md b/README.md
index b485b74..fbca51f 100644
--- a/README.md
+++ b/README.md
@@ -179,6 +179,7 @@ They are bound to the `publish` stage, and use the following variables:
 | `MAVEN_DEPLOY_FROM_UNPROTECTED_DISABLED`| Set to `true` to limit snapshot publication to protected branches | _none_ (disabled) |
 | `MAVEN_DEPLOY_ARGS`                 | Maven arguments for the `mvn-deploy` job                     | `deploy -Dmaven.test.skip=true` |
 | `MAVEN_RELEASE_ARGS`                | Maven arguments for the `mvn-release` job                    | `release:prepare -DtagNameFormat=@{project.version} -Darguments=-Dmaven.test.skip=true` |
+| `MAVEN_RELEASE_VERSION`             | Explicit version to use when triggering a release | _none_ (uses the current snapshot version from `pom.xml`) |
 | `MAVEN_RELEASE_SCM_COMMENT_PREFIX`  | Maven release plugin [scmCommentPrefix](https://maven.apache.org/maven-release/maven-release-plugin/prepare-mojo.html#scmCommentPrefix) parameter | `chore(maven-release): ` |
 | `MAVEN_RELEASE_SCM_RELEASE_COMMENT` | Maven release plugin [scmReleaseCommitComment](https://maven.apache.org/maven-release/maven-release-plugin/prepare-mojo.html#scmReleaseCommitComment) parameter (since Maven `3.0.0-M1`) | _none_ (Maven default) |
 | `MAVEN_RELEASE_SCM_DEV_COMMENT`     | Maven release plugin [scmDevelopmentCommitComment](https://maven.apache.org/maven-release/maven-release-plugin/prepare-mojo.html#scmDevelopmentCommitComment) parameter (since Maven `3.0.0-M1`) | _none_ (Maven default) |
diff --git a/kicker.json b/kicker.json
index 22e1460..b968e39 100644
--- a/kicker.json
+++ b/kicker.json
@@ -144,6 +144,11 @@
           "default": "release:prepare -DtagNameFormat=@{project.version} -Darguments=-Dmaven.test.skip=true",
           "advanced": true
         },
+        {
+          "name": "MAVEN_RELEASE_VERSION",
+          "description": "Explicit version to use when triggering a release\n\n_Otherwise uses the current snapshot version from `pom.xml`)_",
+          "advanced": true
+        },
         {
           "name": "MAVEN_RELEASE_SCM_COMMENT_PREFIX",
           "description": "Maven release plugin [scmCommentPrefix](https://maven.apache.org/maven-release/maven-release-plugin/prepare-mojo.html#scmCommentPrefix) parameter",
diff --git a/templates/gitlab-ci-maven.yml b/templates/gitlab-ci-maven.yml
index 23e2291..90e59b8 100644
--- a/templates/gitlab-ci-maven.yml
+++ b/templates/gitlab-ci-maven.yml
@@ -567,6 +567,7 @@ mvn-release:
     - >-
       mvn ${TRACE+-X} $MAVEN_CLI_OPTS $mvn_settings_opt $java_proxy_args
       ${scm_auth_args} ${semrel_args}
+      ${MAVEN_RELEASE_VERSION+-DreleaseVersion="$MAVEN_RELEASE_VERSION"}
       ${MAVEN_RELEASE_SCM_COMMENT_PREFIX+-DscmCommentPrefix="$MAVEN_RELEASE_SCM_COMMENT_PREFIX"}
       ${MAVEN_RELEASE_SCM_RELEASE_COMMENT+-DscmReleaseCommitComment="$MAVEN_RELEASE_SCM_RELEASE_COMMENT"}
       ${MAVEN_RELEASE_SCM_DEV_COMMENT+-DscmDevelopmentCommitComment="$MAVEN_RELEASE_SCM_DEV_COMMENT"}
-- 
GitLab