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

✨ Add command for release signers to easily import keys #8

Merged
merged 3 commits into from
Jul 1, 2021
Merged
Show file tree
Hide file tree
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
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