semantic_release.hvcs.gitlab module

Helper code for interacting with a Gitlab remote VCS

class semantic_release.hvcs.gitlab.Gitlab(remote_url: str, *, hvcs_domain: str | None = None, token: str | None = None, allow_insecure: bool = False, **_kwargs: Any)[source]

Bases: RemoteHvcsBase

Gitlab HVCS interface for interacting with Gitlab repositories

DEFAULT_DOMAIN = 'gitlab.com'
DEFAULT_ENV_TOKEN_NAME = 'GITLAB_TOKEN'
commit_hash_url(commit_hash: str) str[source]
compare_url(from_rev: str, to_rev: str) str[source]
create_or_update_release(tag: str, release_notes: str, prerelease: bool = False) str[source]

Create or update a release for the given tag in a remote VCS

Arguments:

tag(str): The tag to create or update the release for release_notes(str): The changelog description for this version only prerelease(bool): This parameter has no effect in GitLab

Returns:

str: The release id

Raises:

ValueError: If the release could not be created or updated gitlab.exceptions.GitlabAuthenticationError: If the user is not authenticated GitlabUpdateError: If the server cannot perform the request

create_release(tag: str, release_notes: str, prerelease: bool = False, assets: list[str] | None = None, noop: bool = False) str[source]

Create a release in a remote VCS, adding any release notes and assets to it

Arguments:

tag(str): The tag to create the release for release_notes(str): The changelog description for this version only prerelease(bool): This parameter has no effect in GitLab assets(list[str]): A list of paths to files to upload as assets (TODO: not implemented) noop(bool): If True, do not perform any actions, only log intents

Returns:

str: The tag of the release

Raises:

GitlabAuthenticationError: If authentication is not correct GitlabCreateError: If the server cannot perform the request

edit_release_notes(release: ProjectRelease, release_notes: str) str[source]

Update the release notes for a given release

Arguments:

release(gitlab.v4.objects.ProjectRelease): The release object to update release_notes(str): The new release notes

Returns:

str: The release id

Raises:

GitlabAuthenticationError: If authentication is not correct GitlabUpdateError: If the server cannot perform the request

get_changelog_context_filters() tuple[Callable[..., Any], ...][source]

Return a list of functions that can be used as filters in a Jinja2 template

ex. filters to convert text to URLs for issues and commits

get_release_by_tag(tag: str) ProjectRelease | None[source]

Get a release by its tag name

Arguments:

tag(str): The tag name to get the release for

Returns:

gitlab.v4.objects.ProjectRelease | None: The release object or None if not found

Raises:

gitlab.exceptions.GitlabAuthenticationError: If the user is not authenticated

issue_url(issue_number: str | int) str[source]
merge_request_url(mr_number: str | int) str[source]
property project: GitLabProject
pull_request_url(pr_number: str | int) str[source]
remote_url(use_token: bool = True) str[source]

Get the remote url including the token for authentication if requested

upload_dists(tag: str, dist_glob: str) int[source]

Upload built distributions to a release on a remote VCS that supports such uploads