A semantic-release plugin that determines the next version based on GitLab merge request labels and generates release notes from merge request information.
- Determines version bump (major, minor, patch, etc.) based on GitLab merge request labels
- Supports all semantic-release version types: major, premajor, minor, preminor, patch, prepatch, prerelease
- Fully customizable label mapping for determining release types
- Generates structured release notes from merge request information
- Integrates with GitLab CI/CD environment variables
npm install --save-dev "@gitlab/semantic-release-merge-request-analyzer"
By default, this plugin recognizes the following labels:
-
breaking change
- Triggers a major release -
type::feature
- Triggers a minor release -
type::bug
- Triggers a patch release -
type::maintenance
- Does not trigger a release (maintenance work)
However, you can fully customize which labels map to which release types.
The plugin requires the following environment variables:
-
CI_SERVER_URL
: The base URL of the GitLab instance, including protocol and port (automatically set in GitLab CI, default:https://gitlab.com
) -
CI_PROJECT_ID
: The GitLab project ID (automatically set in GitLab CI) -
GITLAB_TOKEN
: A GitLab access token with API access
Add the plugin to your .releaserc.json
or release.config.js
:
{
"plugins": [
"@gitlab/semantic-release-merge-request-analyzer",
"@semantic-release/gitlab"
]
}
You can customize which labels trigger which release types:
{
"plugins": [
[
"@gitlab/semantic-release-merge-request-analyzer",
{
"labels": {
"major": ["breaking change", "breaking-change"],
"premajor": ["pre-major"],
"minor": ["type::feature", "feature", "feat"],
"preminor": ["pre-minor"],
"patch": ["type::bug", "bug", "fix"],
"prepatch": ["pre-patch"],
"prerelease": ["pre-release"]
}
}
],
"@semantic-release/gitlab"
]
}
The plugin supports all standard semantic-release version types:
-
major
- Backward-incompatible changes -
premajor
- Pre-release for the next major version -
minor
- New features (backward-compatible) -
preminor
- Pre-release for the next minor version -
patch
- Bug fixes -
prepatch
- Pre-release for the next patch version -
prerelease
- General pre-release
If a merge request has multiple labels that would trigger different release types, the plugin chooses the highest release type based on the precedence (major > premajor > minor > preminor > patch > prepatch > prerelease).
If a merge request doesn't have any of the configured labels, it won't trigger a release.
Alternatively, if you want to use only specific functions from this plugin:
{
"plugins": [
[
"@gitlab/semantic-release-merge-request-analyzer",
{
"analyzeCommits": true,
"generateNotes": true,
"labels": {
"major": ["breaking"],
"minor": ["feature"],
"patch": ["fix"]
}
}
],
"@semantic-release/gitlab"
]
}
- Verify Conditions: Checks that required environment variables are present.
-
Analyze Commits: For each commit, the plugin:
- Finds the associated GitLab merge request
- Examines the merge request labels to determine if a release is needed
- Determines release type (major, minor, patch, etc.) based on configured label mapping
- Selects the highest precedence release type among all analyzed merge requests
- Generate Notes: Creates structured release notes based on merge request titles, categorized by release type.
When multiple merge requests with different release types are found, the plugin follows this precedence order:
-
major
(highest) premajor
minor
preminor
patch
prepatch
-
prerelease
(lowest)
This ensures that the most significant change determines the final release type.
MIT