Skip to content

Commit

Permalink
fix module
Browse files Browse the repository at this point in the history
  • Loading branch information
Aurélien Richez committed Jul 21, 2023
1 parent 4410f36 commit b5d3228
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 34 deletions.
40 changes: 39 additions & 1 deletion build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import mill.scalalib._
import mill.scalalib.bsp.ScalaMetalsSupport
import mill.scalalib.publish.{Developer, License, PomSettings, VersionControl}
import mill.scalalib.scalafmt.ScalafmtModule
import $file.plugins.githubPackages
import githubPackages.{GithubPackagesPublishModule, GithubPackagesPublisher}

object core extends CommonModule with ArmadilloPublishModule {
override def ivyDeps = Agg(
Expand Down Expand Up @@ -293,7 +295,10 @@ trait CommonModule extends BaseModule {
)
}

trait ArmadilloPublishModule extends PublishModule {
trait ArmadilloPublishModule extends GithubPackagesPublishModule {

def githubOwner: String = "input-output-hk"
def githubRepository: String = "armadillo"

def publishVersion = VcsVersion.vcsState().format()

Expand Down Expand Up @@ -328,3 +333,36 @@ object Version {
val Fs2 = "3.4.0"
val Logback = "1.4.5"
}

object GithubPackagesPublishModule extends mill.Module {
import mill.scalalib.publish.Artifact

def publishAll(
publishArtifacts: mill.main.Tasks[PublishModule.PublishData],
token: String,
githubOwner: String,
githubRepository: String,
readTimeout: Int = 60000,
connectTimeout: Int = 5000
) =
T.command {

val x: Seq[(Seq[(os.Path, String)], Artifact)] =
T.sequence(publishArtifacts.value)().map { case PublishModule.PublishData(a, s) =>
(s.map { case (p, f) => (p.path, f) }, a)
}
new GithubPackagesPublisher(
githubOwner,
githubRepository,
token,
readTimeout,
connectTimeout,
T.log
).publishAll(
x: _*
)
}

lazy val millDiscover: mill.define.Discover[this.type] =
mill.define.Discover[this.type]
}
34 changes: 1 addition & 33 deletions plugins/githubPackages.sc
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,9 @@ trait GithubPackagesPublishModule extends PublishModule {

def publishGithubPackages(
token: String,
// publish: Boolean = true,
readTimeout: Int = 60000,
connectTimeout: Int = 5000
): define.Command[Unit] =
) =
T.command {
val PublishModule.PublishData(artifactInfo, artifacts) =
publishArtifacts()
Expand All @@ -174,34 +173,3 @@ trait GithubPackagesPublishModule extends PublishModule {
).publish(artifacts.map { case (a, b) => (a.path, b) }, artifactInfo)
}
}

object GithubPackagesPublishModule extends ExternalModule {
def publishAll(
token: String,
githubOwner: String,
githubRepository: String,
publishArtifacts: mill.main.Tasks[PublishModule.PublishData],
readTimeout: Int = 60000,
connectTimeout: Int = 5000
) =
T.command {

val x: Seq[(Seq[(os.Path, String)], Artifact)] =
T.sequence(publishArtifacts.value)().map { case PublishModule.PublishData(a, s) =>
(s.map { case (p, f) => (p.path, f) }, a)
}
new GithubPackagesPublisher(
githubOwner,
githubRepository,
token,
readTimeout,
connectTimeout,
T.log
).publishAll(
x: _*
)
}

lazy val millDiscover: mill.define.Discover[this.type] =
mill.define.Discover[this.type]
}

0 comments on commit b5d3228

Please sign in to comment.