sbt / sbt-pgp

PGP plugin for sbt
Other
144 stars 56 forks source link

Implement gpg 2 support #184

Closed eed3si9n closed 3 years ago

eed3si9n commented 3 years ago

Fixes https://github.com/sbt/sbt-pgp/issues/173 / https://github.com/sbt/sbt-pgp/issues/178 https://www.gnupg.org/documentation/manuals/gnupg/GPG-Esoteric-Options.html#GPG-Esoteric-Options

--passphrase string Since Version 2.1 the --pinentry-mode also needs to be set to loopback.

This attemps to detect the version number from the --version output, and adds --pinentry-mode loopback to the argument.

eed3si9n commented 3 years ago

Note that this fix alone does not fix GitHub Actions situation:

gpg: key 24A4616356F15CE1: public key "sbt-projectmatrix bot <eed3si9n@gmail.com>" imported
gpg: key 24A4616356F15CE1/24A4616356F15CE1: error sending to agent: Inappropriate ioctl for device
gpg: error building skey array: Inappropriate ioctl for device
gpg: Total number processed: 1
gpg:               imported: 1
gpg:       secret keys read: 1
....
[info] gpg: no default secret key: No secret key
[info] gpg: signing failed: No secret key
[error] java.lang.RuntimeException: Failure running 'gpg --batch --pinentry-mode loopback --passphrase *** --detach-sign --armor --use-agent --output /home/runner/work/sbt-projectmatrix/sbt-projectmatrix/target/scala-2.12/sbt-1.0/sbt-projectmatrix-0.7.1-M1.jar.asc /home/runner/work/sbt-projectmatrix/sbt-projectmatrix/target/scala-2.12/sbt-1.0/sbt-projectmatrix-0.7.1-M1.jar'.  Exit code: 2
aakoshh commented 3 years ago

Unfortunately the --pinentry-mode option is only available from GPG version 2.1, but isLegacyGpg just checks the major version. When the plugin is used with 2.0.x we get an invalid option error.

gpg --version
gpg (GnuPG) 2.0.22
[info] gpg: invalid option "--pinentry-mode"
--
  | [error] java.lang.RuntimeException: Failure running 'gpg --batch --pinentry-mode loopback --passphrase *** --detach-sign --armor --use-agent --output /var/lib/buildkite-agent/builds/...'.  Exit code: 2

See here for a similar issue.