Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tools: add custom private key option for release.sh #14401

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 30 additions & 15 deletions tools/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,28 @@ webuser=dist
promotablecmd=dist-promotable
promotecmd=dist-promote
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
Expand Down Expand Up @@ -81,7 +102,7 @@ function sign {
exit 1
fi

shapath=$(ssh ${webuser}@${webhost} $signcmd nodejs $version)
shapath=$(ssh ${customsshkey} ${webuser}@${webhost} $signcmd nodejs $version)

if ! [[ ${shapath} =~ ^/.+/SHASUMS256.txt$ ]]; then
echo 'Error: No SHASUMS file returned by sign!'
Expand All @@ -96,7 +117,7 @@ function sign {

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 --detach-sign --digest-algo SHA256 ${tmpdir}/${shafile}
Expand All @@ -119,7 +140,7 @@ function sign {
fi

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
fi
done
Expand All @@ -128,25 +149,19 @@ function sign {
}


if [ "X${1}" == "X-s" ]; then
if [ "X${2}" == "X" ]; then
echo "Please supply a version string to sign"
exit 1
fi

sign $2
exit 0
if [ -n "${signversion}" ]; then
sign ${signversion}
exit 0
fi


# else: do a normal release & promote

################################################################################
## Look for releases to promote

echo -e "\n# Checking for releases ..."

promotable=$(ssh ${webuser}@${webhost} $promotablecmd nodejs)
promotable=$(ssh ${customsshkey} ${webuser}@${webhost} $promotablecmd nodejs)

if [ "X${promotable}" == "X" ]; then
echo "No releases to promote!"
Expand Down Expand Up @@ -179,7 +194,7 @@ for version in $versions; do

echo -e "\n# Promoting ${version}..."

ssh ${webuser}@${webhost} $promotecmd nodejs $version
ssh ${customsshkey} ${webuser}@${webhost} $promotecmd nodejs $version

sign $version

Expand Down