typelevel / sbt-typelevel

Let sbt work for you.
https://typelevel.org/sbt-typelevel/
Apache License 2.0
168 stars 47 forks source link

Publishing via the Central Portal #721

Closed m3is0 closed 1 month ago

m3is0 commented 1 month ago

Since recently, all new Sonatype accounts must publish via the Central Portal: https://central.sonatype.org/register/central-portal/

I've successfully published my project with sbt-ci-release and sbt-sonatype v3.11.0 (which supports the new API), but with sbt-typelevel-ci-release v0.7.2 (which includes the same sbt-sonatype) it doesn't work.

I tried to set SONATYPE_CREDENTIAL_HOST, but with no success.

armanbilge commented 1 month ago

Thanks for trying this!

it doesn't work.

How do you know that it didn't work? Are there logs or some kind of error message?

I tried to set SONATYPE_CREDENTIAL_HOST, but with no success.

How did you try to set it? can you share your build.sbt?

kubukoz commented 1 month ago

For the record, sbt-sonatype 3.11.0 should support the new API: https://github.com/xerial/sbt-sonatype/pull/474 (issue: https://github.com/xerial/sbt-sonatype/issues/465)

and sbt-typelevel uses that in 0.7.2.

m3is0 commented 1 month ago

As @kubukoz mentioned, I get the following error:

scala.MatchError: URLRepository(https://SettingKey(This / This / This / sonatypeCredentialHost), Patterns(ivyPatterns=Vector(), artifactPatterns=Vector(), isMavenCompatible=false, descriptorOptional=false, skipConsistencyCheck=false), false) (of class sbt.librarymanagement.URLRepository)
    at org.typelevel.sbt.TypelevelSonatypeCiReleasePlugin$.$anonfun$tlCiReleaseCommand$4(TypelevelSonatypeCiReleasePlugin.scala:75)
...
aartigao commented 1 month ago

FYI, I've tried 👇🏽

addSbtPlugin("org.typelevel" % "sbt-typelevel" % "0.7.2-8-ce3d86e-SNAPSHOT")

and works! 🎉 Thanks @kubukoz!

(beware that, for the moment, publishing snapshots is not supported and your CI will fail).

kubukoz commented 1 month ago

@aartigao did you identify where the problem with snapshots comes from?

aartigao commented 1 month ago

If I read correctly it's just that it is not supported yet by SBT Sonatype.

m3is0 commented 1 month ago

It works well with SONATYPE_CREDENTIAL_HOST = "central.sonatype.com" as an actions secret!

Thanks to you guys, and thanks to @kubukoz for fixing this so quickly!

With ThisBuild / sonatypeCredentialHost := xerial.sbt.Sonatype.sonatypeCentralHost it doesn't work.

It still uses the default host:

2024-07-27 20:14:52.597Z  info [SonatypeService] sonatypeRepository  : https://s01.oss.sonatype.org/service/local  - (SonatypeService.scala:26)
...
2024-07-27 20:14:54.120Z error [Sonatype] 
wvlet.airframe.http.HttpClientException: [401: Unauthorized]

Is this expected?

m3is0 commented 1 month ago

I think the above problem is related to the following code: https://github.com/typelevel/sbt-typelevel/blob/626ef87136e03ef04b0172ca01d64b4ece698a7d/sonatype/src/main/scala/org/typelevel/sbt/TypelevelSonatypePlugin.scala#L62-L69

armanbilge commented 1 month ago

@m3is0 Yes, it's a scoping problem. Originally, sbt-sonatype required that sonatypeCredentialHost be scoped at the project-level instead of the ThisBuild-level. However, it looks like that was changed in https://github.com/xerial/sbt-sonatype/commit/70740908a72b9bbafb9cca82ec77f8db215be7f4, so now our code is broken.

m3is0 commented 1 month ago

Thanks @armanbilge !

kubukoz commented 2 weeks ago

The 0.7.2-12-17ac909-SNAPSHOT version has worked for us, any chance we can get a patch soon?

armanbilge commented 2 weeks ago

@kubukoz we need to fix one more thing before we can release: