@@ -15,15 +15,25 @@ webuser=dist
1515promotablecmd=dist-promotable
1616promotecmd=dist-promote
1717signcmd=dist-sign
18+ allPGPKeys=" "
1819customsshkey=" " # let ssh and scp use default key
20+ readmePath=" README.md"
1921signversion=" "
2022cloudflare_bucket=" r2:dist-prod"
2123
22- while getopts " :i:s: " option; do
24+ while getopts " :i:r:s:a " option; do
2325 case " ${option} " in
26+ a)
27+ # With -a, local keys are not filtered based on the one listed in the README
28+ # useful if you want to sign with a subkey.
29+ allPGPKeys=" true"
30+ ;;
2431 i)
2532 customsshkey=" -i ${OPTARG} "
2633 ;;
34+ r)
35+ readmePath=" ${OPTARG} "
36+ ;;
2737 s)
2838 signversion=" ${OPTARG} "
2939 ;;
@@ -44,7 +54,16 @@ shift $((OPTIND-1))
4454
4555echo " # Selecting GPG key ..."
4656
47- gpgkey=$( gpg --list-secret-keys --keyid-format SHORT | awk -F' ( +|/)' ' /^(sec|ssb)/{print $3}' )
57+
58+ if [ -z " $allPGPKeys " ]; then
59+ gpgkey=" $( awk ' {
60+ if ($1 == "gpg" && $2 == "--keyserver" && $4 == "--recv-keys" && (1 == 2' " $(
61+ gpg --list-secret-keys | awk -F' = ' ' /^ +Key fingerprint/{ gsub(/ /,"",$2); print " || $5 == \"" $2 "\"" }' || true
62+ ) " ' )) { print substr($5, 33) }
63+ }' " $readmePath " ) "
64+ else
65+ gpgkey=$( gpg --list-secret-keys --keyid-format SHORT | awk -F' ( +|/)' ' /^(sec|ssb)/{print $3}' )
66+ fi
4867keycount=$( echo " $gpgkey " | wc -w)
4968
5069if [ " $keycount " -eq 0 ]; then
@@ -68,13 +87,12 @@ elif [ "$keycount" -ne 1 ]; then
6887 gpgkey=$( echo " $gpgkey " | sed -n " ${keynum} p" )
6988fi
7089
71- gpgfing=$( gpg --keyid-format 0xLONG --fingerprint " $gpgkey " | grep ' Key fingerprint =' | awk -F' = ' ' {print $2}' | tr -d ' ' )
72-
73- grep -q " $gpgfing " README.md || (\
74- echo ' Error: this GPG key fingerprint is not listed in ./README.md' && \
75- exit 1 \
76- )
90+ gpgfing=$( gpg --keyid-format 0xLONG --fingerprint " $gpgkey " | awk -F' = ' ' /^ +Key fingerprint/{gsub(/ /,"",$2);print $2}' )
7791
92+ grep -q " $gpgfing " " $readmePath " || {
93+ echo " Error: this GPG key fingerprint is not listed in $readmePath "
94+ exit 1
95+ }
7896
7997echo " Using GPG key: $gpgkey "
8098echo " Fingerprint: $gpgfing "
0 commit comments