2015-01-31 11:55:37 +01:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
# To promote and sign a release that has been prepared by the build slaves, use:
|
|
|
|
# release.sh
|
|
|
|
|
|
|
|
# To _only_ sign an existing release, use:
|
|
|
|
# release.sh -s vx.y.z
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
2015-08-31 08:01:01 +02:00
|
|
|
webhost=direct.nodejs.org
|
2015-01-31 11:55:37 +01:00
|
|
|
webuser=dist
|
|
|
|
promotablecmd=dist-promotable
|
|
|
|
promotecmd=dist-promote
|
|
|
|
signcmd=dist-sign
|
2017-07-20 20:16:43 +02:00
|
|
|
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))
|
2015-01-31 11:55:37 +01:00
|
|
|
|
|
|
|
################################################################################
|
|
|
|
## Select a GPG key to use
|
|
|
|
|
|
|
|
echo "# Selecting GPG key ..."
|
|
|
|
|
2017-05-30 20:47:23 +02:00
|
|
|
gpgkey=$(gpg --list-secret-keys --keyid-format SHORT | awk -F'( +|/)' '/^(sec|ssb)/{print $3}')
|
2015-01-31 11:55:37 +01:00
|
|
|
keycount=$(echo $gpgkey | wc -w)
|
|
|
|
|
|
|
|
if [ $keycount -eq 0 ]; then
|
|
|
|
echo 'Need at least one GPG key, please make one with `gpg --gen-key`'
|
|
|
|
echo 'You will also need to submit your key to a public keyserver, e.g.'
|
|
|
|
echo ' https://sks-keyservers.net/i/#submit'
|
|
|
|
exit 1
|
|
|
|
elif [ $keycount -ne 1 ]; then
|
|
|
|
echo -e 'You have multiple GPG keys:\n'
|
|
|
|
|
|
|
|
gpg --list-secret-keys
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
echo $gpgkey | awk '{ for(i = 1; i <= NF; i++) { print i ") " $i; } }'
|
|
|
|
echo -n 'Select a key: '
|
|
|
|
read keynum
|
|
|
|
|
|
|
|
if $(test "$keynum" -eq "$keynum" > /dev/null 2>&1); then
|
|
|
|
_gpgkey=$(echo $gpgkey | awk '{ print $'${keynum}'}')
|
|
|
|
keycount=$(echo $_gpgkey | wc -w)
|
|
|
|
if [ $keycount -eq 1 ]; then
|
|
|
|
echo ""
|
|
|
|
gpgkey=$_gpgkey
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2016-10-24 18:03:53 +02:00
|
|
|
gpgfing=$(gpg --keyid-format 0xLONG --fingerprint $gpgkey | grep 'Key fingerprint =' | awk -F' = ' '{print $2}' | tr -d ' ')
|
2015-01-31 11:55:37 +01:00
|
|
|
|
|
|
|
if ! test "$(grep $gpgfing README.md)"; then
|
|
|
|
echo 'Error: this GPG key fingerprint is not listed in ./README.md'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Using GPG key: $gpgkey"
|
|
|
|
echo " Fingerprint: $gpgfing"
|
|
|
|
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
## Create and sign checksums file for a given version
|
|
|
|
|
|
|
|
function sign {
|
|
|
|
echo -e "\n# Creating SHASUMS256.txt ..."
|
|
|
|
|
|
|
|
local version=$1
|
|
|
|
|
2016-09-28 12:59:08 +02:00
|
|
|
if ! git tag -v $version 2>&1 | grep "${gpgkey}" | grep key > /dev/null; then
|
|
|
|
echo "Could not find signed tag for \"${version}\" or GPG key is not yours"
|
2016-10-18 01:13:37 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
ghtaggedversion=$(curl -sL https://raw.githubusercontent.com/nodejs/node/${version}/src/node_version.h \
|
|
|
|
| awk '/define NODE_(MAJOR|MINOR|PATCH)_VERSION/{ v = v "." $3 } END{ v = "v" substr(v, 2); print v }')
|
|
|
|
if [ "${version}" != "${ghtaggedversion}" ]; then
|
|
|
|
echo "Could not find tagged version on github.com/nodejs/node, did you push your tag?"
|
|
|
|
exit 1
|
2015-01-31 11:55:37 +01:00
|
|
|
fi
|
|
|
|
|
2017-07-20 20:16:43 +02:00
|
|
|
shapath=$(ssh ${customsshkey} ${webuser}@${webhost} $signcmd nodejs $version)
|
2015-01-31 11:55:37 +01:00
|
|
|
|
|
|
|
if ! [[ ${shapath} =~ ^/.+/SHASUMS256.txt$ ]]; then
|
|
|
|
echo 'Error: No SHASUMS file returned by sign!'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -e "\n# Signing SHASUMS for ${version}..."
|
|
|
|
|
|
|
|
shafile=$(basename $shapath)
|
|
|
|
shadir=$(dirname $shapath)
|
2015-08-13 18:14:34 +02:00
|
|
|
tmpdir="/tmp/_node_release.$$"
|
2015-01-31 11:55:37 +01:00
|
|
|
|
|
|
|
mkdir -p $tmpdir
|
|
|
|
|
2017-07-20 20:16:43 +02:00
|
|
|
scp ${customsshkey} ${webuser}@${webhost}:${shapath} ${tmpdir}/${shafile}
|
2015-01-31 11:55:37 +01:00
|
|
|
|
2016-10-13 04:08:39 +02:00
|
|
|
gpg --default-key $gpgkey --clearsign --digest-algo SHA256 ${tmpdir}/${shafile}
|
2016-10-13 04:09:39 +02:00
|
|
|
gpg --default-key $gpgkey --detach-sign --digest-algo SHA256 ${tmpdir}/${shafile}
|
2015-01-31 11:55:37 +01:00
|
|
|
|
|
|
|
echo "Wrote to ${tmpdir}/"
|
|
|
|
|
|
|
|
echo -e "Your signed ${shafile}.asc:\n"
|
|
|
|
|
|
|
|
cat ${tmpdir}/${shafile}.asc
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
while true; do
|
|
|
|
echo -n "Upload files? [y/n] "
|
|
|
|
yorn=""
|
|
|
|
read yorn
|
|
|
|
|
|
|
|
if [ "X${yorn}" == "Xn" ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "X${yorn}" == "Xy" ]; then
|
2017-07-20 20:16:43 +02:00
|
|
|
scp ${customsshkey} ${tmpdir}/${shafile} ${tmpdir}/${shafile}.asc ${tmpdir}/${shafile}.sig ${webuser}@${webhost}:${shadir}/
|
2015-01-31 11:55:37 +01:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
rm -rf $tmpdir
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-07-20 20:16:43 +02:00
|
|
|
if [ -n "${signversion}" ]; then
|
|
|
|
sign ${signversion}
|
|
|
|
exit 0
|
2015-01-31 11:55:37 +01:00
|
|
|
fi
|
|
|
|
|
|
|
|
# else: do a normal release & promote
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
## Look for releases to promote
|
|
|
|
|
|
|
|
echo -e "\n# Checking for releases ..."
|
|
|
|
|
2017-07-20 20:16:43 +02:00
|
|
|
promotable=$(ssh ${customsshkey} ${webuser}@${webhost} $promotablecmd nodejs)
|
2015-01-31 11:55:37 +01:00
|
|
|
|
|
|
|
if [ "X${promotable}" == "X" ]; then
|
|
|
|
echo "No releases to promote!"
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -e "Found the following releases / builds ready to promote:\n"
|
|
|
|
echo "$promotable" | sed 's/^/ * /'
|
|
|
|
echo ""
|
|
|
|
|
|
|
|
versions=$(echo "$promotable" | cut -d: -f1)
|
|
|
|
|
|
|
|
################################################################################
|
|
|
|
## Promote releases
|
|
|
|
|
|
|
|
for version in $versions; do
|
|
|
|
while true; do
|
|
|
|
files=$(echo "$promotable" | grep "^${version}" | sed 's/^'${version}': //')
|
|
|
|
echo -n "Promote ${version} files (${files})? [y/n] "
|
|
|
|
yorn=""
|
|
|
|
read yorn
|
|
|
|
|
|
|
|
if [ "X${yorn}" == "Xn" ]; then
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "X${yorn}" != "Xy" ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo -e "\n# Promoting ${version}..."
|
|
|
|
|
2017-07-20 20:16:43 +02:00
|
|
|
ssh ${customsshkey} ${webuser}@${webhost} $promotecmd nodejs $version
|
2015-01-31 11:55:37 +01:00
|
|
|
|
|
|
|
sign $version
|
|
|
|
|
|
|
|
break
|
|
|
|
done
|
|
|
|
done
|