idiap_devtools.gitlab.release#

Utilities to needed to release packages.

Functions

get_latest_tag_name(gitpkg)

Find the name of the latest tag for a given package in the format '#.#.#'.

get_next_version(gitpkg, bump)

Returns the next version of this package to be tagged.

release_package(gitpkg, tag_name, tag_comments)

Releases a package.

update_files_at_default_branch(gitpkg, ...)

Update (via a commit) files of a given gitlab package, directly on the default project branch.

wait_for_pipeline_to_finish(gitpkg, pipeline_id)

Using sleep function, wait for the latest pipeline to finish building.

idiap_devtools.gitlab.release.get_latest_tag_name(gitpkg)[source]#

Find the name of the latest tag for a given package in the format ‘#.#.#’.

Parameters:

gitpkg (Project) – gitlab package object

Return type:

Optional[str]

Returns:

The name of the latest tag in format ‘#.#.#’. None if no tags for the package were found.

idiap_devtools.gitlab.release.get_next_version(gitpkg, bump)[source]#

Returns the next version of this package to be tagged.

Parameters:
  • gitpkg (Project) – gitlab package object

  • bump (str) – what to bump (can be “major”, “minor”, or “patch” versions)

Return type:

str

Returns:

The new version of the package (to be tagged)

Raises:

ValueError – if the latest tag retrieve from the package does not conform with the subset of PEP440 we use (e.g. “v1.2.3b1”).

idiap_devtools.gitlab.release.update_files_at_default_branch(gitpkg, files_dict, message, dry_run)[source]#

Update (via a commit) files of a given gitlab package, directly on the default project branch.

Parameters:
  • gitpkg (Project) – gitlab package object

  • files_dict (dict[str, str]) – Dictionary of file names and their contents (as text)

  • message (str) – Commit message

  • dry_run (bool) – If True, nothing will be committed or pushed to GitLab

Return type:

None

idiap_devtools.gitlab.release.wait_for_pipeline_to_finish(gitpkg, pipeline_id)[source]#

Using sleep function, wait for the latest pipeline to finish building.

This function pauses the script until pipeline completes either successfully or with error.

Parameters:
  • gitpkg (Project) – gitlab package object

  • pipeline_id (Optional[int]) – id of the pipeline for which we are waiting to finish

  • dry_run – If True, outputs log message and exit. There wil be no waiting.

Return type:

None

idiap_devtools.gitlab.release.release_package(gitpkg, tag_name, tag_comments, dry_run=False, profile=None)[source]#

Releases a package.

The provided tag will be annotated with a given list of comments. Files such as README.md and pyproject.toml will be updated according to the release procedures.

Parameters:
  • gitpkg (Project) – gitlab package object

  • tag_name (str) – The name of the release tag

  • tag_comments_list – New annotations for this tag in a form of list

  • dry_run (bool) – If True, nothing will be committed or pushed to GitLab

  • profile (Optional[Profile]) – An instance of idiap_devtools.profile.Profile used to retrieve the specifiers to pin the package’s dependencies in pyproject.toml.

Return type:

Optional[int]

Returns:

The (integer) pipeline identifier, or None, if a pipeline was not actually started (e.g. dry_run is set to True)