From 54ca432ee7e019beb0d753e89a10132ed6cf8e8d Mon Sep 17 00:00:00 2001 From: s3lph Date: Sun, 4 Nov 2018 10:43:50 +0100 Subject: [PATCH] Added missing MIME type header in release script --- package/release.py | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/package/release.py b/package/release.py index 44dd32b..d9a6c2a 100755 --- a/package/release.py +++ b/package/release.py @@ -10,10 +10,6 @@ import http.client from urllib.error import HTTPError -encoder = json.encoder.JSONEncoder() -decoder = json.decoder.JSONDecoder() - - def parse_changelog(tag: str) -> Optional[str]: release_changelog: str = '' 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()) sys.exit(1) 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] = {} for job in joblist: name: str = job['name'] - id: str = job['id'] - jobidmap[name] = id + job_id: str = job['id'] + jobidmap[name] = job_id return jobidmap @@ -136,12 +132,13 @@ def main(): - [Arch Linux Package]({arch_url}) ([sha256]({arch_sha_url})) - 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 = \ f'https://gitlab.com/api/v4/projects/{project_id}/repository/tags/{release_tag}/release' headers: Dict[str, str] = { - 'Private-Token': api_token + 'Private-Token': api_token, + 'Content-Type': 'application/json; charset=utf-8' } request = urllib.request.Request( @@ -157,7 +154,7 @@ def main(): sys.exit(1) response_bytes: bytes = response.read() 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: print('Something went wrong...', file=sys.stderr)