Skip to content

GitLab Releases ​

@neosjs/release ships with a built-in gitlab plugin that creates a GitLab Release for the current version, links milestones, and uploads assets through the GitLab REST API v4.

Prerequisite: GitLab v11.7 or later is required, and a GitLab Release is attached to a Git tag that has already been pushed. Make sure tags and pushes are configured correctly in Git Integration. GitLab itself does not support draft or pre-release flags.

Quick Start ​

  1. Enable gitlab.release: true in the configuration file (or pass --gitlab.release on the command line).
  2. Create a Personal Access Token with the api scope in your GitLab personal settings.
  3. Provide the token through the GITLAB_TOKEN environment variable (the variable name can be changed with gitlab.tokenRef):
bash
export GITLAB_TOKEN="glpat-xxxxxxxxxxxx"
release

By default, the token and the current user's access to the project are verified during the init stage (access_level >= 30 is required, i.e. the Developer role or above; skip it with gitlab.skipChecks: true).

Using the Job Token in GitLab CI ​

In a GitLab CI pipeline there is no need to configure a personal token; the built-in CI_JOB_TOKEN can be used directly:

json
{
  "gitlab": {
    "release": true,
    "tokenRef": "CI_JOB_TOKEN",
    "tokenHeader": "JOB-TOKEN"
  }
}

When gitlab.tokenHeader is JOB-TOKEN (case-insensitive), the plugin automatically skips the user and collaborator permission checks.

Which Host Receives the Token ​

The hostname in the git remote URL may belong to a mirror or an impersonating domain, so it must not decide where the token is sent. Tokens from environment variables (GITLAB_TOKEN or the variable named by gitlab.tokenRef, including CI_JOB_TOKEN) are only sent to the following three kinds of hosts. The gitlab plugin, Release-via-PR, and --sync-releases all follow this rule:

  • The official domain gitlab.com
  • The gitlab.origin explicitly set in the configuration (self-hosted instances)
  • The address that GitLab CI declares for itself in environment variables (CI_SERVER_URL when GITLAB_CI=true, i.e. pipelines on self-hosted instances)

If a token is present in the environment but the repository host is not one of these, the release stops immediately and asks you to set the host with gitlab.origin: the token is never sent, and gitlab.skipChecks cannot skip this step (--dry-run prints the same notice).

For example, when git remote points to https://gitlab.example.com/team/demo.git and the release runs locally or on a third-party CI, declare the self-hosted instance explicitly:

json
{
  "gitlab": {
    "release": true,
    "origin": "https://gitlab.example.com"
  }
}

Custom Release Notes ​

By default the changelog generated by the built-in changelog plugin is used (falling back to git.logCommand or '-' when there is no content). You can also customize it with gitlab.releaseNotes:

  • String: executed as a shell command, using its standard output (supports ${...} template variables; a value containing shell syntax is refused, use RELEASE_ environment variables for multi-line content, see Lifecycle Hooks).
  • Function (JS / TS configuration file): receives the release context and returns a string or Promise<string>.

Linking Milestones ​

Use gitlab.milestones to link one or more milestone titles to the release (supports template variables such as ${version}):

json
{
  "gitlab": {
    "release": true,
    "milestones": ["${version}"]
  }
}
  • During the beforeRelease stage, before the release, the project and parent group milestones are looked up automatically. The release is aborted if any of the specified milestones does not exist.
  • To skip the existence check, set gitlab.skipChecks: true.

Uploading Release Assets ​

Use gitlab.assets to specify file paths or glob patterns (supports template variables such as ${version}):

Option 1: Project Uploads (default) ​

json
{
  "gitlab": {
    "release": true,
    "assets": ["dist/*.dmg", "dist/*.zip"],
    "useIdsForUrls": true
  }
}

On GitLab 17.2 and later, make sure to set gitlab.useIdsForUrls: true to use the project-ID-based full_path asset link format.

Option 2: Upload to the Generic Package Registry ​

Assets are uploaded as generic packages to projects/:id/packages/generic/<packageName>/<version>/<fileName> and attached to the release as asset links:

json
{
  "gitlab": {
    "release": true,
    "assets": ["dist/*.tar.gz"],
    "useGenericPackages": true,
    "genericPackageName": "my-app"
  }
}

These two options used to be called useGenericPackageRepositoryForAssets and genericPackageRepositoryName. The names were too long and have been shortened. The old names still work, and the release prints a notice asking you to switch to the new ones.

Self-Hosted GitLab, Self-Signed Certificates, and Proxies ​

Self-hosted GitLab on an enterprise intranet is fully supported:

json
{
  "gitlab": {
    "release": true,
    "origin": "https://gitlab.internal.example.com",
    "repoId": 12345,
    "certificateAuthorityFile": "/etc/ssl/certs/company-ca.crt",
    "proxy": true
  }
}
  • gitlab.origin: explicitly sets the base URL (empty defaults to https://${repo.host}).
  • gitlab.repoId: uses the numeric project ID instead of the URL-encoded owner/project path.
  • gitlab.certificateAuthorityFile / gitlab.certificateAuthorityFileRef: path to a custom CA certificate file; by default the CI_SERVER_TLS_CA_FILE environment variable is read automatically.
  • gitlab.secure: false: skips server TLS certificate verification (recommended only for temporary testing or intranet self-signed environments).
  • gitlab.proxy: true: reads the HTTP_PROXY / HTTPS_PROXY / NO_PROXY environment variables automatically and sends requests through the proxy.

Syncing and Updating Existing Releases ​

gitlab.update: true (or --gitlab.update) combined with --sync-releases overwrites and updates existing GitLab Releases when syncing historical versions from CHANGELOG.md:

bash
release --sync-releases --gitlab.release --gitlab.update

Configuration Options ​

OptionTypeDefaultDescription
gitlab.releasebooleanfalseWhether to create a GitLab Release
gitlab.releaseNamestring'Release v${version}'Release title template
gitlab.releaseNotesstring | Function | nullnullCustom release notes (shell command or function)
gitlab.milestonesstring | string[][]List of milestone titles to link to the release
gitlab.updatebooleanfalseWhether to allow updating an existing GitLab Release (used with --sync-releases)
gitlab.tokenRefstring'GITLAB_TOKEN'Name of the environment variable the token is read from
gitlab.tokenHeaderstring'Private-Token'Name of the HTTP request header used to pass the token ('JOB-TOKEN' for a job token)
gitlab.certificateAuthorityFilestring | nullnullPath to the CA certificate file for self-hosted instances
gitlab.certificateAuthorityFileRefstring'CI_SERVER_TLS_CA_FILE'Name of the environment variable the CA certificate path is read from
gitlab.securebooleantrueWhether to verify the server TLS certificate
gitlab.proxybooleanfalseWhether to read HTTP_PROXY / HTTPS_PROXY / NO_PROXY and use a proxy
gitlab.assetsstring | string[] | nullnullFiles or glob patterns to upload and attach as release assets
gitlab.useIdsForUrlsbooleanfalseUse ID-based asset links (required by GitLab 17.2+)
gitlab.useGenericPackagesbooleanfalseUpload assets to the Generic Package Registry (the old name useGenericPackageRepositoryForAssets still works)
gitlab.genericPackageNamestring''Package name in the Generic Package Registry (empty defaults to the sanitized project name or 'release'; the old name genericPackageRepositoryName still works)
gitlab.originstring | nullnullBase URL of the GitLab instance (defaults to https://${repo.host})
gitlab.skipChecksbooleanfalseSkip the token, permission, and milestone checks
gitlab.repoIdstring | number | nullnullUse the numeric project ID instead of the URL-encoded project path

Complete Default Configuration ​

ts
{
  gitlab: {
    release: false,
    releaseName: 'Release v${version}',
    releaseNotes: null,
    milestones: [],
    update: false,
    tokenRef: 'GITLAB_TOKEN',
    tokenHeader: 'Private-Token',
    certificateAuthorityFile: null,
    certificateAuthorityFileRef: 'CI_SERVER_TLS_CA_FILE',
    secure: true,
    proxy: false,
    assets: null,
    useIdsForUrls: false,
    useGenericPackages: false,
    genericPackageName: '',
    origin: null,
    skipChecks: false,
    repoId: null
  }
}