3 # To promote and sign a release that has been prepared by the build slaves, use:
6 # To _only_ sign an existing release, use:
11 webhost=direct.nodejs.org
13 promotablecmd=dist-promotable
14 promotecmd=dist-promote
18 ################################################################################
19 ## Select a GPG key to use
21 echo "# Selecting GPG key ..."
23 gpgkey=$(gpg --list-secret-keys | grep '^sec' | awk -F'( +|/)' '{print $3}')
24 keycount=$(echo $gpgkey | wc -w)
26 if [ $keycount -eq 0 ]; then
27 echo 'Need at least one GPG key, please make one with `gpg --gen-key`'
28 echo 'You will also need to submit your key to a public keyserver, e.g.'
29 echo ' https://sks-keyservers.net/i/#submit'
31 elif [ $keycount -ne 1 ]; then
32 echo -e 'You have multiple GPG keys:\n'
34 gpg --list-secret-keys
37 echo $gpgkey | awk '{ for(i = 1; i <= NF; i++) { print i ") " $i; } }'
38 echo -n 'Select a key: '
41 if $(test "$keynum" -eq "$keynum" > /dev/null 2>&1); then
42 _gpgkey=$(echo $gpgkey | awk '{ print $'${keynum}'}')
43 keycount=$(echo $_gpgkey | wc -w)
44 if [ $keycount -eq 1 ]; then
53 gpgfing=$(gpg --fingerprint $gpgkey | grep 'Key fingerprint =' | awk -F' = ' '{print $2}' | tr -d ' ')
55 if ! test "$(grep $gpgfing README.md)"; then
56 echo 'Error: this GPG key fingerprint is not listed in ./README.md'
60 echo "Using GPG key: $gpgkey"
61 echo " Fingerprint: $gpgfing"
64 ################################################################################
65 ## Create and sign checksums file for a given version
68 echo -e "\n# Creating SHASUMS256.txt ..."
72 gpgtagkey=$(git tag -v $version 2>&1 | grep 'key ID' | awk '{print $NF}')
74 if [ "X${gpgtagkey}" == "X" ]; then
75 echo "Could not find signed tag for \"${version}\""
79 if [ "${gpgtagkey}" != "${gpgkey}" ]; then
80 echo "GPG key for \"${version}\" tag is not yours, cannot sign"
83 shapath=$(ssh ${webuser}@${webhost} $signcmd nodejs $version)
85 if ! [[ ${shapath} =~ ^/.+/SHASUMS256.txt$ ]]; then
86 echo 'Error: No SHASUMS file returned by sign!'
90 echo -e "\n# Signing SHASUMS for ${version}..."
92 shafile=$(basename $shapath)
93 shadir=$(dirname $shapath)
94 tmpdir="/tmp/_node_release.$$"
98 scp ${webuser}@${webhost}:${shapath} ${tmpdir}/${shafile}
100 gpg --default-key $gpgkey --clearsign ${tmpdir}/${shafile}
102 echo "Wrote to ${tmpdir}/"
104 echo -e "Your signed ${shafile}.asc:\n"
106 cat ${tmpdir}/${shafile}.asc
111 echo -n "Upload files? [y/n] "
115 if [ "X${yorn}" == "Xn" ]; then
119 if [ "X${yorn}" == "Xy" ]; then
120 scp ${tmpdir}/${shafile} ${tmpdir}/${shafile}.asc ${webuser}@${webhost}:${shadir}/
129 if [ "X${1}" == "X-s" ]; then
130 if [ "X${2}" == "X" ]; then
131 echo "Please supply a version string to sign"
140 # else: do a normal release & promote
142 ################################################################################
143 ## Look for releases to promote
145 echo -e "\n# Checking for releases ..."
147 promotable=$(ssh ${webuser}@${webhost} $promotablecmd nodejs)
149 if [ "X${promotable}" == "X" ]; then
150 echo "No releases to promote!"
154 echo -e "Found the following releases / builds ready to promote:\n"
155 echo "$promotable" | sed 's/^/ * /'
158 versions=$(echo "$promotable" | cut -d: -f1)
160 ################################################################################
163 for version in $versions; do
165 files=$(echo "$promotable" | grep "^${version}" | sed 's/^'${version}': //')
166 echo -n "Promote ${version} files (${files})? [y/n] "
170 if [ "X${yorn}" == "Xn" ]; then
174 if [ "X${yorn}" != "Xy" ]; then
178 echo -e "\n# Promoting ${version}..."
180 ssh ${webuser}@${webhost} $promotecmd nodejs $version