diff --git a/README.md b/README.md index 2f352b941f49afa4944116da7faae114812401b3..86b11a3a654e365c954e1751f55e40c4e1446618 100644 --- a/README.md +++ b/README.md @@ -420,7 +420,9 @@ It uses the following variables: #### Configure the target registry -The target registry url for publication shall be configured in the `publishConfig` of your `package.json` file. Examples: +The target registry url for publication shall be configured in the `publishConfig` of your `package.json` file. \ +If no registry is configured in `publishConfig`, it will publish to default target registry 'https://registry.npmjs.org/' only if `access` is set to 'public' in the `publishConfig` of your `package.json` file. \ +Examples: - for an unscoped package: diff --git a/templates/gitlab-ci-node.yml b/templates/gitlab-ci-node.yml index ccca4df760167b9c5e031008e6b79f8108fadedb..f446c064b23ea1587278d20c892f18b8818cbd61 100644 --- a/templates/gitlab-ci-node.yml +++ b/templates/gitlab-ci-node.yml @@ -554,12 +554,14 @@ stages: pkg_fullname=$(node -pe "require('./package.json').name") publish_registry_key=$(node -pe "parts='$pkg_fullname'.split('/');parts.length>1?parts[0]+':registry':'registry'") publish_registry_url=$(node -pe "require('./package.json').publishConfig?.['$publish_registry_key'] || ''") - if [[ -z "$publish_registry_url" ]] + publish_access=$(node -pe "require('./package.json').publishConfig?.access || ''") + if [[ -z "$publish_registry_url" ]] && [[ "$publish_access" != "public" ]] then - log_info "No publish registry url found in your package.json file" + log_info "No publish registry url found in your package.json file, and publish access is not set to public" log_info "Publish will only work if you're using GitLab project-level registry (use scope \\e[33;1m@${CI_PROJECT_ROOT_NAMESPACE}\\e[0m)" - log_info "Otherwise, declare the target registry url under \\e[33;1m'publishConfig' > '$publish_registry_key'\\e[0m key in your package.json file..." + log_info "Otherwise, declare the target registry url under \\e[33;1m'publishConfig' > '$publish_registry_key'\\e[0m key in your package.json file, or set 'public' access under \\e[33;1m'publishConfig' > 'access'\\e[0m to publish on default registry https://registry.npmjs.org/..." else + publish_registry_url="${publish_registry_url:-https://registry.npmjs.org/}" log_info "Publish to \\e[33;1m$publish_registry_url\\e[0m..." # maybe configure token if [[ "$NODE_PUBLISH_TOKEN" ]] @@ -818,7 +820,7 @@ node-sbom: paths: - $NODE_PROJECT_DIR/reports/node-sbom.cyclonedx.json reports: - cyclonedx: + cyclonedx: - $NODE_PROJECT_DIR/reports/node-sbom.cyclonedx.json rules: # exclude if disabled