mirror of
https://github.com/pypa/gh-action-pypi-publish.git
synced 2024-11-22 00:21:08 -05:00
Refactor the hash helper script to use pathlib and CLI args
This commit is contained in:
parent
8682135dac
commit
0575dc8eab
2 changed files with 8 additions and 7 deletions
|
@ -1,20 +1,21 @@
|
|||
import os
|
||||
import hashlib
|
||||
import pathlib
|
||||
import sys
|
||||
|
||||
sha256 = hashlib.sha256()
|
||||
md5 = hashlib.md5()
|
||||
blake2_256 = hashlib.blake2b(digest_size=256 // 8)
|
||||
|
||||
file_list = os.listdir(os.path.abspath(os.getenv("INPUT_PACKAGES_DIR")))
|
||||
packages_dir = pathlib.Path(sys.argv[1]).resolve().absolute()
|
||||
file_iterable = packages_dir.iterdir()
|
||||
|
||||
print("Showing hash values of files to be uploaded:")
|
||||
|
||||
for file in file_list:
|
||||
print(file)
|
||||
for file_object in file_iterable:
|
||||
print(file_object)
|
||||
print("")
|
||||
|
||||
with open(os.path.abspath(os.path.join(os.getenv("INPUT_PACKAGES_DIR"), file)), "rb") as f:
|
||||
content = f.read()
|
||||
content = file_object.read_bytes()
|
||||
|
||||
sha256.update(content)
|
||||
md5.update(content)
|
||||
|
|
|
@ -45,7 +45,7 @@ if [[ ${INPUT_VERBOSE,,} != "false" ]] ; then
|
|||
fi
|
||||
|
||||
if [[ ${INPUT_PRINT_HASH,,} != "false" || ${INPUT_VERBOSE,,} != "false" ]] ; then
|
||||
python /app/print-hash.py
|
||||
python /app/print-hash.py "${INPUT_PACKAGES_DIR%%/}"
|
||||
fi
|
||||
|
||||
TWINE_USERNAME="$INPUT_USER" \
|
||||
|
|
Loading…
Reference in a new issue