-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaddon-update-action.py
executable file
·63 lines (48 loc) · 1.5 KB
/
addon-update-action.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
52
53
54
55
56
57
58
59
60
61
62
63
import argparse
import yaml
from github import Auth, Github
parser = argparse.ArgumentParser()
parser.add_argument(
"--github_token",
type=str,
help="Github API Access token, NOT the usual Github token.",
required=True,
)
parser.add_argument(
"--new_server_version",
type=str,
help="The new server tag to use for the release.",
required=True,
)
parser.add_argument(
"--pre_release",
type=str,
help="Stable or Beta release.",
required=False,
)
if __name__ == "__main__":
args = parser.parse_args()
MAIN = "main"
ORGANIZATION = "music-assistant"
ADDON_REPO = "home-assistant-addon"
github = Github(auth=Auth.Token(args.github_token))
addon_repo = github.get_repo(f"{ORGANIZATION}/{ADDON_REPO}")
pre_release = args.pre_release in ("true", "True")
addon_version = "music_assistant"
if pre_release is True:
addon_version = "music_assistant_beta"
addon_config_file = addon_repo.get_contents(
f"{addon_version}/config.yaml", ref=MAIN
)
existing_config_content = yaml.safe_load(
addon_config_file.decoded_content.decode("utf-8")
)
existing_config_content["version"] = args.new_server_version
updated_config = yaml.dump(existing_config_content, sort_keys=False)
addon_repo.update_file(
path=f"{addon_version}/config.yaml",
message=f"Update config.yaml for {args.new_server_version}",
content=updated_config,
sha=addon_config_file.sha,
branch=MAIN,
)