mirror of
https://github.com/pypa/gh-action-pypi-publish.git
synced 2024-12-27 09:32:15 -05:00
Move out the Python script from the shell script
This commit is contained in:
parent
e5cc29fe08
commit
77ee113713
3 changed files with 29 additions and 27 deletions
|
@ -31,7 +31,7 @@ inputs:
|
|||
required: false
|
||||
default: false
|
||||
print_hash:
|
||||
description: Show hash values of files uploaded
|
||||
description: Show hash values of files to be uploaded
|
||||
required: false
|
||||
default: false
|
||||
branding:
|
||||
|
|
24
print-hash.py
Executable file
24
print-hash.py
Executable file
|
@ -0,0 +1,24 @@
|
|||
import os
|
||||
import hashlib
|
||||
|
||||
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")))
|
||||
|
||||
for file in file_list:
|
||||
print(file)
|
||||
print("")
|
||||
|
||||
with open(os.path.abspath(os.path.join(os.getenv("INPUT_PACKAGES_DIR"), file)), "rb") as f:
|
||||
content = f.read()
|
||||
|
||||
sha256.update(content)
|
||||
md5.update(content)
|
||||
blake2_256.update(content)
|
||||
|
||||
print(f"SHA256: {sha256.hexdigest()}")
|
||||
print(f"MD5: {md5.hexdigest()}")
|
||||
print(f"BLAKE2-256: {blake2_256.hexdigest()}")
|
||||
print("")
|
|
@ -44,33 +44,11 @@ if [[ ${INPUT_VERBOSE,,} != "false" ]] ; then
|
|||
TWINE_EXTRA_ARGS="--verbose $TWINE_EXTRA_ARGS"
|
||||
fi
|
||||
|
||||
if [[ ${INPUT_PRINT_HASH,,} || ${INPUT_VERBOSE,,} != "false" ]] ; then
|
||||
python ./print-hash.py
|
||||
fi
|
||||
|
||||
TWINE_USERNAME="$INPUT_USER" \
|
||||
TWINE_PASSWORD="$INPUT_PASSWORD" \
|
||||
TWINE_REPOSITORY_URL="$INPUT_REPOSITORY_URL" \
|
||||
exec twine upload ${TWINE_EXTRA_ARGS} ${INPUT_PACKAGES_DIR%%/}/*
|
||||
|
||||
if [[ ${INPUT_PRINT_HASH,,} != "false" ]] ; then
|
||||
cat > ./print_hash.py << EOF
|
||||
import os
|
||||
import hashlib
|
||||
sha256 = hashlib.sha256()
|
||||
md5 = hashlib.md5()
|
||||
blake2_256 = hashlib.blake2b(digest_size=256 // 8)
|
||||
file_list = os.listdir(os.path.abspath("${INPUT_PACKAGES_DIR%%/}"))
|
||||
for i in file_list:
|
||||
print(i)
|
||||
print("")
|
||||
file = open(os.path.abspath(os.path.join("${INPUT_PACKAGES_DIR%%/}", i)), "rb")
|
||||
content = file.read()
|
||||
file.close()
|
||||
sha256.update(content)
|
||||
md5.update(content)
|
||||
blake2_256.update(content)
|
||||
print(f"SHA256: {sha256.hexdigest()}")
|
||||
print(f"MD5: {md5.hexdigest()}")
|
||||
print(f"BLAKE2-256: {blake2_256.hexdigest()}")
|
||||
print("")
|
||||
EOF
|
||||
python ./print_hash.py
|
||||
rm ./print_hash.py
|
||||
fi
|
Loading…
Reference in a new issue