Skip to content

Commit e5cc29f

Browse files
committed
Show hash values of files uploaded
1 parent bea5cda commit e5cc29f

File tree

2 files changed

+31
-0
lines changed

2 files changed

+31
-0
lines changed

action.yml

+5
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,10 @@ inputs:
3030
description: Show verbose output.
3131
required: false
3232
default: false
33+
print_hash:
34+
description: Show hash values of files uploaded
35+
required: false
36+
default: false
3337
branding:
3438
color: yellow
3539
icon: upload-cloud
@@ -44,3 +48,4 @@ runs:
4448
- ${{ inputs.verify_metadata }}
4549
- ${{ inputs.skip_existing }}
4650
- ${{ inputs.verbose }}
51+
- ${{ inputs.print_hash }}

twine-upload.sh

+26
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,29 @@ TWINE_USERNAME="$INPUT_USER" \
4848
TWINE_PASSWORD="$INPUT_PASSWORD" \
4949
TWINE_REPOSITORY_URL="$INPUT_REPOSITORY_URL" \
5050
exec twine upload ${TWINE_EXTRA_ARGS} ${INPUT_PACKAGES_DIR%%/}/*
51+
52+
if [[ ${INPUT_PRINT_HASH,,} != "false" ]] ; then
53+
cat > ./print_hash.py << EOF
54+
import os
55+
import hashlib
56+
sha256 = hashlib.sha256()
57+
md5 = hashlib.md5()
58+
blake2_256 = hashlib.blake2b(digest_size=256 // 8)
59+
file_list = os.listdir(os.path.abspath("${INPUT_PACKAGES_DIR%%/}"))
60+
for i in file_list:
61+
print(i)
62+
print("")
63+
file = open(os.path.abspath(os.path.join("${INPUT_PACKAGES_DIR%%/}", i)), "rb")
64+
content = file.read()
65+
file.close()
66+
sha256.update(content)
67+
md5.update(content)
68+
blake2_256.update(content)
69+
print(f"SHA256: {sha256.hexdigest()}")
70+
print(f"MD5: {md5.hexdigest()}")
71+
print(f"BLAKE2-256: {blake2_256.hexdigest()}")
72+
print("")
73+
EOF
74+
python ./print_hash.py
75+
rm ./print_hash.py
76+
fi

0 commit comments

Comments
 (0)