Skip to content

Commit

Permalink
Merge pull request #8 from canterberry/cli-add
Browse files Browse the repository at this point in the history
✨ Add command for release signers to easily import keys
  • Loading branch information
canterberry authored Jul 1, 2021
2 parents c980295 + 62049ac commit 085a84e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Backup files, redundant with git history
/gpg/*~
26 changes: 25 additions & 1 deletion cli.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,28 @@ nodejs_keys_import() {
done
}

nodejs_keys_add() {
if [ $# -lt 1 ]; then
nodejs_keys_usage
fi

KEY_ID="$1"

gpg --export --armor "${KEY_ID}" > "${CLI_DIR}/keys/${KEY_ID}.asc"

GNUPGHOME="${CLI_DIR}/gpg" gpg --import "${CLI_DIR}/keys/${KEY_ID}.asc"

printf "keys.list <- "
if grep --quiet "${KEY_ID}" "${CLI_DIR}/keys.list"; then
echo "${KEY_ID}"
else
echo "${KEY_ID}" | tee -a "${CLI_DIR}/keys.list"
fi
}

nodejs_keys_usage() {
>&2 cat <<EOF
USAGE: $0 clear|help|import
USAGE: $0 clear|help|import|add
Manages Node.js release signing keys.
Expand All @@ -56,6 +75,7 @@ COMMANDS:
clear Clears all Node.js release signing keys from the GPG keyring.
help Displays this help message.
import Imports all Node.js release signing keys to the GPG keyring. (default)
add Adds a release signing key to this repo.
EOF
exit 1
Expand Down Expand Up @@ -83,6 +103,7 @@ COMMAND_NAME="help"

if [ "$#" -gt 0 ]; then
COMMAND_NAME="$1"
shift
fi

case "${COMMAND_NAME}" in
Expand All @@ -92,6 +113,9 @@ case "${COMMAND_NAME}" in
import)
nodejs_keys_import
;;
add)
nodejs_keys_add "$@"
;;
*)
nodejs_keys_usage
;;
Expand Down

0 comments on commit 085a84e

Please sign in to comment.