Skip to content

Commit edf8ffe

Browse files
authored
Merge pull request #211 from hnez/ci-stable-branches
CI: add support for stable branches and minor versions
2 parents 600c528 + c779eff commit edf8ffe

File tree

2 files changed

+29
-19
lines changed

2 files changed

+29
-19
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ on:
44
pull_request:
55
branches:
66
- scarthgap
7+
- stable-*
78
push:
89
branches:
910
- scarthgap
11+
- stable-*
1012
schedule:
1113
- cron: '10 21 * * 4'
1214

.github/workflows/distribution-version.py

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
import bb.tinfoil
55
import git
66

7-
# TODO: add minor version numbers once we have them
8-
RE_VERSION_TAG = "v(?P<year>[0-9][0-9])\.(?P<month>[0-9][0-9])"
9-
RE_VERSION_BB = "(?P<year>[0-9][0-9])\.(?P<month>[0-9][0-9])(?P<dev>$|\+dev)"
7+
RE_VERSION_TAG = r"v(?P<year>[0-9][0-9])\.(?P<month>[0-9][0-9])(?:\.(?P<minor>[0-9]+))?"
8+
RE_VERSION_BB = r"(?P<year>[0-9][0-9])\.(?P<month>[0-9][0-9])(?:(?P<dev>$|\+dev)|(?:\.(?P<minor>[0-9]+))?)"
109

1110

1211
def bb_variables(names):
@@ -38,44 +37,53 @@ def git_prev_tag():
3837
return (tag, commit_is_tagged)
3938

4039

40+
def version_tuple(version):
41+
year = int(version["year"])
42+
month = int(version["month"])
43+
minor = int(version["minor"] or "0")
44+
45+
return (year, month, minor)
46+
47+
4148
def check_version(distro_version):
4249
prev_tag, commit_is_tagged = git_prev_tag()
4350

4451
print(f"Checking tag {prev_tag} against version {distro_version}")
4552

4653
version_tag = re.fullmatch(RE_VERSION_TAG, prev_tag)
47-
version_tag_numeric = int(version_tag["year"]) * 100 + int(version_tag["month"])
54+
version_tag_tuple = version_tuple(version_tag)
4855

4956
version_bb = re.fullmatch(RE_VERSION_BB, distro_version)
50-
version_bb_numeric = int(version_bb["year"]) * 100 + int(version_bb["month"])
57+
version_bb_tuple = version_tuple(version_bb)
5158

5259
if commit_is_tagged:
5360
# The version in a tagged commit must match the version in the tag's name.
5461
assert version_bb["dev"] == ""
55-
assert version_tag_numeric == version_bb_numeric
56-
57-
elif version_bb["dev"] == "":
58-
# Release candidates already have the next release version set,
59-
# but it must be newer than any tag in the current commit's history.
60-
assert version_bb_numeric > version_tag_numeric
62+
assert version_tag_tuple == version_bb_tuple
6163

62-
else:
64+
elif version_bb["dev"]:
6365
# Non release candidate versions should have the previous tagged
6466
# version number plus the +dev suffix set.
65-
assert version_bb_numeric == version_tag_numeric
67+
assert version_bb_tuple == version_tag_tuple
68+
69+
else:
70+
# Release candidates already have the next release version set,
71+
# but it must be newer than any tag in the current commit's history.
72+
assert version_bb_tuple > version_tag_tuple
6673

6774

6875
def check_codename(codename):
6976
base_ref = os.environ.get("GITHUB_BASE_REF")
7077
ref = os.environ.get("GITHUB_REF_NAME")
7178
ref_type = os.environ.get("GITHUB_REF_TYPE")
7279

73-
if base_ref:
74-
print(f"Checking codename {codename} against pull request into {base_ref}")
75-
assert codename == f"tacos-{base_ref}"
76-
elif ref and ref_type == "branch":
77-
print(f"Checking codename {codename} against branch {ref}")
78-
assert codename == f"tacos-{ref}"
80+
branch = base_ref or (ref if ref_type == "branch" else None)
81+
82+
if branch and branch.startswith("stable-"):
83+
print("Running for a stable branch. Skipping codename check")
84+
elif branch:
85+
print(f"Checking codename {codename} against branch {branch}")
86+
assert codename == f"tacos-{branch}"
7987
elif ref_type == "tag":
8088
print("Running for a tag. Skipping codename check")
8189
else:

0 commit comments

Comments
 (0)