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
- Enable
gitlab.release: truein the configuration file (or pass--gitlab.releaseon the command line). - Create a Personal Access Token with the
apiscope in your GitLab personal settings. - Provide the token through the
GITLAB_TOKENenvironment variable (the variable name can be changed withgitlab.tokenRef):
export GITLAB_TOKEN="glpat-xxxxxxxxxxxx"
releaseBy 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:
{
"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.originexplicitly set in the configuration (self-hosted instances) - The address that GitLab CI declares for itself in environment variables (
CI_SERVER_URLwhenGITLAB_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:
{
"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, useRELEASE_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}):
{
"gitlab": {
"release": true,
"milestones": ["${version}"]
}
}- During the
beforeReleasestage, 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)
{
"gitlab": {
"release": true,
"assets": ["dist/*.dmg", "dist/*.zip"],
"useIdsForUrls": true
}
}On GitLab 17.2 and later, make sure to set
gitlab.useIdsForUrls: trueto use the project-ID-basedfull_pathasset 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:
{
"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:
{
"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 tohttps://${repo.host}).gitlab.repoId: uses the numeric project ID instead of the URL-encodedowner/projectpath.gitlab.certificateAuthorityFile/gitlab.certificateAuthorityFileRef: path to a custom CA certificate file; by default theCI_SERVER_TLS_CA_FILEenvironment 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 theHTTP_PROXY/HTTPS_PROXY/NO_PROXYenvironment 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:
release --sync-releases --gitlab.release --gitlab.updateConfiguration Options
| Option | Type | Default | Description |
|---|---|---|---|
gitlab.release | boolean | false | Whether to create a GitLab Release |
gitlab.releaseName | string | 'Release v${version}' | Release title template |
gitlab.releaseNotes | string | Function | null | null | Custom release notes (shell command or function) |
gitlab.milestones | string | string[] | [] | List of milestone titles to link to the release |
gitlab.update | boolean | false | Whether to allow updating an existing GitLab Release (used with --sync-releases) |
gitlab.tokenRef | string | 'GITLAB_TOKEN' | Name of the environment variable the token is read from |
gitlab.tokenHeader | string | 'Private-Token' | Name of the HTTP request header used to pass the token ('JOB-TOKEN' for a job token) |
gitlab.certificateAuthorityFile | string | null | null | Path to the CA certificate file for self-hosted instances |
gitlab.certificateAuthorityFileRef | string | 'CI_SERVER_TLS_CA_FILE' | Name of the environment variable the CA certificate path is read from |
gitlab.secure | boolean | true | Whether to verify the server TLS certificate |
gitlab.proxy | boolean | false | Whether to read HTTP_PROXY / HTTPS_PROXY / NO_PROXY and use a proxy |
gitlab.assets | string | string[] | null | null | Files or glob patterns to upload and attach as release assets |
gitlab.useIdsForUrls | boolean | false | Use ID-based asset links (required by GitLab 17.2+) |
gitlab.useGenericPackages | boolean | false | Upload assets to the Generic Package Registry (the old name useGenericPackageRepositoryForAssets still works) |
gitlab.genericPackageName | string | '' | Package name in the Generic Package Registry (empty defaults to the sanitized project name or 'release'; the old name genericPackageRepositoryName still works) |
gitlab.origin | string | null | null | Base URL of the GitLab instance (defaults to https://${repo.host}) |
gitlab.skipChecks | boolean | false | Skip the token, permission, and milestone checks |
gitlab.repoId | string | number | null | null | Use the numeric project ID instead of the URL-encoded project path |
Complete Default Configuration
{
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
}
}