Skip to content

Commit f3bfe15

Browse files
author
Marc Rooding
authored
Merge pull request #6 from janjagusch/make-labels-configurable-through-env-vars
Make labels configurable through env vars
2 parents 5c4f04b + 617f573 commit f3bfe15

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ If git tags are available, it will determine whether to do a major, minor, or pa
1717

1818
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).
1919

20-
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)
20+
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).
21+
22+
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.
2123

2224
### API token and group
2325

version-update.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,18 @@ def retrieve_labels_from_merge_request(merge_request_id):
4141
return merge_request.labels
4242

4343
def bump(latest):
44+
45+
minor_bump_label = os.environ.get("MINOR_BUMP_LABEL") or "bump-minor"
46+
major_bump_label = os.environ.get("MAJOR_BUMP_LABEL") or "bump-major"
47+
4448
merge_request_id = extract_merge_request_id_from_commit()
4549
labels = retrieve_labels_from_merge_request(merge_request_id)
4650

47-
if "bump-minor" in labels:
51+
52+
53+
if minor_bump_label in labels:
4854
return semver.bump_minor(latest)
49-
elif "bump-major" in labels:
55+
elif major_bump_label in labels:
5056
return semver.bump_major(latest)
5157
else:
5258
return semver.bump_patch(latest)

0 commit comments

Comments
 (0)