Added missing MIME type header in release script

This commit is contained in:
s3lph 2018-11-04 10:43:50 +01:00
parent 566d1efdd6
commit 54ca432ee7

View file

@ -10,10 +10,6 @@ import http.client
from urllib.error import HTTPError from urllib.error import HTTPError
encoder = json.encoder.JSONEncoder()
decoder = json.decoder.JSONDecoder()
def parse_changelog(tag: str) -> Optional[str]: def parse_changelog(tag: str) -> Optional[str]:
release_changelog: str = '' release_changelog: str = ''
with open('CHANGELOG.md', 'r') as f: with open('CHANGELOG.md', 'r') as f:
@ -45,13 +41,13 @@ def fetch_job_ids(project_id: int, pipeline_id: int, api_token: str) -> Dict[str
print(e.read().decode()) print(e.read().decode())
sys.exit(1) sys.exit(1)
resp_data: bytes = resp.read() resp_data: bytes = resp.read()
joblist: List[Dict[str, Any]] = decoder.decode(resp_data.decode()) joblist: List[Dict[str, Any]] = json.loads(resp_data.decode())
jobidmap: Dict[str, str] = {} jobidmap: Dict[str, str] = {}
for job in joblist: for job in joblist:
name: str = job['name'] name: str = job['name']
id: str = job['id'] job_id: str = job['id']
jobidmap[name] = id jobidmap[name] = job_id
return jobidmap return jobidmap
@ -136,12 +132,13 @@ def main():
- [Arch Linux Package]({arch_url}) ([sha256]({arch_sha_url})) - [Arch Linux Package]({arch_url}) ([sha256]({arch_sha_url}))
- Docker image: registry.gitlab.com/{project_name}:{release_tag}''' - Docker image: registry.gitlab.com/{project_name}:{release_tag}'''
post_body: str = encoder.encode({'description': augmented_changelog}) post_body: str = json.dumps({'description': augmented_changelog})
gitlab_release_api_url: str = \ gitlab_release_api_url: str = \
f'https://gitlab.com/api/v4/projects/{project_id}/repository/tags/{release_tag}/release' f'https://gitlab.com/api/v4/projects/{project_id}/repository/tags/{release_tag}/release'
headers: Dict[str, str] = { headers: Dict[str, str] = {
'Private-Token': api_token 'Private-Token': api_token,
'Content-Type': 'application/json; charset=utf-8'
} }
request = urllib.request.Request( request = urllib.request.Request(
@ -157,7 +154,7 @@ def main():
sys.exit(1) sys.exit(1)
response_bytes: bytes = response.read() response_bytes: bytes = response.read()
response_str: str = response_bytes.decode() response_str: str = response_bytes.decode()
response_data: Dict[str, Any] = decoder.decode(response_str) response_data: Dict[str, Any] = json.loads(response_str)
if response_data['tag_name'] != release_tag: if response_data['tag_name'] != release_tag:
print('Something went wrong...', file=sys.stderr) print('Something went wrong...', file=sys.stderr)