Browse Source

tools: add custom private key option

Add -i option for release.sh that allows users to specify
non-default private key for ssh and scp commands.
Change argument parsing to getopts.

PR-URL: https://github.com/nodejs/node/pull/14401
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
Reviewed-By: Gibson Fahnestock <gibfahn@gmail.com>
v6.x
Ruslan Bekenev 8 years ago
committed by Myles Borins
parent
commit
8b3ac4b2a2
No known key found for this signature in database GPG Key ID: 933B01F40B5CA946
  1. 43
      tools/release.sh

43
tools/release.sh

@ -13,7 +13,28 @@ webuser=dist
promotablecmd=dist-promotable promotablecmd=dist-promotable
promotecmd=dist-promote promotecmd=dist-promote
signcmd=dist-sign signcmd=dist-sign
customsshkey="" # let ssh and scp use default key
signversion=""
while getopts ":i:s:" option; do
case "${option}" in
i)
customsshkey="-i ${OPTARG}"
;;
s)
signversion="${OPTARG}"
;;
\?)
echo "Invalid option -$OPTARG."
exit 1
;;
:)
echo "Option -$OPTARG takes a parameter."
exit 1
;;
esac
done
shift $((OPTIND-1))
################################################################################ ################################################################################
## Select a GPG key to use ## Select a GPG key to use
@ -81,7 +102,7 @@ function sign {
exit 1 exit 1
fi fi
shapath=$(ssh ${webuser}@${webhost} $signcmd nodejs $version) shapath=$(ssh ${customsshkey} ${webuser}@${webhost} $signcmd nodejs $version)
if ! [[ ${shapath} =~ ^/.+/SHASUMS256.txt$ ]]; then if ! [[ ${shapath} =~ ^/.+/SHASUMS256.txt$ ]]; then
echo 'Error: No SHASUMS file returned by sign!' echo 'Error: No SHASUMS file returned by sign!'
@ -96,7 +117,7 @@ function sign {
mkdir -p $tmpdir mkdir -p $tmpdir
scp ${webuser}@${webhost}:${shapath} ${tmpdir}/${shafile} scp ${customsshkey} ${webuser}@${webhost}:${shapath} ${tmpdir}/${shafile}
gpg --default-key $gpgkey --clearsign --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} gpg --default-key $gpgkey --detach-sign --digest-algo SHA256 ${tmpdir}/${shafile}
@ -119,7 +140,7 @@ function sign {
fi fi
if [ "X${yorn}" == "Xy" ]; then if [ "X${yorn}" == "Xy" ]; then
scp ${tmpdir}/${shafile} ${tmpdir}/${shafile}.asc ${tmpdir}/${shafile}.sig ${webuser}@${webhost}:${shadir}/ scp ${customsshkey} ${tmpdir}/${shafile} ${tmpdir}/${shafile}.asc ${tmpdir}/${shafile}.sig ${webuser}@${webhost}:${shadir}/
break break
fi fi
done done
@ -128,17 +149,11 @@ function sign {
} }
if [ "X${1}" == "X-s" ]; then if [ -n "${signversion}" ]; then
if [ "X${2}" == "X" ]; then sign ${signversion}
echo "Please supply a version string to sign"
exit 1
fi
sign $2
exit 0 exit 0
fi fi
# else: do a normal release & promote # else: do a normal release & promote
################################################################################ ################################################################################
@ -146,7 +161,7 @@ fi
echo -e "\n# Checking for releases ..." echo -e "\n# Checking for releases ..."
promotable=$(ssh ${webuser}@${webhost} $promotablecmd nodejs) promotable=$(ssh ${customsshkey} ${webuser}@${webhost} $promotablecmd nodejs)
if [ "X${promotable}" == "X" ]; then if [ "X${promotable}" == "X" ]; then
echo "No releases to promote!" echo "No releases to promote!"
@ -179,7 +194,7 @@ for version in $versions; do
echo -e "\n# Promoting ${version}..." echo -e "\n# Promoting ${version}..."
ssh ${webuser}@${webhost} $promotecmd nodejs $version ssh ${customsshkey} ${webuser}@${webhost} $promotecmd nodejs $version
sign $version sign $version

Loading…
Cancel
Save