Skip to content

Commit 97b22a0

Browse files
authored
Update create_release_tag.py
1 parent 4f35d46 commit 97b22a0

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

.github/workflows/create_release_tag.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
import sys
77

88
TARGET_FILE = "src/index.json"
9-
# Get API URLs from environment
10-
RELEASE_API_URL, TAG_API_URL = get_api_urls()
119

1210
def get_api_urls() -> Tuple[str, str]:
1311
"""Generate GitHub API URLs based on GITHUB_REPOSITORY environment variable."""
@@ -56,17 +54,17 @@ def generate_tag_and_title(filename: str) -> Tuple[str, str]:
5654
release_title = f"Release {tag_name}"
5755
return tag_name, release_title
5856

59-
def check_tag_exists(tag_name: str, headers: Dict[str, str]) -> bool:
57+
def check_tag_exists(url: str, tag_name: str, headers: Dict[str, str]) -> bool:
6058
response = requests.get(
61-
f"{TAG_API_URL}/{tag_name}",
59+
f"{url}/{tag_name}",
6260
headers=headers
6361
)
6462
return response.status_code == 200
6563

66-
def create_release(release_data: Dict[str, str], headers: Dict[str, str]) -> None:
64+
def create_release(url: str, release_data: Dict[str, str], headers: Dict[str, str]) -> None:
6765
try:
6866
response = requests.post(
69-
RELEASE_API_URL,
67+
url,
7068
json=release_data,
7169
headers=headers
7270
)
@@ -81,6 +79,9 @@ def main():
8179
print("Error: GITHUB_TOKEN environment variable is required")
8280
sys.exit(1)
8381

82+
# Get API URLs from environment
83+
release_url, tag_url = get_api_urls()
84+
8485
headers = {
8586
"Authorization": f"token {github_token}",
8687
"Accept": "application/vnd.github.v3+json"
@@ -105,7 +106,7 @@ def main():
105106
text=True
106107
).strip()
107108

108-
if check_tag_exists(commit_sha, headers):
109+
if check_tag_exists(tag_url, commit_sha, headers):
109110
print(f"Commit {commit_sha} already has a tag, skipping...")
110111
return
111112

@@ -116,7 +117,7 @@ def main():
116117
"body": release_title
117118
}
118119

119-
create_release(release_data, headers)
120+
create_release(release_url, release_data, headers)
120121

121122
except ValueError as e:
122123
print(f"Error generating tag for filename {filename}: {e}")

0 commit comments

Comments
 (0)