Skip to content
Snippets Groups Projects
Commit d99c6bbf authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

feat: add semantic-release integration

parent 1e1259d1
No related branches found
No related tags found
No related merge requests found
......@@ -161,12 +161,40 @@ They are bound to the `publish` stage, and use the following variables:
| `MAVEN_DEPLOY_ARGS` | Maven arguments for the Snapshot job | `deploy -DskipTests` |
| `MAVEN_RELEASE_ARGS` | Maven arguments for the Release job | `release:prepare release:perform -DskipTests` |
| `MAVEN_RELEASE_SCM_COMMENT_PREFIX` | Maven release plugin [scmCommentPrefix](https://maven.apache.org/maven-release/maven-release-plugin/prepare-mojo.html#scmCommentPrefix) parameter | `[ci skip][maven-release-plugin]` |
| `MVN_SEMREL_RELEASE_DISABLED` | Disable [semantic-release integration](#semantic-release-integration) | `[ci skip][maven-release-plugin]` |
More info:
* [Maven Deploy Plugin](https://maven.apache.org/plugins/maven-deploy-plugin/)
* [Maven Release Plugin](http://maven.apache.org/maven-release/maven-release-plugin/index.html)
#### `semantic-release` integration
If you activate the [`semantic-release-info` job from the `semantic-release` template](https://gitlab.com/Orange-OpenSource/tbc/semantic-release/#semantic-release-info-job), the `mvn-release` job will rely on the generated next version info.
* the release will only be performed if a next semantic release is present
* the version is passed to the maven release plugin as release version argument adding `-DreleaseVersion=${SEMREL_INFO_NEXT_VERSION}` to the `MAVEN_RELEASE_ARGS` value
:warning: Both maven release plugin and semantic-release use a dedicated tag format that need to be set accordingly.
By default maven release plugin uses `${artifactId}-${version}` and semantic-release uses `s${version}`
For exemple you can modify the semantic-release tag format with the `SEMREL_TAG_FORMAT` variable (see [semantic-release template variables](https://gitlab.com/Orange-OpenSource/tbc/semantic-release/#variables)).
```yml
variables:
SEMREL_TAG_FORMAT: "myArtifactId-$${version}"
```
Or you can [override the maven release plugin tag format](http://maven.apache.org/maven-release/maven-release-plugin/examples/prepare-release.html#Overriding_the_default_tag_name_format).
Note: You can disable the `semantic-release` job (as it's the `mvn-release` job that will perform the release and so we only need the `semantic-release-info` job) with the `SEMREL_RELEASE_DISABLED` variable.
```yml
variables:
SEMREL_RELEASE_DISABLED: "true"
```
Finally, the semantic-release integration can be disable with the `MVN_SEMREL_RELEASE_DISABLED` variable.
#### Maven repository authentication
Your Maven repository may require authentication credentials to publish artifacts.
......
......@@ -133,6 +133,11 @@
"default": "[ci skip][maven-release-plugin]",
"advanced": true
},
{
"name": "MVN_SEMREL_RELEASE_DISABLED",
"description": "Disable semantic-release integration",
"advanced": true
},
{
"name": "GIT_USERNAME",
"description": "Git username (if you wish to release using Git credentials)",
......
......@@ -429,6 +429,12 @@ mvn-release:
stage: publish
before_script:
- *mvn-scripts
- |
if [ "${SEMREL_INFO_ON}" ] && [ -z "${SEMREL_INFO_NEXT_VERSION}" ]
then
log_info "no new version to release"
exit 0
fi
- install_ca_certs "${CUSTOM_CA_CERTS:-$DEFAULT_CA_CERTS}"
- eval_java_proxy_args
- log_info "Preparing Git repository for release..."
......@@ -438,7 +444,15 @@ mvn-release:
script:
- configure_scm_auth
- maybe_set_version_from_git
- mvn ${TRACE+-X} $MAVEN_CLI_OPTS $java_proxy_args $scm_auth_args $MAVEN_RELEASE_ARGS -DscmCommentPrefix="$MAVEN_RELEASE_SCM_COMMENT_PREFIX"
- |
if [ "${SEMREL_INFO_ON}" ] && [ -z "${SEMREL_INFO_NEXT_VERSION}" ]
then
log_info "semantic-release info is activated, using computed next version for release \\e[1;94m${SEMREL_INFO_NEXT_VERSION}\\e[0m"
RELEASE_ARGS="${MAVEN_RELEASE_ARGS} -DreleaseVersion=${SEMREL_INFO_NEXT_VERSION}"
else
RELEASE_ARGS="${MAVEN_RELEASE_ARGS}"
fi
- mvn ${TRACE+-X} $MAVEN_CLI_OPTS $java_proxy_args $scm_auth_args $RELEASE_ARGS -DscmCommentPrefix="$MAVEN_RELEASE_SCM_COMMENT_PREFIX"
rules:
# exclude merge requests
- if: $CI_MERGE_REQUEST_ID
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment