Skip to content

Commit

Permalink
fix(plugins/git): add more optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
dalisoft committed Apr 26, 2024
1 parent 281de5f commit cc7085e
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions plugins/git.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ prepare() {
log_verbose "Git username [$GIT_USERNAME] and Git e-mail [$GIT_EMAIL] set"
fi

if [ -z "${GPG_NO_SIGN-}" ] && [ -n "${GPG_KEY_ID-}" ]; then
if [ -z "${GPG_NO_SIGN-}" ] && [ -n "${GPG_KEY-}" ] && [ -n "${GPG_KEY_ID-}" ]; then
git config --local commit.gpgsign true
git config --local user.signingkey "$GPG_KEY_ID"
git config --local tag.forceSignAnnotated true
Expand All @@ -24,7 +24,7 @@ prepare() {
log_verbose "Git GPG key import skipped"
fi

if [ -n "${GPG_PASSPHRASE}" ]; then
if [ -n "${GPG_PASSPHRASE-}" ]; then
echo "$GPG_PASSPHRASE" | gpg --quiet --batch --yes --pinentry-mode loopback --sign --local-user "${GPG_KEY_ID-}" --passphrase-fd 0 >/dev/null
log_verbose "Git GPG passphrase set"
fi
Expand All @@ -38,22 +38,20 @@ cleanup() {
log_verbose "Git username and Git e-mail unset"
fi

if [ -z "${GPG_NO_SIGN-}" ] && [ -n "${GPG_KEY_ID-}" ]; then
if [ -z "${GPG_NO_SIGN-}" ] && [ -n "${GPG_KEY-}" ] && [ -n "${GPG_KEY_ID-}" ]; then
git config --local --unset commit.gpgsign
git config --local --unset user.signingkey
git config --local --unset tag.forceSignAnnotated
git config --local --unset gpg.program
log_verbose "Git GPG sign and key ID [$GPG_KEY_ID] are unset"

if gpg --list-keys | grep -q "${GPG_KEY_ID-}"; then
if [ -n "${GPG_PASSPHRASE}" ]; then
if [ -n "${GPG_PASSPHRASE-}" ]; then
echo "$GPG_PASSPHRASE" | gpg --quiet --batch --yes --passphrase-fd 0 --delete-secret-and-public-key "$GPG_KEY_ID" >/dev/null
else
gpg --quiet --batch --yes --delete-secret-and-public-key "$GPG_KEY_ID"
fi
log_verbose "Git GPG key deleted"
else
log_verbose "Git GPG key delete skipped"
fi

log_verbose "Git GPG config cleanup"
Expand All @@ -70,7 +68,7 @@ release() {
if ! $IS_DRY_RUN; then
prepare

if [ -z "${GPG_NO_SIGN-}" ] && [ -n "${GPG_KEY_ID-}" ]; then
if [ -z "${GPG_NO_SIGN-}" ] && [ -n "${GPG_KEY-}" ] && [ -n "${GPG_KEY_ID-}" ]; then
git tag --sign "$NEXT_RELEASE_TAG" "$CHECKOUT_SHA" --message "Release, tag and sign $NEXT_RELEASE_TAG"
log "Created signed Git tag [$NEXT_RELEASE_TAG]!"
else
Expand Down

0 comments on commit cc7085e

Please sign in to comment.