Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sonatype-staging is a not an existing directory #227

Closed
ghostbuster91 opened this issue Feb 6, 2022 · 2 comments · Fixed by #238
Closed

sonatype-staging is a not an existing directory #227

ghostbuster91 opened this issue Feb 6, 2022 · 2 comments · Fixed by #238

Comments

@ghostbuster91
Copy link
Contributor

This happens when the key or the key passphrase was incorrect.

2022-02-05 19:12:06.[162](https://github.com/ghostbuster91/scalafix-unified/runs/5079515519?check_suite_focus=true#step:4:162)Z  info [SonatypeClient] Creating a staging repository in profile io.github.*** with a description key: [sbt-sonatype] root 0.0.1  - (SonatypeClient.scala:126)
2022-02-05 19:12:06.246Z  info [SonatypeService] No previous staging repository for [sbt-sonatype] root 0.0.1 was found  - (SonatypeService.scala:99)
2022-02-05 19:12:10.034Z  info [SonatypeClient] Created successfully: iogithub***-1011  - (SonatypeClient.scala:139)
2022-02-05 19:12:10.052Z error [Sonatype] 
java.io.IOException: Supplied file /home/runner/work/scalafix-unified/scalafix-unified/target/sonatype-staging/0.0.1 is a not an existing directory!
	at org.sonatype.spice.zapper.fs.AbstractDirectory.<init>(AbstractDirectory.java:32)
	at org.sonatype.spice.zapper.fs.DirectoryIOSource.<init>(DirectoryIOSource.java:68)
	at org.sonatype.spice.zapper.fs.DirectoryIOSource.<init>(DirectoryIOSource.java:59)
	at org.sonatype.spice.zapper.fs.DirectoryIOSource.<init>(DirectoryIOSource.java:50)
	at xerial.sbt.sonatype.SonatypeClient.$anonfun$uploadBundle$2(SonatypeClient.scala:284)
	at scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.java:23)
	at scala.util.Try$.apply(Try.scala:213)

If we scroll up the logs we can notice that the key was imported but the provided base64 input was invalid due to (#226)

Running ci-release.
  branch=refs/tags/v0.0.1
gpg (GnuPG) 2.2.19
gpg: directory '/home/runner/.gnupg' created
gpg: keybox '/home/runner/.gnupg/pubring.kbx' created
base64: invalid input
gpg: /home/runner/.gnupg/trustdb.gpg: trustdb created
gpg: key A6[33](https://github.com/ghostbuster91/scalafix-unified/runs/5079515519?check_suite_focus=true#step:4:33)84B42C7889C0: public key "scalafix-unified ci bot <kghost0@gmail.com>" imported
gpg: key A63384B42C7889C0: secret key imported
gpg: Total number processed: 1
gpg:               imported: 1
gpg:       secret keys read: 1
gpg:   secret keys imported: 1
Tag push detected, publishing a stable release

I think that the script should fail if the base64 -d returns non-zero exit code.

https://github.com/sbt/sbt-ci-release/blob/main/plugin/src/main/scala/com/geirsson/CiReleasePlugin.scala#L93

Currently, the exit code of the importing command is ignored.
Notice, that piping multiple commands using #| operator will return only last command exit code which in our case is gpg --import.

I would be happy to submit a PR as soon as we agree upon the approach.

Link to a github action build: https://github.com/ghostbuster91/scalafix-unified/runs/5079515519?check_suite_focus=true

@eed3si9n
Copy link
Member

eed3si9n commented Feb 7, 2022

Notice, that piping multiple commands using #| operator will return only last command exit code which in our case is gpg --import.

It is unfortunate that #| doesn't act in a -o pipefail way.

Maybe it could run

// running base64 alone to emulate pipefail
(s"echo $secret" #| "base64 --decode").!(...)

with a null ProcessLogger, which is something like ProcessLogger(_ => ())?
That way if base64 fails, it would be caught there.

@ghostbuster91
Copy link
Contributor Author

It is unfortunate that #| doesn't act in a -o pipefail way.

💯

with a null ProcessLogger, which is something like ProcessLogger(_ => ())?
That way if base64 fails, it would be caught there.

I am not sure if I follow. Such null process logger would simply ignore all the errors, wouldn't it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants