Skip to content

Commit

Permalink
tools: fix release script
Browse files Browse the repository at this point in the history
PR-URL: #36540
Refs: #36123
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Beth Griggs <bgriggs@redhat.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Myles Borins <myles.borins@gmail.com>
  • Loading branch information
aduh95 authored and nodejs-github-bot committed Dec 17, 2020
1 parent 32d58d7 commit f28715d
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions tools/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,17 +57,17 @@ elif [ "$keycount" -ne 1 ]; then

keynum=
while [ -z "${keynum##*[!0-9]*}" ] || [ "$keynum" -le 0 ] || [ "$keynum" -gt "$keycount" ]; do
echo "$gpgkey" | awk '{ for(i = 1; i <= NF; i++) { print i ") " $i; } }'
echo "$gpgkey" | awk '{ print NR ") " $0; }'
printf 'Select a key: '
read -r keynum
done
echo ""
gpgkey=$(echo "$gpgkey" | awk "{ print \$${keynum}}")
gpgkey=$(echo "$gpgkey" | sed -n "${keynum}p")
fi

gpgfing=$(gpg --keyid-format 0xLONG --fingerprint "$gpgkey" | grep 'Key fingerprint =' | awk -F' = ' '{print $2}' | tr -d ' ')

grep "$gpgfing" README.md || (\
grep -q "$gpgfing" README.md || (\
echo 'Error: this GPG key fingerprint is not listed in ./README.md' && \
exit 1 \
)
Expand All @@ -93,15 +93,15 @@ sign() {

# local version=$1

ghtaggedversion=$(curl -sL https://raw.githubusercontent.com/nodejs/node/"$1"/src/node_version.h \
ghtaggedversion=$(curl -sL "https://raw.githubusercontent.com/nodejs/node/$1/src/node_version.h" \
| awk '/define NODE_(MAJOR|MINOR|PATCH)_VERSION/{ v = v "." $3 } END{ v = "v" substr(v, 2); print v }')
if [ "$1" != "${ghtaggedversion}" ]; then
echo "Could not find tagged version on github.com/nodejs/node, did you push your tag?"
exit 1
fi

# shellcheck disable=SC2029
shapath=$(ssh "${customsshkey}" "${webuser}@${webhost}" $signcmd nodejs "$1")
# shellcheck disable=SC2086,SC2029
shapath=$(ssh ${customsshkey} "${webuser}@${webhost}" $signcmd nodejs $1)

echo "${shapath}" | grep -q '^/.*/SHASUMS256.txt$' || \
echo 'Error: No SHASUMS file returned by sign!' \
Expand All @@ -116,10 +116,11 @@ sign() {

mkdir -p $tmpdir

scp "${customsshkey}" "${webuser}@${webhost}:${shapath}" "${tmpdir}/${shafile}"
# shellcheck disable=SC2086
scp ${customsshkey} "${webuser}@${webhost}:${shapath}" "${tmpdir}/${shafile}"

gpg --default-key "$gpgkey" --clearsign --digest-algo SHA256 ${tmpdir}/"${shafile}"
gpg --default-key "$gpgkey" --detach-sign --digest-algo SHA256 ${tmpdir}/"${shafile}"
gpg --default-key "$gpgkey" --clearsign --digest-algo SHA256 "${tmpdir}/${shafile}"
gpg --default-key "$gpgkey" --detach-sign --digest-algo SHA256 "${tmpdir}/${shafile}"

echo "Wrote to ${tmpdir}/"

Expand All @@ -141,8 +142,8 @@ sign() {

if [ "X${yorn}" = "Xy" ]; then
scp "${customsshkey}" "${tmpdir}/${shafile}" "${tmpdir}/${shafile}.asc" "${tmpdir}/${shafile}.sig" "${webuser}@${webhost}:${shadir}/"
#shellcheck disable=SC2029
ssh "${customsshkey}" "${webuser}@${webhost}" chmod 644 "${shadir}/${shafile}.asc" "${shadir}/${shafile}.sig"
# shellcheck disable=SC2086,SC2029
ssh ${customsshkey} "${webuser}@${webhost}" chmod 644 "${shadir}/${shafile}.asc" "${shadir}/${shafile}.sig"
break
fi
done
Expand All @@ -164,7 +165,8 @@ fi

printf "\n# Checking for releases ...\n"

promotable=$(ssh "${customsshkey}" "$webuser@$webhost" $promotablecmd nodejs)
# shellcheck disable=SC2086,SC2029
promotable=$(ssh ${customsshkey} "$webuser@$webhost" $promotablecmd nodejs)

if [ "X${promotable}" = "X" ]; then
echo "No releases to promote!"
Expand Down Expand Up @@ -201,8 +203,8 @@ for version in $versions; do
echo ""
echo "# Promoting ${version}..."

# shellcheck disable=SC2029
ssh "${customsshkey}" "$webuser@$webhost" $promotecmd nodejs "$version" && \
# shellcheck disable=SC2086,SC2029
ssh ${customsshkey} "$webuser@$webhost" $promotecmd nodejs $version && \
sign "$version"

break
Expand Down

0 comments on commit f28715d

Please sign in to comment.