Created
June 7, 2018 07:47
-
-
Save DragonBe/d2851e4b93ccff3e420129f843574dd7 to your computer and use it in GitHub Desktop.
Creating a GPG signed archive of your GIT source code with SHA 256 checksums in bash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Getting the current project's directory | |
pf=$(printf '%q\n' "${PWD##*/}") | |
# Getting the current configured user's email | |
gpguser=$(git config user.email) | |
if [ -z $gpguser ] | |
then | |
echo "!!! ERROR: No user for GIT configured !!!" | |
echo " You might want to set 'git config user.email <[email protected]>'" | |
exit 1 | |
fi | |
# Looking up their GPG key ID | |
gpgid=$(gpg --list-keys --keyid-format LONG $gpguser | grep "^ " | sed 's/\ //g') | |
if [ -z $gpgid ] | |
then | |
echo "!!! ERROR: Couldn't find matching GPG ID for user $gpguser !!!" | |
exit 1 | |
fi | |
# Clean up | |
rm -f $pf.zip | |
rm -f $pf.zip.asc | |
rm -f $pf.tar.gz | |
rm -f $pf.tar.gz.asc | |
rm -f $pf.sum | |
# Running archive | |
for format in zip tar.gz | |
do | |
git archive --format=$format --prefix=$pf/ --output=$pf.$format HEAD | |
shasum -a 256 $pf.$format >> $pf.sum | |
gpg --detach-sign -a -u $gpgid $pf.$format | |
done | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment