Skip to content

Commit

Permalink
Fixed.
Browse files Browse the repository at this point in the history
  • Loading branch information
vd2org committed Feb 26, 2024
1 parent e500807 commit 620b889
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tools/create_release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import sys

import requests


def create_release(token: str, repo: str, release: str, body: str):
response = requests.post(f"https://api.github.com/repos/{repo}/releases",
headers={"Authorization": f"Bearer {token}"},
json={"tag_name": release, "name": release, "body": body})

if response.status_code != 201:
print(f"Failed to create release: {response.status_code} {response.text}", file=sys.stderr, flush=True)
sys.exit(-1)


def main():
try:
token, repo, release, body_file = sys.argv[1:]
except ValueError:
print(f"Usage: python {sys.argv[0]} <token> <repo> <release> <body_file>", file=sys.stderr)
sys.exit(-1)

try:
with open(body_file, 'r') as file:
body = file.read()
except (FileNotFoundError, IsADirectoryError):
print(f"File not found: {body_file}", file=sys.stderr)
sys.exit(-1)

create_release(token, repo, release, body)


if __name__ == '__main__':
main()

0 comments on commit 620b889

Please sign in to comment.