SERVER-52535 Use evergreen and github API to get the bin version for each release and for the latest

This commit is contained in:
Mikhail Shchatko
2020-11-18 18:30:54 +03:00
committed by Evergreen Agent
parent 0345f78615
commit da2fa0281d
13 changed files with 1252 additions and 422 deletions

View File

@@ -0,0 +1,28 @@
"""Helper functions to interact with github."""
from github import Github, GithubException
class GithubConnError(Exception):
"""Errors in github_conn.py."""
pass
def get_git_tag_and_commit(github_oauth_token, version):
"""Return git tag and commit hash by associating the version with git tag."""
github = Github(github_oauth_token)
repo = github.get_repo("mongodb/mongo")
try:
git_ref_list = list(repo.get_git_matching_refs(f"tags/r{version}"))
# If git tag fully matches the version, it will be only one git_ref in the list,
# otherwise picking up the latest git_ref
git_ref = git_ref_list[-1]
git_tag = repo.get_git_tag(git_ref.object.sha)
git_commit = repo.get_commit(git_tag.object.sha)
except (GithubException, IndexError):
raise GithubConnError(f"Commit hash for a version {version} not found.")
return git_tag.tag, git_commit.sha