-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpublish_main_tag.py
51 lines (44 loc) · 1.81 KB
/
publish_main_tag.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
from typing import Optional
import click
from git import Repo, TagReference
from utils import ISamplesRepos, pick_latest_tag, MAIN_TAG_NAME, pick_new_main_tag
def _cut_tag_and_push(source_tag: str, target_repo: Repo) -> TagReference:
commit_msg = f"Moving {MAIN_TAG_NAME} to point to {source_tag} for release"
try:
target_repo.delete_tag(MAIN_TAG_NAME)
target_repo.remotes.origin.push(f":{MAIN_TAG_NAME}")
except:
print("Unable to delete remote tag, continuing.")
tag = target_repo.create_tag(MAIN_TAG_NAME, source_tag, commit_msg, True)
main_tag_name = pick_new_main_tag(target_repo)
commit_msg = f"Creating archival tag {main_tag_name} off of {source_tag} for release"
archived_release_tag = target_repo.create_tag(main_tag_name, source_tag, commit_msg, True)
target_repo.remotes.origin.push()
target_repo.remotes.origin.push(tag)
target_repo.remotes.origin.push(archived_release_tag)
return tag
@click.command()
@click.argument(
"path",
type=click.Path(
exists=True, file_okay=False, dir_okay=True, writable=True, readable=True
),
)
@click.option(
"--source_tag",
default=None
)
def main(path: str, source_tag: Optional[str]):
isamples_repos = ISamplesRepos(path)
if source_tag is None:
source_tag = pick_latest_tag(isamples_repos.docker_repo, False)
print(f"Cutting new {MAIN_TAG_NAME} from {source_tag} in all iSamples Repos")
print("Cutting tag and pushing isamples-docker")
_cut_tag_and_push(source_tag, isamples_repos.docker_repo)
print("Cutting tag and pushing isamples-inabox")
_cut_tag_and_push(source_tag, isamples_repos.isb_repo)
print("Cutting tag and pushing isamples-webui")
_cut_tag_and_push(source_tag, isamples_repos.webui_repo)
print("Success.")
if __name__ == "__main__":
main()