Commit 49a2fca3 authored by Pierre Smeyers's avatar Pierre Smeyers
Browse files

Merge branch 'feat/new-release' into 'master'

new release

See merge request to-be-continuous/angular!46
parents c480ccc3 1ac9dddf
Loading
Loading
Loading
Loading
+10 −7
Original line number Diff line number Diff line
@@ -302,17 +302,20 @@ It is bound to the `test` stage, and uses the following variables:

### `ng-publish` job

The Angular template features a `ng-publish` job to publish the built project.
This job [publishes](https://docs.npmjs.com/cli/v6/commands/npm-publish) the project packages to a npm registry.

This job is bound to the `publish` stage, and uses the following variable:
This job is bound to the `publish` stage and is disabled by default.
When enabled, it is executed on a Git tag with a semantic version pattern (`v?[0-9]+\.[0-9]+\.[0-9]+`, _configurable_).

It uses the following variables:

| Name                       | description                                                                 | default value                                                    |
|----------------------------|-----------------------------------------------------------------------------|------------------------------------------------------------------|
| `NG_PUBLISH_ENABLED`       | Set variable to `true` to enable the publish job                            | none (disabled)                                                  |
| `NG_PUBLISH_PROJECTS`      | Space separated list of projects to publish                                 | If no project is specified, all workspace projects are published |
| `NG_PUBLISH_ARGS`          | NPM [publish](https://docs.npmjs.com/cli/v6/commands/npm-publish) arguments | `--verbose`                                                      |
| `NPM_PUBLISH_REGISTRY`     | NPM registry to publish to | uses GitLab project npm packages registry      |                                                                  |
| :lock: `NPM_PUBLISH_TOKEN` | NPM publication registry authentication token                               | none                                                             |
| `NG_PUBLISH_ENABLED`       | Set variable to `true` to enable the publish job                            | _none_ (disabled) |
| `NG_PUBLISH_PROJECTS`      | Space separated list of projects to publish                                 | _none_ (all workspace projects are published) |
| `NG_PUBLISH_ARGS`          | NPM [publish](https://docs.npmjs.com/cli/v6/commands/npm-publish) arguments | _none_ |
| `NPM_PUBLISH_REGISTRY`     | npm registry to publish to | uses GitLab project npm packages registry      | _none_ |
| :lock: `NPM_PUBLISH_TOKEN` | NPM publication registry authentication token                               | _none_ |

:warning: When using the gitlab registry (which is the default behavior), your NPM package name must be in the format of `@scope/package-name`:

+2 −3
Original line number Diff line number Diff line
@@ -62,13 +62,12 @@
    {
      "id": "publish",
      "name": "Publish",
      "description": "NPM [publish](https://docs.npmjs.com/cli/v6/commands/npm-publish) your angular project",
      "description": "[publishes](https://docs.npmjs.com/cli/v6/commands/npm-publish) the project packages to a npm registry",
      "enable_with": "NG_PUBLISH_ENABLED",
      "variables": [
        {
          "name": "NG_PUBLISH_ARGS",
          "description": "npm [publish](https://docs.npmjs.com/cli/v6/commands/npm-publish) arguments",
          "default": "--verbose",
          "advanced": true
        },
        {
@@ -78,7 +77,7 @@
        },
        {
          "name": "NPM_PUBLISH_REGISTRY",
          "description": "NPM registry to publish to. If none is specified, uses GitLab project npm packages registry",
          "description": "npm registry to publish to. If none is specified, uses GitLab project npm packages registry",
          "secret": true
        },
        {
+8 −7
Original line number Diff line number Diff line
@@ -87,6 +87,8 @@ variables:
  PROD_REF: '/^(master|main)$/'
  # default integration ref name (pattern)
  INTEG_REF: '/^develop$/'
  # default release tag name (pattern)
  RELEASE_REF: '/^v?[0-9]+\.[0-9]+\.[0-9]+$/'

  # ==================================================
  # Variables for publication
@@ -100,7 +102,6 @@ variables:

  # Set some args of `npm publish` command
  # ex: NG_PUBLISH_ARGS: "--dry-run"
  NG_PUBLISH_ARGS: '--verbose'

# ==================================================
# Stages definition
@@ -360,7 +361,6 @@ stages:
      npm config set "@${CI_PROJECT_ROOT_NAMESPACE}:registry" "https://${CI_SERVER_HOST}/api/v4/packages/npm/"
      npm config set "//${CI_SERVER_HOST}/api/v4/projects/${CI_PROJECT_ID}/packages/npm/:_authToken" "${CI_JOB_TOKEN}"
    fi

  }

  function npm_publish() {
@@ -426,9 +426,8 @@ stages:
      fi

      log_info "Publishing project '${project}' from ${projectOutputDir}"
      npm publish "${projectOutputDir}" "${NG_PUBLISH_ARGS}"
      npm publish ${TRACE+--verbose} "${projectOutputDir}" "${NG_PUBLISH_ARGS}"
    done

  }

  unscope_variables
@@ -590,6 +589,8 @@ ng-publish:
  script:
    - npm_publish
  rules:
    # on production branche: manual
    - if: '$NG_PUBLISH_ENABLED == "true" && $CI_COMMIT_REF_NAME =~ $PROD_REF'
      when: manual
    # exclude if $NG_PUBLISH_ENABLED not set
    - if: '$NG_PUBLISH_ENABLED != "true"'
      when: never
    # on tag with release pattern: auto
    - if: '$CI_COMMIT_TAG =~ $RELEASE_REF'