|
14 | 14 | DEFAULT_BRANCH_COMMIT_SHA, |
15 | 15 | ] |
16 | 16 |
|
| 17 | +MAJOR_RELEASE = "major" |
| 18 | +MINOR_RELEASE = "minor" |
| 19 | +PATCH_RELEASE = "patch" |
| 20 | + |
| 21 | +ALL_RELEASE_TYPES = [MAJOR_RELEASE, MINOR_RELEASE, PATCH_RELEASE] |
| 22 | + |
17 | 23 |
|
18 | 24 | class ActionEnvironment(NamedTuple): |
19 | 25 | repository: str |
@@ -42,6 +48,7 @@ class Configuration(NamedTuple): |
42 | 48 | update_version_with: str = LATEST_RELEASE_TAG |
43 | 49 | pull_request_user_reviewers: set[str] = set() |
44 | 50 | pull_request_team_reviewers: set[str] = set() |
| 51 | + release_types: list[str] = ALL_RELEASE_TYPES |
45 | 52 |
|
46 | 53 | @property |
47 | 54 | def git_commit_author(self) -> str: |
@@ -72,6 +79,7 @@ def get_user_config(cls, env: Mapping[str, str | None]) -> dict[str, str | None] |
72 | 79 | "commit_message": env.get("INPUT_COMMIT_MESSAGE"), |
73 | 80 | "ignore_actions": env.get("INPUT_IGNORE"), |
74 | 81 | "update_version_with": env.get("INPUT_UPDATE_VERSION_WITH"), |
| 82 | + "release_types": env.get("INPUT_RELEASE_TYPES"), |
75 | 83 | "pull_request_user_reviewers": env.get("INPUT_PULL_REQUEST_USER_REVIEWERS"), |
76 | 84 | "pull_request_team_reviewers": env.get("INPUT_PULL_REQUEST_TEAM_REVIEWERS"), |
77 | 85 | } |
@@ -122,6 +130,22 @@ def clean_pull_request_team_reviewers(value: Any) -> set[str] | None: |
122 | 130 | return {s.strip() for s in value.strip().split(",") if s} |
123 | 131 | return None |
124 | 132 |
|
| 133 | + @staticmethod |
| 134 | + def clean_release_types(value: Any) -> list[str] | None: |
| 135 | + if value and isinstance(value, str): |
| 136 | + values = [s.strip() for s in value.lower().strip().split(",") if s] |
| 137 | + if values == ["all"]: |
| 138 | + return ALL_RELEASE_TYPES |
| 139 | + elif all(i in ALL_RELEASE_TYPES for i in values): |
| 140 | + return values |
| 141 | + else: |
| 142 | + gha_utils.error( |
| 143 | + "Invalid input for `release_types` field, " |
| 144 | + f"expected one/all of {ALL_RELEASE_TYPES} but got `{value}`" |
| 145 | + ) |
| 146 | + raise SystemExit(1) |
| 147 | + return None |
| 148 | + |
125 | 149 | @staticmethod |
126 | 150 | def clean_skip_pull_request(value: Any) -> bool | None: |
127 | 151 | if value in [1, "1", True, "true", "True"]: |
|
0 commit comments