diff --git a/templates/gitlab-ci-helm.yml b/templates/gitlab-ci-helm.yml index c7440ffe935f803abe59b911355094924359f89e..2f00bfb440cde4c1f7059e37e265da5561a4f975 100644 --- a/templates/gitlab-ci-helm.yml +++ b/templates/gitlab-ci-helm.yml @@ -575,20 +575,19 @@ stages: function helm_package() { rm -f helm-package.env - # determine chart version to publish (semantic-release integration) - if [[ "${SEMREL_INFO_ON}" && "${HELM_SEMREL_RELEASE_DISABLED}" != "true" ]] + # extract version from chart + base_version=$(awk -F':' '/^version:/ {print $2}' "$HELM_CHART_DIR/Chart.yaml") + base_version=${base_version// /} + # override version if semantic-release integration is enabled + if [[ "${SEMREL_INFO_ON}" ]] && [[ "${HELM_SEMREL_RELEASE_DISABLED}" != "true" ]] then if [[ -z "${SEMREL_INFO_NEXT_VERSION}" ]] then - log_warn "[semantic-release] no new version to release: skip" - exit 0 + log_info "[semantic-release] no new version to release: use default" else - log_info "[semantic-release] use computed next version: \\e[33;1m${SEMREL_INFO_NEXT_VERSION}\\e[0m" base_version="${SEMREL_INFO_NEXT_VERSION}" + log_info "[semantic-release] use computed next version: \\e[33;1m${base_version}\\e[0m" fi - else - base_version=$(awk -F':' '/^version:/ {print $2}' "$HELM_CHART_DIR/Chart.yaml") - base_version=${base_version// /} fi chart_name=$(awk -F':' '/^name:/ {print $2}' "$HELM_CHART_DIR/Chart.yaml") chart_name=${chart_name// /} @@ -603,8 +602,6 @@ stages: version_label="-$CI_COMMIT_REF_SLUG" fi - add_helm_repositories - # helm package log_info "packaging chart with version: \\e[33;1m${base_version}${version_label}\\e[0m" # shellcheck disable=SC2086 @@ -888,6 +885,13 @@ helm-publish: extends: .helm-base stage: publish script: + # skip if semantic-release integration enabled and no release is required + - | + if [[ "${SEMREL_INFO_ON}" ]] && [[ "${HELM_SEMREL_RELEASE_DISABLED}" != "true" ]] && [[ -z "${SEMREL_INFO_NEXT_VERSION}" ]] + then + log_warn "[semantic-release] no new version to release: skip" + exit 0 + fi - helm_publish $helm_package_file rules: - if: '$HELM_PUBLISH_URL == null || $HELM_PUBLISH_URL == "" || $HELM_PUBLISH_METHOD == "disabled"'