release.py: Use new Gitlab releases API
This commit is contained in:
parent
dc3f7101f0
commit
675e391ea5
1 changed files with 14 additions and 17 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
from typing import Any, Dict, List, Optional, Tuple
|
from typing import Any, Dict, List, Optional, Tuple
|
||||||
|
|
||||||
|
@ -28,7 +29,7 @@ def parse_changelog(tag: str) -> Optional[str]:
|
||||||
return release_changelog
|
return release_changelog
|
||||||
|
|
||||||
|
|
||||||
def fetch_job_ids(project_id: str, pipeline_id: str, api_token: str) -> Dict[str, str]:
|
def fetch_job_ids(project_id: int, pipeline_id: int, api_token: str) -> Dict[str, str]:
|
||||||
url: str = f'https://gitlab.com/api/v4/projects/{project_id}/pipelines/{pipeline_id}/jobs'
|
url: str = f'https://gitlab.com/api/v4/projects/{project_id}/pipelines/{pipeline_id}/jobs'
|
||||||
headers: Dict[str, str] = {
|
headers: Dict[str, str] = {
|
||||||
'Private-Token': api_token,
|
'Private-Token': api_token,
|
||||||
|
@ -51,10 +52,9 @@ def fetch_job_ids(project_id: str, pipeline_id: str, api_token: str) -> Dict[str
|
||||||
return jobidmap
|
return jobidmap
|
||||||
|
|
||||||
|
|
||||||
def fetch_single_shafile(url: str, api_token: str) -> str:
|
def fetch_single_shafile(url: str) -> str:
|
||||||
headers: Dict[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)
|
req = urllib.request.Request(url, headers=headers)
|
||||||
try:
|
try:
|
||||||
|
@ -68,20 +68,18 @@ def fetch_single_shafile(url: str, api_token: str) -> str:
|
||||||
return filename
|
return filename
|
||||||
|
|
||||||
|
|
||||||
def fetch_wheel_url(base_url: str, project_id: str, job_ids: Dict[str, str], api_token: str) -> Optional[Tuple[str, str]]:
|
def fetch_wheel_url(base_url: str, job_ids: Dict[str, str]) -> Optional[Tuple[str, str]]:
|
||||||
mybase: str = f'{base_url}/jobs/{job_ids["build_wheel"]}/artifacts/raw'
|
mybase: str = f'{base_url}/jobs/{job_ids["build_wheel"]}/artifacts/raw'
|
||||||
wheel_sha_url: str = f'https://gitlab.com/api/v4/projects/{project_id}/jobs/{job_ids["build_wheel"]}'\
|
wheel_sha_url: str = f'{mybase}/dist/SHA256SUMS'
|
||||||
'/artifacts/dist/SHA256SUMS'
|
wheel_filename: str = fetch_single_shafile(wheel_sha_url)
|
||||||
wheel_filename: str = fetch_single_shafile(wheel_sha_url, api_token)
|
|
||||||
wheel_url: str = f'{mybase}/dist/{wheel_filename}'
|
wheel_url: str = f'{mybase}/dist/{wheel_filename}'
|
||||||
return wheel_url, wheel_sha_url
|
return wheel_url, wheel_sha_url
|
||||||
|
|
||||||
|
|
||||||
def fetch_debian_url(base_url: str, project_id: str, job_ids: Dict[str, str], api_token: str) -> Optional[Tuple[str, str]]:
|
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'
|
mybase: str = f'{base_url}/jobs/{job_ids["build_debian"]}/artifacts/raw'
|
||||||
debian_sha_url: str = f'https://gitlab.com/api/v4/projects/{project_id}/jobs/{job_ids["build_debian"]}'\
|
debian_sha_url: str = f'{mybase}/package/debian/SHA256SUMS'
|
||||||
'/artifacts/package/debian/SHA256SUMS'
|
debian_filename: str = fetch_single_shafile(debian_sha_url)
|
||||||
debian_filename: str = fetch_single_shafile(debian_sha_url, api_token)
|
|
||||||
debian_url: str = f'{mybase}/package/debian/{debian_filename}'
|
debian_url: str = f'{mybase}/package/debian/{debian_filename}'
|
||||||
return debian_url, debian_sha_url
|
return debian_url, debian_sha_url
|
||||||
|
|
||||||
|
@ -117,17 +115,16 @@ def main():
|
||||||
|
|
||||||
base_url: str = f'https://gitlab.com/{project_name}/-'
|
base_url: str = f'https://gitlab.com/{project_name}/-'
|
||||||
|
|
||||||
wheel_url, wheel_sha_url = fetch_wheel_url(base_url, project_id, job_ids, api_token)
|
wheel_url, wheel_sha_url = fetch_wheel_url(base_url, job_ids)
|
||||||
debian_url, debian_sha_url = fetch_debian_url(base_url, project_id, job_ids, api_token)
|
debian_url, debian_sha_url = fetch_debian_url(base_url, job_ids)
|
||||||
|
|
||||||
augmented_changelog = f'''{changelog.strip()}
|
augmented_changelog = f'''{changelog.strip()}
|
||||||
|
|
||||||
### Download
|
### Download
|
||||||
|
|
||||||
- [Python Wheel]({wheel_url}) ([sha256]({wheel_sha_url}))
|
- [Python Wheel]({wheel_url}) ([sha256]({wheel_sha_url}))
|
||||||
- [Debian Package]({debian_url}) ([sha256]({debian_sha_url}))'''
|
- [Debian Package]({debian_url}) ([sha256]({debian_sha_url}))
|
||||||
# Docker currently not working
|
- Docker image: registry.gitlab.com/{project_name}:{release_tag}'''
|
||||||
# - Docker image: registry.gitlab.com/{project_name}:{release_tag}
|
|
||||||
|
|
||||||
post_body: str = json.dumps({
|
post_body: str = json.dumps({
|
||||||
'tag_name': release_tag,
|
'tag_name': release_tag,
|
||||||
|
|
Loading…
Reference in a new issue