diff --git a/README.md b/README.md index d9cd68ebea8d1a544a7859782a03230d257fd0f1..0629323912e494e19c0d74001ba7fcf57a1aea87 100644 --- a/README.md +++ b/README.md @@ -235,6 +235,16 @@ This job [packages your chart into an archive](https://helm.sh/docs/helm/helm_pa | --------------------- | ---------------------------------------- | ----------------- | | `HELM_PACKAGE_ARGS` | The Helm [command with options](https://helm.sh/docs/helm/helm_package/) to perform the packaging (_without dynamic arguments such as the chart path_) | `package --dependency-update` | +| `HELM_SEMREL_RELEASE_DISABLED` | Set to disable usage of semrel release info for helm package | _none_ (enabled) | + +#### `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 automatically use the generated next version info for both application version (`--app-version`) and chart version (`--version`). + +If no next version info is generated by semantic-release, the package will be created either, but without versionning info. + +Note: You can disable the `semantic-release` integration (as it's the `helm-package`job that will perform the release) with the `HELM_SEMREL_RELEASE_DISABLED` variable. + ### `helm-publish` job This job uses the following variables: diff --git a/kicker.json b/kicker.json index ba02f1c2f7d4168b3e07a34f75a34e17c7c862bd..6f171dd8e8bd1d7bc1a1abd26ae9385a51b02c46 100644 --- a/kicker.json +++ b/kicker.json @@ -140,6 +140,11 @@ "description": "The Helm [command with options](https://helm.sh/docs/helm/helm_package/) to perform the packaging (_without dynamic arguments such as the chart path_)", "default": "package --dependency-update", "advanced": true + }, + { + "name": "HELM_SEMREL_RELEASE_DISABLED", + "description": "Disable semantic-release integration", + "advanced": true } ] }, diff --git a/templates/gitlab-ci-helm.yml b/templates/gitlab-ci-helm.yml index 839106ceb2c59232a0bb1d6ec0fc3976c918f7c0..b85eef66493dd60a6d62ca3dbe4cd4740ef5d4cc 100644 --- a/templates/gitlab-ci-helm.yml +++ b/templates/gitlab-ci-helm.yml @@ -282,11 +282,9 @@ stages: helm_namespace_opt="$helm_namespace_opt --namespace $namespace" fi - if [ -f "$CI_PROJECT_DIR/.package_name.txt" ]; then - package=$(cat "$CI_PROJECT_DIR/.package_name.txt") - elif [ -n "$HELM_DEPLOY_CHART" ]; then - package="$HELM_DEPLOY_CHART" - else + package=$(ls -1 ./helm_packages/*.tgz 2>/dev/null || echo "") + package=${package:-$HELM_DEPLOY_CHART} + if [ -z "${package}" ]; then log_error "No Chart to deploy! Please use \\e[32m\$HELM_DEPLOY_CHART\\e[0m to deploy a chart from a repository" log_error "Or check the provided variables to package your own chart!" exit 1 @@ -557,9 +555,13 @@ helm-package: - install_ca_certs "${CUSTOM_CA_CERTS:-$DEFAULT_CA_CERTS}" - add_helm_repositories script: - - output=$(helm $HELM_PACKAGE_ARGS $HELM_CHART_DIR --destination $CI_PROJECT_DIR) && echo $output - - mv "$(echo $output | grep -oe "[^ ]*$")" $CI_PROJECT_DIR/ - - echo $output | grep -oe "[^/]*$" > $CI_PROJECT_DIR/.package_name.txt + - | + if [[ "$SEMREL_INFO_ON" ]] && [[ "$SEMREL_INFO_NEXT_VERSION" ]] && [[ -z "$HELM_SEMREL_RELEASE_DISABLED" ]] + then + log_info "semantic-release info is activated, using computed next version for release: \\e[1;94m${SEMREL_INFO_NEXT_VERSION}\\e[0m" + helm_version_opts="--app-version ${SEMREL_INFO_NEXT_VERSION} --version ${SEMREL_INFO_NEXT_VERSION}" + fi + - helm $HELM_PACKAGE_ARGS ${TRACE+--debug} $helm_version_opts $HELM_CHART_DIR --destination helm_packages rules: - if: $CI_MERGE_REQUEST_ID when: never @@ -568,8 +570,7 @@ helm-package: artifacts: expire_in: 1 week paths: - - $CI_PROJECT_DIR/*.tgz - - $CI_PROJECT_DIR/.package_name.txt + - helm_packages/ # ================================================== # Stage: publish