refactor: finish moving ssh-* scripts to own installers
[webi-installers/.git] / git-config-gpg / git-config-gpg.sh
1 #!/bin/bash
2 set -e
3 set -u
4
5 function __git_gpg_init() {
6     export PATH="$HOME/.local/opt/gnupg/bin:$PATH"
7     export PATH="$HOME/.local/opt/gnupg/bin/pinentry-mac.app/Contents/MacOS:$PATH"
8
9     # TODO check for public key without gpg-pubkey?
10     if ! command -v gpg-pubkey; then
11         webi gpg-pubkey
12     else
13         gpg-pubkey
14     fi
15
16     MY_KEY_ID="$(
17         gpg-pubkey-id
18     )"
19
20     echo -n "Enabling automatic git commit signing...
21             git config --global user.signingkey ${MY_KEY_ID}
22             git config --global commit.gpgsign true
23             git config --global log.showSignature true
24         "
25
26     git config --global user.signingkey "${MY_KEY_ID}"
27     git config --global commit.gpgsign true
28     git config --global log.showSignature true
29
30     echo ""
31     echo "Successfully updated ~/.gitconfig"
32     echo ""
33     echo "How to verify signed commits on GitHub:"
34     echo ""
35     echo "    1. Go to 'Add GPG Key': https://github.com/settings/gpg/new"
36     echo "    2. Copy and paste the key above from the first ---- to the last ----"
37     echo ""
38 }
39
40 __git_gpg_init