Skip to content

Commit

Permalink
Merge pull request #6 from janjagusch/make-labels-configurable-throug…
Browse files Browse the repository at this point in the history
…h-env-vars

Make labels configurable through env vars
  • Loading branch information
Marc Rooding authored Jun 16, 2020
2 parents 5c4f04b + 617f573 commit f3bfe15
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ If git tags are available, it will determine whether to do a major, minor, or pa

As stated above, the version update workflow relies on merge request labels to determine the new version. The `bump-minor` and `bump-major` labels have been set as global GitLab labels. However, global labels only propogate to groups created after setting a global label. When adding a global label, they [do not automatically propogate to existing groups](https://gitlab.com/gitlab-org/gitlab-ce/issues/12707).

If you cannot select the specified labels in your merge request, your group was most likely created before the global labels were defined. Please follow [this guide to setup group-specific labels](https://docs.gitlab.com/ee/user/project/labels.html)
If you cannot select the specified labels in your merge request, your group was most likely created before the global labels were defined. Please follow [this guide to setup group-specific labels](https://docs.gitlab.com/ee/user/project/labels.html).

Tip: You can use custom labels for minor and major bumps by setting the `MINOR_BUMP_LABEL` and `MAJOR_BUMP_LABEL` environment variables. If not set, the default labels `bump-minor` and `bump-major` will be used.

### API token and group

Expand Down
10 changes: 8 additions & 2 deletions version-update.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,18 @@ def retrieve_labels_from_merge_request(merge_request_id):
return merge_request.labels

def bump(latest):

minor_bump_label = os.environ.get("MINOR_BUMP_LABEL") or "bump-minor"
major_bump_label = os.environ.get("MAJOR_BUMP_LABEL") or "bump-major"

merge_request_id = extract_merge_request_id_from_commit()
labels = retrieve_labels_from_merge_request(merge_request_id)

if "bump-minor" in labels:


if minor_bump_label in labels:
return semver.bump_minor(latest)
elif "bump-major" in labels:
elif major_bump_label in labels:
return semver.bump_major(latest)
else:
return semver.bump_patch(latest)
Expand Down

0 comments on commit f3bfe15

Please sign in to comment.