2022-11-07 17:20:39 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
2023-01-09 20:58:55 +00:00
|
|
|
import argparse
|
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
|
2023-12-18 08:07:22 +00:00
|
|
|
from commit_status_helper import get_commit, post_commit_status
|
2022-11-07 17:20:39 +00:00
|
|
|
from get_robot_token import get_best_robot_token
|
2024-02-06 12:39:34 +00:00
|
|
|
from git_helper import commit as commit_arg
|
2022-11-07 17:20:39 +00:00
|
|
|
from github_helper import GitHub
|
|
|
|
from pr_info import PRInfo
|
2022-12-02 17:27:36 +00:00
|
|
|
from release import RELEASE_READY_STATUS
|
2024-02-06 12:39:34 +00:00
|
|
|
from report import SUCCESS
|
2022-11-07 17:20:39 +00:00
|
|
|
|
|
|
|
|
|
|
|
def main():
|
2023-01-09 20:58:55 +00:00
|
|
|
parser = argparse.ArgumentParser(
|
|
|
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
|
|
|
description="mark the commit as ready for release",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"--token",
|
|
|
|
default=os.getenv("GITHUB_TOKEN", ""),
|
|
|
|
required=False,
|
|
|
|
help="GitHub token to authorize, required if commit is set. "
|
|
|
|
"Can be set as GITHUB_TOKEN env",
|
|
|
|
)
|
|
|
|
parser.add_argument(
|
|
|
|
"commit",
|
|
|
|
nargs="?",
|
|
|
|
type=commit_arg,
|
|
|
|
help="if given, used instead of one from PRInfo",
|
|
|
|
)
|
|
|
|
args = parser.parse_args()
|
|
|
|
description = "the release can be created from the commit, manually set"
|
2023-04-18 23:03:48 +00:00
|
|
|
pr_info = None
|
2023-01-09 20:58:55 +00:00
|
|
|
if not args.commit:
|
|
|
|
pr_info = PRInfo()
|
|
|
|
if pr_info.event == pr_info.default_event:
|
|
|
|
raise ValueError("neither launched from the CI nor commit is given")
|
|
|
|
args.commit = pr_info.sha
|
|
|
|
description = "the release can be created from the commit"
|
|
|
|
args.token = args.token or get_best_robot_token()
|
|
|
|
|
2023-02-22 15:46:31 +00:00
|
|
|
gh = GitHub(args.token, create_cache_dir=False)
|
2023-01-09 20:58:55 +00:00
|
|
|
# Get the rate limits for a quick fail
|
2023-04-18 23:03:48 +00:00
|
|
|
commit = get_commit(gh, args.commit)
|
2023-01-09 20:58:55 +00:00
|
|
|
gh.get_rate_limit()
|
2023-04-06 09:40:32 +00:00
|
|
|
post_commit_status(
|
2023-12-18 08:07:22 +00:00
|
|
|
commit,
|
2024-02-06 12:39:34 +00:00
|
|
|
SUCCESS,
|
2024-03-27 17:07:59 +00:00
|
|
|
"",
|
2023-12-18 08:07:22 +00:00
|
|
|
description,
|
|
|
|
RELEASE_READY_STATUS,
|
|
|
|
pr_info,
|
2022-11-07 17:20:39 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
2023-01-09 20:58:55 +00:00
|
|
|
logging.getLogger().setLevel(logging.INFO)
|
2022-11-07 17:20:39 +00:00
|
|
|
main()
|