tools: update upload asset to 'update release's msg' with 'ISO hash'
This commit is contained in:
parent
13a7ccc951
commit
fd0a393b4e
1 changed files with 31 additions and 2 deletions
|
@ -1,8 +1,10 @@
|
||||||
|
import hashlib
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from github import Github
|
from github import Github
|
||||||
|
|
||||||
logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s")
|
logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s")
|
||||||
|
@ -10,7 +12,21 @@ logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s")
|
||||||
api_key = os.getenv("api_key", None)
|
api_key = os.getenv("api_key", None)
|
||||||
current_date = datetime.today().strftime("%Y-%m-%d")
|
current_date = datetime.today().strftime("%Y-%m-%d")
|
||||||
|
|
||||||
path = list(Path().cwd().glob("out/*.iso"))[0].as_posix()
|
|
||||||
|
def _compute_sha256(file_name):
|
||||||
|
hash_sha256 = hashlib.sha256()
|
||||||
|
with open(file_name, "rb") as f:
|
||||||
|
for chunk in iter(lambda: f.read(4096), b""):
|
||||||
|
hash_sha256.update(chunk)
|
||||||
|
return hash_sha256.hexdigest()
|
||||||
|
|
||||||
|
|
||||||
|
_path = list(Path().cwd().glob("out/*.iso"))[0]
|
||||||
|
path = _path.posix_path()
|
||||||
|
|
||||||
|
file_name = _path.name
|
||||||
|
|
||||||
|
hash = _compute_sha256(path)
|
||||||
|
|
||||||
repo_name = os.getenv("name", None)
|
repo_name = os.getenv("name", None)
|
||||||
release_name = os.getenv("release_name", None)
|
release_name = os.getenv("release_name", None)
|
||||||
|
@ -26,7 +42,8 @@ if not (repo_name and api_key and release_name):
|
||||||
|
|
||||||
|
|
||||||
gh = Github(api_key)
|
gh = Github(api_key)
|
||||||
repo = gh.get_repo(f"parchlinux/{repo_name}")
|
print(repo_name, api_key)
|
||||||
|
repo = gh.get_repo(f"parchlinux/parch-iso-cinnamon")
|
||||||
|
|
||||||
release = repo.get_release(release_name)
|
release = repo.get_release(release_name)
|
||||||
|
|
||||||
|
@ -34,3 +51,15 @@ logging.info("statrting Upload ISO to release")
|
||||||
|
|
||||||
release.upload_asset(path=path)
|
release.upload_asset(path=path)
|
||||||
logging.info("ISO upload is done")
|
logging.info("ISO upload is done")
|
||||||
|
|
||||||
|
# update release
|
||||||
|
msg = (
|
||||||
|
release.body
|
||||||
|
+ f"""
|
||||||
|
| name | sha256 |
|
||||||
|
| :---: | :---: |
|
||||||
|
| {file_name} | {hash} |"""
|
||||||
|
)
|
||||||
|
logging.info("Starting Update release msg with: \n %s" % msg)
|
||||||
|
release.update_release(name=release.tag_name, message=msg)
|
||||||
|
logging.info("Release Update is done.")
|
Loading…
Add table
Reference in a new issue