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

Merge branch '25-this-template-doesn-t-allow-to-chose-semantic-release-version' into 'master'

Resolve "This template doesn't allow to chose semantic-release version"

Closes #25

See merge request to-be-continuous/semantic-release!37
parents 124fd618 f2998732
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -27,6 +27,8 @@ The semantic-release template uses some global configuration used throughout all
| Name                  | description                                   | default value     |
| --------------------- | --------------------------------------------- | ----------------- |
| `SEMREL_IMAGE`        | The Docker image used to run semantic-release | `registry.hub.docker.com/library/node:latest` |
| `SEMREL_VERSION`      | The [semantic-release](https://www.npmjs.com/package/semantic-release) version to use | `latest` |
| `SEMREL_EXEC_VERSION` | The [@semantic-release/exec](https://www.npmjs.com/package/@semantic-release/exec) version to use | `latest` |
| :lock: `GITLAB_TOKEN` | A GitLab [project access token](https://docs.gitlab.com/ee/user/project/settings/project_access_tokens.html) or [personal access token](https://docs.gitlab.com/ce/user/profile/personal_access_tokens.html) with `api`, `read_repository` and `write repository` scopes. :warning: This variable is **mandatory** and [defined by `semantic-release`](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/ci-configuration.md#push-access-to-the-remote-repository) itself. | _none_ |
| `GIT_AUTHOR_EMAIL` | A Git author email address associated with the `GITLAB_TOKEN` [bot user](https://docs.gitlab.com/ee/user/project/settings/project_access_tokens.html#bot-users-for-projects). This is [defined by `semantic-release`](https://semantic-release.gitbook.io/semantic-release/usage/configuration#git-environment-variables) itself, and **required if** the [verify-user push rules](https://docs.gitlab.com/ee/user/project/repository/push_rules.html#verify-users) enabled for the project | _none_ |
| `GIT_COMMITTER_EMAIL` | A Git committer email address associated with the `GITLAB_TOKEN` [bot user](https://docs.gitlab.com/ee/user/project/settings/project_access_tokens.html#bot-users-for-projects). This is [defined by `semantic-release`](https://semantic-release.gitbook.io/semantic-release/usage/configuration#git-environment-variables) itself, and **required if** the [verify-user push rules](https://docs.gitlab.com/ee/user/project/repository/push_rules.html#verify-users) enabled for the project | _none_ |
+12 −0
Original line number Diff line number Diff line
@@ -9,6 +9,18 @@
      "description": "The Docker image used to run semantic-release",
      "default": "registry.hub.docker.com/library/node:latest"
    },
    {
      "name": "SEMREL_VERSION",
      "description": "The [semantic-release](https://www.npmjs.com/package/semantic-release) version to use",
      "default": "latest",
      "advanced": true
    },
    {
      "name": "SEMREL_EXEC_VERSION",
      "description": "The [@semantic-release/exec](https://www.npmjs.com/package/@semantic-release/exec) version to use",
      "default": "latest",
      "advanced": true
    },
    {
      "name": "GITLAB_TOKEN",
      "description": "A GitLab [project access token](https://docs.gitlab.com/ee/user/project/settings/project_access_tokens.html) or [personal access token](https://docs.gitlab.com/ce/user/profile/personal_access_tokens.html) with `api`, `read_repository` and `write repository` scopes.",
+10 −10
Original line number Diff line number Diff line
@@ -29,8 +29,6 @@ variables:
  SEMREL_IMAGE: "registry.hub.docker.com/library/node:latest"
  SEMREL_HOOKS_DIR: "."
  SEMREL_TAG_FORMAT: "$${version}"
  # SEMREL_INFO_ENABLED
  SEMREL_INFO_FILE: ".semrel-info.dotenv"

  # default production ref name (pattern)
  PROD_REF: '/^(master|main)$/'
@@ -44,6 +42,8 @@ variables:
  SEMREL_PUBLISH_CMD: "publish.sh"
  SEMREL_SUCCESS_CMD: "success.sh"
  SEMREL_FAIL_CMD: "fail.sh"
  SEMREL_VERSION: latest
  SEMREL_EXEC_VERSION: latest

  SEMREL_CONFIG_DIR: "."

@@ -369,7 +369,7 @@ stages:
    done <<< $(yq eval ".plugins[]" "${semrelConfigFile}" -o=json --indent 0)

    # shellcheck disable=SC2086
    npm install -g semantic-release ${required_plugins}
    npm install -g "semantic-release@${SEMREL_VERSION}" ${required_plugins}
  }

  # this script console output is inserted in generated file: DO NOT ADD LOGS
@@ -476,7 +476,7 @@ stages:

    # Generating the hook scripts that will generate the dotenv file
    # The dotenv file is generated in $TMPDIR so it will survive the git reset
    dotenv_tmp="$(mktemp -t semrel-info-XXXXXXXXXX.dotenv)"
    dotenv_tmp="$(mktemp -t semrel.out.env)"

    export_last_version_hook_script="./export-last-version.sh"
    {
@@ -524,20 +524,20 @@ stages:
    mv -f "${releaserc_file}.new" ".releaserc"

    if [[ -n "$TRACE" ]]; then
      echo "generated .releaserc:"
      log_info "--- generated .releaserc:"
      cat ".releaserc"
    fi

    npm install -g semantic-release @semantic-release/exec
    npm install -g "semantic-release@${SEMREL_VERSION}" "@semantic-release/exec@${SEMREL_EXEC_VERSION}"
    semantic-release --dry-run

    # Rollback temporary semantic-release configuration
    git reset --hard

    mv "${dotenv_tmp}" "${SEMREL_INFO_FILE}"
    mv "${dotenv_tmp}" ./semrel.out.env

    echo "semrel dotenv artifact:"
    cat "${SEMREL_INFO_FILE}"
    log_info "--- semrel dotenv artifact:"
    cat ./semrel.out.env
  }

  function configure_commit_signing() {
@@ -598,7 +598,7 @@ semantic-release-info:
    - dotenv_semrel_info
  artifacts:
    reports:
      dotenv: "${SEMREL_CONFIG_DIR}/$SEMREL_INFO_FILE"
      dotenv: "${SEMREL_CONFIG_DIR}/semrel.out.env"
  rules:
    - if: $CI_COMMIT_TAG
      when: never