diff --git a/entrypoint.sh b/entrypoint.sh index 83a4f8e..ef732e5 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,11 +2,13 @@ dir="$(dirname "${INPUT_FILES}")" glob="$(basename "${INPUT_FILES}")" +# Pass these through sort so we can have deterministic output indexing if [ "${glob}" = "**" ]; then - all_files="$(find "$dir" -type f)" + all_files="$(find "$dir" -type f |sort)" else - all_files="$(find "$dir" -maxdepth 1 -name "${glob}")" + all_files="$(find "$dir" -maxdepth 1 -name "${glob}" |sort)" fi +i=0 while IFS= read -r f; do sign_dir="$(dirname "$f")" sign_file="$(basename "$f")" @@ -35,8 +37,13 @@ while IFS= read -r f; do echo "Fetching key from ${INPUT_PUBLIC_KEY}" curl -sLo /tmp/public_key "${INPUT_PUBLIC_KEY}" ec=$?; if [ $ec -ne 0 ]; then exit $ec; fi - rekor upload --artifact "$f" --signature "${dest_sig}" --pki-format x509 --public-key /tmp/public_key - ec=$?; if [ $ec -ne 0 ]; then exit $ec; fi + output=$(rekor upload --artifact "$f" --signature "${dest_sig}" --pki-format x509 --public-key /tmp/public_key) + ec=$?; echo "$output"; if [ $ec -ne 0 ]; then exit $ec; fi + echo "INDEX_${i}=$(echo "$output"|cut -d, -f1|cut -d\ -f5)" >> "${GITHUB_OUTPUT}" + echo "URL_${i}=$(echo "$output"|cut -d: -f2-|cut -d\ -f2)" >> "${GITHUB_OUTPUT}" + echo "SOURCE_${i}=${f}" >> "${GITHUB_OUTPUT}" + echo "SIG_${i}=${dest_sig}" >> "${GITHUB_OUTPUT}" + i=$((i+1)) fi done <