22Resolve release_type from PR labels with safe defaults.
33
44Modes
5- -----
6- 1) Manual override (MANUAL_RELEASE_TYPE): emit that and exit.
7- 2) Single-PR mode (default): inspect PR labels for THIS_SHA; default "rc".
8- 3) Aggregate mode (AGGREGATE=true): consider *all PRs merged since latest final tag*
9- up to LATEST_TEST_SHA (BOUNDARY), and pick highest of { major > minor > patch > rc}.
5+
6+ - Manual override (MANUAL_RELEASE_TYPE): emit that and exit.
7+ - Single-PR mode (default): inspect PR labels for THIS_SHA; default "rc".
8+ - Aggregate mode (AGGREGATE=true): consider TEST deployed PRs merged since latest final tag*
9+ up to LATEST_TEST_SHA (BOUNDARY), and pick highest of major > minor > patch > rc
1010
1111Env inputs
12- ----------
13- GH_TOKEN / GITHUB_TOKEN : required
14- THIS_SHA : SHA being promoted (required unless manual override)
15- LATEST_TEST_SHA : required when AGGREGATE=true
16- MANUAL_RELEASE_TYPE : optional (rc|patch|minor|major)
17- AGGREGATE : "true"|"false" (default "false")
18- BRANCH : branch (default "main")
19-
20- Outputs (GITHUB_OUTPUT)
21- -----------------------
22- release_type : rc|patch|minor|major
23- basis : manual|single-pr|aggregate
24- pr_numbers : comma-separated PR numbers considered
12+
13+ GH_TOKEN / GITHUB_TOKEN: required
14+ THIS_SHA: SHA being promoted (required unless manual override)
15+ LATEST_TEST_SHA: required when AGGREGATE=true
16+ MANUAL_RELEASE_TYPE: (rc|patch|minor|major)
17+ AGGREGATE: "true"|"false" (default "false")
18+ BRANCH: branch (default "main")
19+
20+ Outputs
21+
22+ release_type: rc|patch|minor|major
23+ basis: manual|single-pr|aggregate
24+ pr_numbers: comma-separated PR numbers considered
2525"""
2626
2727import os , subprocess , sys
3030BRANCH = os .getenv ("BRANCH" , "main" )
3131
3232def run (cmd : List [str ], check = True , capture = True ) -> subprocess .CompletedProcess :
33+ # cp = completed process (will use this to refer)
3334 return subprocess .run (cmd , check = check , capture_output = capture , text = True )
3435
3536def fail (msg : str ) -> int :
@@ -41,13 +42,20 @@ def ensure_graph():
4142 run (["git" ,"fetch" ,"--tags" ,"--force" ,"--quiet" ], check = True )
4243
4344def gh_api (path : str , jq : str | None = None ) -> List [str ]:
45+ """
46+ A simple python wrapper around the GitHub API
47+ to make it a callable function.
48+ """
4449 args = ["gh" ,"api" , path ]
4550 if jq :
4651 args += ["--jq" , jq ]
4752 cp = run (args , check = True )
4853 return [x for x in cp .stdout .splitlines () if x ]
4954
5055def latest_final_tag () -> str | None :
56+ """
57+ Grabs the version tags and sorts semantically desc
58+ """
5159 cp = run (["git" ,"tag" ,"--list" ,"v[0-9]*.[0-9]*.[0-9]*" ,"--sort=-v:refname" ], check = True )
5260 tags = cp .stdout .splitlines ()
5361 return tags [0 ] if tags else None
0 commit comments