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

align SonatypeCentralPublishModule with SonatypePublisher #3987

Merged
merged 1 commit into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions contrib/sonatypecentral/readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ $ mill -i \
mill.contrib.sonatypecentral.SonatypeCentralPublishModule/publishAll \
--username myusername \
--password mypassword \
--gpgArgs --passphrase=$GPG_PASSPHRASE,--no-tty,--pinentry-mode,loopback,--batch,--yes,-a,-b \
--gpgArgs --passphrase=$MILL_PGP_PASSPHRASE,--no-tty,--pinentry-mode,loopback,--batch,--yes,-a,-b \
--publishArtifacts __.publishArtifacts \
--readTimeout 36000 \
--awaitTimeout 36000 \
Expand Down Expand Up @@ -68,7 +68,7 @@ The `mill.contrib.sonatypecentral.SonatypeCentralPublishModule/publishAll` metho

`password`: The password for calling the Sonatype Central publishing api. Defaults to the `SONATYPE_PASSWORD` environment variable if unset. If neither the parameter nor the environment variable are set, an error will be thrown. +

`gpgArgs`: Arguments to pass to the gpg package for signing artifacts. _Default: `--batch, --yes, -a, -b`._ +
`gpgArgs`: Arguments to pass to the gpg package for signing artifacts. Uses the `MILL_PGP_PASSPHRASE` environment variable if set. _Default: `[--passphrase=$MILL_PGP_PASSPHRASE], --no-tty, --pinentry-mode, loopback, --batch, --yes, -a, -b`._ +

`publishArtifacts`: The command for generating all publishable artifacts (ex. `__.publishArtifacts`). Required. +

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,16 @@ import mill.contrib.sonatypecentral.SonatypeCentralPublishModule.{
getPublishingTypeFromReleaseFlag,
getSonatypeCredentials
}
import mill.scalalib.PublishModule.defaultGpgArgs
import mill.scalalib.publish.Artifact
import mill.scalalib.publish.SonatypeHelpers.{
PASSWORD_ENV_VARIABLE_NAME,
USERNAME_ENV_VARIABLE_NAME
}

trait SonatypeCentralPublishModule extends PublishModule {
def sonatypeCentralGpgArgs: T[String] = Task { defaultGpgArgs.mkString(",") }
def sonatypeCentralGpgArgs: T[String] = Task {
PublishModule.defaultGpgArgsForPassphrase(T.env.get("MILL_PGP_PASSPHRASE")).mkString(",")
}

def sonatypeCentralConnectTimeout: T[Int] = Task { defaultConnectTimeout }

Expand All @@ -43,10 +44,7 @@ trait SonatypeCentralPublishModule extends PublishModule {
PublishModule.pgpImportSecretIfProvided(T.env)
val publisher = new SonatypeCentralPublisher(
credentials = finalCredentials,
gpgArgs = sonatypeCentralGpgArgs() match {
case "" => PublishModule.defaultGpgArgsForPassphrase(T.env.get("PGP_PASSPHRASE"))
case gpgArgs => gpgArgs.split(",").toIndexedSeq
},
gpgArgs = sonatypeCentralGpgArgs().split(",").toIndexedSeq,
connectTimeout = sonatypeCentralConnectTimeout(),
readTimeout = sonatypeCentralReadTimeout(),
log = T.log,
Expand Down Expand Up @@ -75,7 +73,7 @@ object SonatypeCentralPublishModule extends ExternalModule {
username: String = defaultCredentials,
password: String = defaultCredentials,
shouldRelease: Boolean = defaultShouldRelease,
gpgArgs: String = defaultGpgArgs.mkString(","),
gpgArgs: String = "",
readTimeout: Int = defaultReadTimeout,
connectTimeout: Int = defaultConnectTimeout,
awaitTimeout: Int = defaultAwaitTimeout,
Expand All @@ -93,7 +91,7 @@ object SonatypeCentralPublishModule extends ExternalModule {
val publisher = new SonatypeCentralPublisher(
credentials = finalCredentials,
gpgArgs = gpgArgs match {
case "" => PublishModule.defaultGpgArgsForPassphrase(T.env.get("PGP_PASSPHRASE"))
case "" => PublishModule.defaultGpgArgsForPassphrase(T.env.get("MILL_PGP_PASSPHRASE"))
case gpgArgs => gpgArgs.split(",").toIndexedSeq
},
connectTimeout = connectTimeout,
Expand Down
Loading