diff --git a/README.md b/README.md index ccffea2adebd644f5282e9f1129d1eaa1b68bc63..3481e8eaf458a391eff32a759417bb6870315076 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,9 @@ The semantic-release template uses some global configuration used throughout all | --------------------- | --------------------------------------------- | ----------------- | | `SEMREL_IMAGE` | The Docker image used to run semantic-release | `node:lts` | | :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_ | +| `SEMREL_REQUIRED_PLUGINS_FILE` | An optional file for additional npm packages to install | `semrel-required-plugins.txt` | + +Jobs will extract required plugin packages from discovered configuration. If your configuration needs additional packages, add them, one per line, to `SEMREL_REQUIRED_PLUGINS_FILE` file. Each line must be a valid `npm install` package argument. ## Jobs diff --git a/kicker.json b/kicker.json index 0450999dc76ebfea0f8eee285ad4021649a34ca8..4eedb1f3c31758173baae9d73c4a68ac6c891e8f 100644 --- a/kicker.json +++ b/kicker.json @@ -20,6 +20,12 @@ "description": "For generated `.releaserc` file only. [tagFormat semantic-release option](https://github.com/semantic-release/semantic-release/blob/master/docs/usage/configuration.md#tagformat)e. :warning: don't forget to double the `$` character so it is not interpreted by GitLab.", "default": "$${version}", "advanced": true + }, + { + "name": "SEMREL_REQUIRED_PLUGINS_FILE", + "description": "Full path to `semrel-required-plugins.txt` file _(relative to `$CI_PROJECT_DIR`)_", + "default": "semrel-required-plugins.txt", + "advanced": true } ], "features": [ diff --git a/templates/gitlab-ci-semrel.yml b/templates/gitlab-ci-semrel.yml index 67b194d8841466975411cdeea5b9da9a1cdd236c..efed32bc78cd4f64e991c1df17f16f1874441f24 100644 --- a/templates/gitlab-ci-semrel.yml +++ b/templates/gitlab-ci-semrel.yml @@ -24,6 +24,8 @@ variables: # default production ref name (pattern) PROD_REF: '/^(master|main)$/' + SEMREL_REQUIRED_PLUGINS_FILE: "semrel-required-plugins.txt" + # undocumented (for internal use only) SEMREL_VERIFY_CONDITIONS_CMD: "verify-conditions.sh" SEMREL_VERIFY_RELEASE_CMD: "verify-release.sh" @@ -31,7 +33,7 @@ variables: SEMREL_PUBLISH_CMD: "publish.sh" SEMREL_SUCCESS_CMD: "success.sh" SEMREL_FAIL_CMD: "fail.sh" - SEMREL_REQUIRED_PLUGINS_FILE: "semrel-required-plugins.txt" + stages: - publish @@ -331,6 +333,14 @@ stages: log_info "installing required plugins" + # shellcheck disable=SC2046 + if [[ -f "${SEMREL_REQUIRED_PLUGINS_FILE}" ]]; then + while IFS= read -r line || [[ -n "$line" ]] + do + required_plugins="${required_plugins} $line" + done <<< $(cat "${SEMREL_REQUIRED_PLUGINS_FILE}") + fi + # shellcheck disable=SC2046 while IFS= read -r line || [[ -n "$line" ]] do