sbt / sbt-pgp

PGP plugin for sbt
Other
144 stars 56 forks source link

Not support a GPG key without passphrase? #175

Open y-yu opened 4 years ago

y-yu commented 4 years ago

steps

  1. Create a GPG key without passphrase

    $ echo -n "" | gpg --batch --yes --pinentry-mode loopback --generate-key --passphrase-fd 0
    • We can show the key which was created by the above 👆 command:

      $ gpg --list-key
      gpg: checking the trustdb
      gpg: marginals needed: 3  completes needed: 1  trust model: pgp
      gpg: depth: 0  valid:   2  signed:   0  trust: 0-, 0q, 0n, 0m, 0f, 2u
      gpg: next trustdb check due at 2022-06-06
      /Users/yyu/.gnupg/pubring.kbx
      -----------------------------
      pub   rsa2048 2020-06-06 [SC]
            79A59AA4B803AC2E84AD07CB94EAC92505728B03
      uid           [ultimate] Yoshimura Hikaru <yyu@mental.poker>
      sub   rsa2048 2020-06-06 [E]
      
      pub   rsa2048 2020-06-06 [SC] [expires: 2022-06-06]
            847ED2CFC1CA4A87C8940A267EB6F97B499527B3
      uid           [ultimate] Password Less <passwordless@exapmle.com>
      sub   rsa2048 2020-06-06 [E] [expires: 2022-06-06]
    • Or if you have already had a PGP key without passphrase then run this command to import it
      $ gpg --batch --import $HOME/.sbt/gpg/secring.asc
  2. Write build.sbt:

    Global / pgpPassphrase := Some(Array())

    or

    Global / pgpPassphrase := None
  3. Run sbt release

  4. Fail to sign

Information

sbt-pgp version: 2.0.1 sbt version: 1.3.12 gnupg version: 2.2.20

Initial gpg keys state:

$ gpg --list-key
/Users/yyu/.gnupg/pubring.kbx
-----------------------------
pub   rsa2048 2020-06-06 [SC]
      79A59AA4B803AC2E84AD07CB94EAC92505728B03
uid           [ultimate] Yoshimura Hikaru <yyu@mental.poker>
sub   rsa2048 2020-06-06 [E]

And run those command for gpg output

export GPG_TTY=$(tty)
export LANG=C

problem

sbt-pgp will not sign by the key and fail due to GPG error.

When Global / pgpPassphrase := None ```scala [error] gpg: using "89E12D0E3E013585D82565D91EE07D3261CE4CA6" as default secret key for signing [error] gpg: signing failed: No passphrase given [error] gpg: signing failed: No passphrase given [error] java.lang.RuntimeException: Failure running 'gpg --detach-sign --armor --use-agent --output /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom.asc /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom'. Exit code: 2 [error] at scala.sys.package$.error(package.scala:30) [error] at com.jsuereth.sbtpgp.CommandLineGpgSigner.sign(PgpSigner.scala:48) [error] at com.jsuereth.sbtpgp.PgpSettings$.$anonfun$signingSettings$2(PgpSettings.scala:151) [error] at scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:245) [error] at scala.collection.immutable.Map$Map4.foreach(Map.scala:236) [error] at scala.collection.TraversableLike.flatMap(TraversableLike.scala:245) [error] at scala.collection.TraversableLike.flatMap$(TraversableLike.scala:242) [error] at scala.collection.AbstractTraversable.flatMap(Traversable.scala:108) [error] at com.jsuereth.sbtpgp.PgpSettings$.$anonfun$signingSettings$1(PgpSettings.scala:146) [error] at scala.Function1.$anonfun$compose$1(Function1.scala:49) [error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62) [error] at sbt.std.Transform$$anon$4.work(Transform.scala:67) [error] at sbt.Execute.$anonfun$submit$2(Execute.scala:281) [error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19) [error] at sbt.Execute.work(Execute.scala:290) [error] at sbt.Execute.$anonfun$submit$1(Execute.scala:281) [error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178) [error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:37) [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [error] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [error] at java.lang.Thread.run(Thread.java:748) [error] (signedArtifacts) Failure running 'gpg --detach-sign --armor --use-agent --output /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom.asc /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom'. Exit code: 2 ```
When Global / pgpPassphrase := Some(Array()) ```scala [error] gpg: using "89E12D0E3E013585D82565D91EE07D3261CE4CA6" as default secret key for signing [error] gpg: signing failed: No passphrase given [error] gpg: signing failed: No passphrase given [error] java.lang.RuntimeException: Failure running 'gpg --batch --passphrase --detach-sign --armor --use-agent --output /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom.asc /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom'. Exit code: 2 [error] at scala.sys.package$.error(package.scala:30) [error] at com.jsuereth.sbtpgp.CommandLineGpgSigner.sign(PgpSigner.scala:48) [error] at com.jsuereth.sbtpgp.PgpSettings$.$anonfun$signingSettings$2(PgpSettings.scala:151) [error] at scala.collection.TraversableLike.$anonfun$flatMap$1(TraversableLike.scala:245) [error] at scala.collection.immutable.Map$Map4.foreach(Map.scala:236) [error] at scala.collection.TraversableLike.flatMap(TraversableLike.scala:245) [error] at scala.collection.TraversableLike.flatMap$(TraversableLike.scala:242) [error] at scala.collection.AbstractTraversable.flatMap(Traversable.scala:108) [error] at com.jsuereth.sbtpgp.PgpSettings$.$anonfun$signingSettings$1(PgpSettings.scala:146) [error] at scala.Function1.$anonfun$compose$1(Function1.scala:49) [error] at sbt.internal.util.$tilde$greater.$anonfun$$u2219$1(TypeFunctions.scala:62) [error] at sbt.std.Transform$$anon$4.work(Transform.scala:67) [error] at sbt.Execute.$anonfun$submit$2(Execute.scala:281) [error] at sbt.internal.util.ErrorHandling$.wideConvert(ErrorHandling.scala:19) [error] at sbt.Execute.work(Execute.scala:290) [error] at sbt.Execute.$anonfun$submit$1(Execute.scala:281) [error] at sbt.ConcurrentRestrictions$$anon$4.$anonfun$submitValid$1(ConcurrentRestrictions.scala:178) [error] at sbt.CompletionService$$anon$2.call(CompletionService.scala:37) [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [error] at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [error] at java.util.concurrent.FutureTask.run(FutureTask.java:266) [error] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [error] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [error] at java.lang.Thread.run(Thread.java:748) [error] (signedArtifacts) Failure running 'gpg --batch --passphrase --detach-sign --armor --use-agent --output /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom.asc /Users/yyu/Desktop/excel-reads/target/scala-2.13/excel-reads_2.13-0.2.1.pom'. Exit code: 2 ```

expectation

notes