From 5fbb658651027365ff1c73e2fd6f482f36684e47 Mon Sep 17 00:00:00 2001 From: s3lph Date: Tue, 28 Sep 2021 01:51:02 +0200 Subject: [PATCH] Fix release.py script --- package/release.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/package/release.py b/package/release.py index 07f6a54..831a903 100755 --- a/package/release.py +++ b/package/release.py @@ -51,9 +51,10 @@ def fetch_job_ids(project_id: str, pipeline_id: str, api_token: str) -> Dict[str return jobidmap -def fetch_single_shafile(url: str) -> str: +def fetch_single_shafile(url: str, api_token: str) -> str: headers: Dict[str, str] = { - 'User-Agent': 'curl/7.70.0' + 'User-Agent': 'curl/7.70.0', + 'Private-Token': api_token } req = urllib.request.Request(url, headers=headers) try: @@ -67,18 +68,20 @@ def fetch_single_shafile(url: str) -> str: return filename -def fetch_wheel_url(base_url: str, job_ids: Dict[str, str]) -> Optional[Tuple[str, str]]: +def fetch_wheel_url(base_url: str, project_id: str, job_ids: Dict[str, str], api_token: str) -> Optional[Tuple[str, str]]: mybase: str = f'{base_url}/jobs/{job_ids["build_wheel"]}/artifacts/raw' - wheel_sha_url: str = f'{mybase}/dist/SHA256SUMS' - wheel_filename: str = fetch_single_shafile(wheel_sha_url) + wheel_sha_url: str = f'https://gitlab.com/api/v4/projects/{project_id}/jobs/{job_ids["build_wheel"]}'\ + '/artifacts/dist/SHA256SUMS' + wheel_filename: str = fetch_single_shafile(wheel_sha_url, api_token) wheel_url: str = f'{mybase}/dist/{wheel_filename}' return wheel_url, wheel_sha_url -def fetch_debian_url(base_url: str, job_ids: Dict[str, str]) -> Optional[Tuple[str, str]]: - mybase: str = f'{base_url}/jobs/{job_ids["build_debian"]}/artifacts/raw' - debian_sha_url: str = f'{mybase}/package/debian/SHA256SUMS' - debian_filename: str = fetch_single_shafile(debian_sha_url) +def fetch_debian_url(base_url: str, project_id: str, job_ids: Dict[str, str], api_token: str) -> Optional[Tuple[str, str]]: + mybase: str = f'{base_url}/jobs/{job_ids["build_wheel"]}/artifacts/raw' + debian_sha_url: str = f'https://gitlab.com/api/v4/projects/{project_id}/jobs/{job_ids["build_debian"]}'\ + '/artifacts/package/debian/SHA256SUMS' + debian_filename: str = fetch_single_shafile(debian_sha_url, api_token) debian_url: str = f'{mybase}/package/debian/{debian_filename}' return debian_url, debian_sha_url @@ -114,8 +117,8 @@ def main(): base_url: str = f'https://gitlab.com/{project_name}/-' - wheel_url, wheel_sha_url = fetch_wheel_url(base_url, job_ids) - debian_url, debian_sha_url = fetch_debian_url(base_url, job_ids) + wheel_url, wheel_sha_url = fetch_wheel_url(base_url, project_id, job_ids, api_token) + debian_url, debian_sha_url = fetch_debian_url(base_url, project_id, job_ids, api_token) augmented_changelog = f'''{changelog.strip()}