forked from BerriAI/proxy_load_tester
-
Notifications
You must be signed in to change notification settings - Fork 2
/
github_helper.py
61 lines (50 loc) · 1.73 KB
/
github_helper.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
import requests
import os
import dotenv
from dotenv import load_dotenv
from github import Github
load_dotenv()
def new_stable_release(version):
commit_hash = get_release_commit_hash(version)
"""
Send
curl -X POST \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer $GITHUB_TOKEN" \
"https://api.github.com/repos/BerriAI/litellm/actions/workflows/ghcr_deploy.yml/dispatches" \
-d "{\"ref\":\"main\", \"inputs\":{\"tag\":\"v${VERSION}\"}}"
"""
new_version_name = f"v{version}-stable"
response = requests.post(
"https://api.github.com/repos/BerriAI/litellm/actions/workflows/ghcr_deploy.yml/dispatches",
headers={
"Accept": "application/vnd.github.v3+json",
"Authorization": f"Bearer {os.getenv('GITHUB_TOKEN')}",
},
json={"ref": "main", "inputs":
{
"tag": new_version_name,
"commit_hash": commit_hash
}
},
)
print("response: ", response)
print("response.text: ", response.text)
print("response.status_code: ", response.status_code)
# new_stable_release("1.34.22.dev15")
def get_release_commit_hash(version_number=None):
github_token = os.getenv("GITHUB_TOKEN")
print("getting release commit hash for ", version_number)
g = Github(github_token)
repo = g.get_repo(
"BerriAI/litellm"
) # Replace with your repository's username and name
release_info = repo.get_release(
id=version_number
)
print(release_info)
print(release_info.target_commitish)
print("commit hash: ", release_info.target_commitish)
# get_release_commit_hash(
# version_number="v1.34.28"
# )