update the base
This commit is contained in:
parent
9fd7f923d6
commit
e170ba0ec1
1 changed files with 32 additions and 9 deletions
|
@ -1,8 +1,9 @@
|
|||
import hashlib
|
||||
import logging
|
||||
import os
|
||||
import sys
|
||||
from datetime import datetime
|
||||
from glob import glob
|
||||
from pathlib import Path
|
||||
|
||||
from github import Github
|
||||
|
||||
|
@ -10,9 +11,23 @@ logging.basicConfig(level=logging.INFO, format="%(levelname)s: %(message)s")
|
|||
|
||||
api_key = os.getenv("api_key", None)
|
||||
current_date = datetime.today().strftime("%Y-%m-%d")
|
||||
path = glob(r"/__w/parch-iso-template/parch-iso-template/out/*.iso")[
|
||||
0
|
||||
] # edit this if your not use in workflow
|
||||
|
||||
|
||||
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.as_posix()
|
||||
|
||||
file_name = _path.name
|
||||
|
||||
hash = _compute_sha256(path)
|
||||
|
||||
repo_name = os.getenv("name", None)
|
||||
release_name = os.getenv("release_name", None)
|
||||
|
||||
|
@ -27,7 +42,8 @@ if not (repo_name and api_key and release_name):
|
|||
|
||||
|
||||
gh = Github(api_key)
|
||||
repo = gh.get_repo(f"parch-os/{repo_name}")
|
||||
print(repo_name, api_key)
|
||||
repo = gh.get_repo(f"parchlinux/{repo_name}")
|
||||
|
||||
release = repo.get_release(release_name)
|
||||
|
||||
|
@ -36,7 +52,14 @@ logging.info("statrting Upload ISO to release")
|
|||
release.upload_asset(path=path)
|
||||
logging.info("ISO upload is done")
|
||||
|
||||
logging.info("statrting Upload ISO gpg key to release")
|
||||
release.upload_asset(
|
||||
"/__w/parch-iso-template/parch-iso-template/iso/public.key"
|
||||
) # noqa: E501:w
|
||||
# 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