mirror of
https://github.com/pypa/gh-action-pypi-publish.git
synced 2024-12-28 01:44:47 -05:00
Show hash values of files uploaded
This commit is contained in:
parent
bea5cda687
commit
e5cc29fe08
2 changed files with 31 additions and 0 deletions
|
@ -30,6 +30,10 @@ inputs:
|
|||
description: Show verbose output.
|
||||
required: false
|
||||
default: false
|
||||
print_hash:
|
||||
description: Show hash values of files uploaded
|
||||
required: false
|
||||
default: false
|
||||
branding:
|
||||
color: yellow
|
||||
icon: upload-cloud
|
||||
|
@ -44,3 +48,4 @@ runs:
|
|||
- ${{ inputs.verify_metadata }}
|
||||
- ${{ inputs.skip_existing }}
|
||||
- ${{ inputs.verbose }}
|
||||
- ${{ inputs.print_hash }}
|
||||
|
|
|
@ -48,3 +48,29 @@ 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