Skip to main content

GitLabChangelog

CI Python Version Code style: black

Produces GitLab changelog release notes for projects that follow SemVer. The changelog produced for each release based on the issues that have been closed and the merge requests that have been merged.

Installation

To install this just install it into a virtualenv like so:

cd GitLabChangelog
python3 -m venv venv
. venv/bin/activate

pip install --upgrade pip
pip install -e .

Contributing

This package uses the python-gitlab package to interact with GitLab. It's useful to refer to their documentation when making changes. You can test using their API locally by generating a Personal Access Token and setting it in the included local_test.py script.

You can run tests locally by running in the virtualenv you installed the package in:

tox

New releases will automatically publish the package to TestPyPi and PyPi via GitHub Actions. Don't forget to bump the version in gitlabchangelog/VERSION before tagging a new release.

Changelog format

The changelog is completely customizable with the Jinja templating engine. To supply your own template, use the template parameter when creating Changelogs:

from os import environ as env

import gitlab
from tagbotgitlab.changelog import Changelog

# Set some environment variables required for import.
env["GITLAB_URL"] = "https://gitlab.example.ca"
env["GITLAB_API_TOKEN"] = "<the-personal-access-token-you-created>"
client = gitlab.Gitlab(env["GITLAB_URL"], private_token=env["GITLAB_API_TOKEN"])

repo = "example/TestRepo"
p = client.projects.get(repo, lazy=True)

template = """
This is release {{ version }} of {{ package }}.
    {% if merge_requests %}
    **Summary:**
    {% for merge_request in merge_requests %}
        - [{{ merge_request.labels }}] {{ merge_request.title }} (!{{ merge_request.number }})
    {% endfor %}
    {% endif %}

    {% if previous_release %}
    **Changeset:** {{ compare_url }})
    {% endif %}
"""
changelog = Changelog(p, template)

commit = "abcdefgh"
version = "v1.0.1"
release_notes = changelog.get(version, commit)
print(release_notes)

The data available to you looks like this:

{
  "compare_url": "https://gitlab.com/Owner/Repo/-/compare/previous_version...current_version (or null for first release)",
  "issues": [
    {
      "author": {
        "name": "Real Name",
        "url": "https://gitlab.com/username",
        "username": "their login"
      },
      "description": "issue description",
      "labels": ["label1", "label2"],
      "number": 123,
      "title": "issue title",
      "url": "https://gitlab.com/Owner/Repo/issues/123"
    }
  ],
  "package": "PackageName",
  "previous_release": "v1.1.2 (or null for first release)",
  "merge_requests": [
    {
      "author": {"same format as": "issue author"},
      "description": "merge request description",
      "labels": ["label1", "label2"],
      "merger": {"same format as": "issue author"},
      "number": 123,
      "title": "merge request title",
      "url": "https://gitlab.com/Owner/Repo/pull/123"
    }
  ],
  "sha": "commit SHA",
  "version": "v1.2.3",
  "version_url": "https://gitlab.com/Owner/Repo/tree/v1.2.3"
}

You can see the default template in gitlabchangelog/changelog.py.

Ignore labels

Issues and pull requests with specified labels are not included in the changelog data. By default, the following labels are ignored:

  • changelog skip
  • duplicate
  • exclude from changelog
  • invalid
  • no changelog
  • question
  • wont fix

White-space, case, dashes, and underscores are ignored when comparing labels.

License

gitlabchangelog is provided under an MIT License.

Release files for GitLabChangelog 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for GitLabChangelog 0.2.1
File Size Uploaded
GitLabChangelog-0.2.1.tar.gz 11.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for GitLabChangelog 0.2.1
File Interpreter ABI Platform
GitLabChangelog-0.2.1-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 19.7 kB

Release files / GitLabChangelog-0.2.1.tar.gz

Download URL GitLabChangelog-0.2.1.tar.gz
Size 11.9 kB
Tags Source
SHA-256 checksum
How to use checksums
55673c80f73209617fa1a2605bbfbca5a6afe9227780c72ae0eedc91b15f72fe
BLAKE2b-256 checksum
How to use checksums
a6347d9e3f0227db4b3aae00bac546a27e129033c0264bdaee4f89ecfcbb2469
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

Release files / GitLabChangelog-0.2.1-py2.py3-none-any.whl

Download URL GitLabChangelog-0.2.1-py2.py3-none-any.whl
Size 7.7 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
80e16351c11e6486e82d7ad78f426d8b0463a6e15177b2d2f8aab71c7f394f0b
BLAKE2b-256 checksum
How to use checksums
e4fbc3025ef7e8f4d2c3d7e9ebdc65f883ad9106108aa27f3c392ce1eb1f9f7b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/33.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.63.0 importlib-metadata/4.11.2 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page