@@ -17,6 +17,7 @@ import scala.annotation.unused
17
17
import scala .concurrent .duration ._
18
18
import scala .util .Properties .isWin
19
19
import com .goyeau .mill .scalafix .ScalafixModule
20
+ import com .lumidion .sonatype .central .client .core .{PublishingType , SonatypeCredentials }
20
21
21
22
object Versions {
22
23
def scala213 = " 2.13.16"
@@ -229,13 +230,14 @@ object tests extends ScalaJsCliModule {
229
230
}
230
231
}
231
232
232
- def ghOrg = " virtuslab"
233
- def ghName = " scala-js-cli"
234
- trait ScalaJsCliPublishModule extends PublishModule {
233
+ def ghOrg = " virtuslab"
234
+ def ghName = " scala-js-cli"
235
+ def publishOrg = " org.virtuslab.scala-cli"
236
+ trait ScalaJsCliPublishModule extends SonatypeCentralPublishModule {
235
237
import mill .scalalib .publish ._
236
238
def pomSettings : Target [PomSettings ] = PomSettings (
237
239
description = artifactName(),
238
- organization = " org.virtuslab.scala-cli " ,
240
+ organization = publishOrg ,
239
241
url = s " https://github.com/ $ghOrg/ $ghName" ,
240
242
licenses = Seq (License .`BSD-3-Clause`),
241
243
versionControl = VersionControl .github(ghOrg, ghName),
@@ -313,18 +315,30 @@ object ci extends Module {
313
315
@ unused
314
316
def publishSonatype (tasks : mill.main.Tasks [PublishModule .PublishData ]): Command [Unit ] =
315
317
Task .Command {
318
+ val publishVersion = finalPublishVersion
319
+ System .err.println(s " Publish version: $publishVersion" )
320
+ val bundleName = s " $publishOrg- $ghName- $publishVersion"
321
+ System .err.println(s " Publishing bundle: $bundleName" )
316
322
publishSonatype0(
317
323
data = define.Target .sequence(tasks.value)(),
318
- log = Task .ctx().log
324
+ log = Task .ctx().log,
325
+ workspace = Task .workspace,
326
+ env = Task .env,
327
+ bundleName = bundleName
319
328
)
320
329
}
321
330
322
331
private def publishSonatype0 (
323
332
data : Seq [PublishModule .PublishData ],
324
- log : mill.api.Logger
333
+ log : mill.api.Logger ,
334
+ workspace : os.Path ,
335
+ env : Map [String , String ],
336
+ bundleName : String
325
337
): Unit = {
326
-
327
- val credentials = sys.env(" SONATYPE_USERNAME" ) + " :" + sys.env(" SONATYPE_PASSWORD" )
338
+ val credentials = SonatypeCredentials (
339
+ username = sys.env(" SONATYPE_USERNAME" ),
340
+ password = sys.env(" SONATYPE_PASSWORD" )
341
+ )
328
342
val pgpPassword = sys.env(" PGP_PASSPHRASE" )
329
343
val timeout = 10 .minutes
330
344
@@ -341,11 +355,8 @@ object ci extends Module {
341
355
)
342
356
set.head
343
357
}
344
- val publisher = new scalalib.publish.SonatypePublisher (
345
- uri = " https://oss.sonatype.org/service/local" ,
346
- snapshotUri = " https://oss.sonatype.org/content/repositories/snapshots" ,
358
+ val publisher = new SonatypeCentralPublisher (
347
359
credentials = credentials,
348
- signed = true ,
349
360
gpgArgs = Seq (
350
361
" --detach-sign" ,
351
362
" --batch=true" ,
@@ -360,11 +371,17 @@ object ci extends Module {
360
371
readTimeout = timeout.toMillis.toInt,
361
372
connectTimeout = timeout.toMillis.toInt,
362
373
log = log,
363
- awaitTimeout = timeout.toMillis.toInt,
364
- stagingRelease = isRelease
374
+ workspace = workspace,
375
+ env = env,
376
+ awaitTimeout = timeout.toMillis.toInt
377
+ )
378
+ val publishingType = if (isRelease) PublishingType .AUTOMATIC else PublishingType .USER_MANAGED
379
+ val finalBundleName = if (bundleName.nonEmpty) Some (bundleName) else None
380
+ publisher.publishAll(
381
+ publishingType = publishingType,
382
+ singleBundleName = finalBundleName,
383
+ artifacts = artifacts : _*
365
384
)
366
-
367
- publisher.publishAll(isRelease, artifacts : _* )
368
385
}
369
386
@ unused
370
387
def upload (directory : String = " artifacts/" ): Command [Unit ] = Task .Command {
0 commit comments