Commit d3aaf7c1 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

feat: integrate semantic-release info to helm-package job

parent 293fbecb
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -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:
+5 −0
Original line number Diff line number Diff line
@@ -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
        }
      ]
    },
+11 −10
Original line number Diff line number Diff line
@@ -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