2021-10-16 22:37:18 -07:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Fail on any error.
|
|
|
|
set -e
|
|
|
|
|
|
|
|
version=$1
|
|
|
|
packages=${@:2}
|
|
|
|
|
2021-10-21 15:54:29 -07:00
|
|
|
echo "::group::Create Cache Key"
|
2021-10-16 22:37:18 -07:00
|
|
|
|
|
|
|
# Remove package delimiters, sort (requires newline) and then convert back to inline list.
|
|
|
|
normalized_list=$(echo $packages | sed 's/[\s,]+/ /g' | tr ' ' '\n' | sort | tr '\n' ' ')
|
2021-10-21 15:54:29 -07:00
|
|
|
echo "::debug::Normalized package list is '$normalized_list'."
|
2021-10-16 22:37:18 -07:00
|
|
|
|
|
|
|
value=$(echo $normalized_list @ $version)
|
2021-10-21 15:54:29 -07:00
|
|
|
echo "::debug::Value to hash is '$value'."
|
2021-10-16 22:37:18 -07:00
|
|
|
|
|
|
|
key=$(echo $value | md5sum | /bin/cut -f1 -d' ')
|
2021-10-21 15:54:29 -07:00
|
|
|
echo "::debug::Value hashed as '$key'."
|
|
|
|
|
|
|
|
echo "::endgroup::"
|
2021-10-16 22:37:18 -07:00
|
|
|
|
2021-10-16 22:46:41 -07:00
|
|
|
echo "CACHE_KEY=$key" >> $GITHUB_ENV
|