Skip to content

Commit

Permalink
Added support to build against a development snapshot of Mill (#107)
Browse files Browse the repository at this point in the history
You can put the desired Mill version into a file `MILL_DEV_VERSION`.
The build will pick this version up and build and test an additional
artifact with the full version as mill platform.

The CI workflow can now publish a version for the latest Mill
development version,
when manually started (with 'workflow_dispatch').

Pull request: #107
  • Loading branch information
lefou authored May 5, 2023
1 parent a83275c commit 0763743
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 5 deletions.
29 changes: 27 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
tags:
- '**'
pull_request:
workflow_dispatch:

# cancel older runs of a pull request;
# this will not cancel anything for normal git pushes
Expand All @@ -25,13 +26,21 @@ jobs:

steps:
- uses: actions/checkout@v3
- run: git fetch --prune --tags --unshallow
with:
fetch-depth: 0

- uses: coursier/cache-action@v6

- uses: actions/setup-java@v3
with:
java-version: ${{ matrix.java-version }}
distribution: temurin

- run: ./millw -i findLatestMill --toFile MILL_DEV_VERSION
if: matrix.os != 'windows-latest' && github.event_name == 'workflow_dispatch'
- run: ./millw.bat -i findLatestMill --toFile MILL_DEV_VERSION
if: matrix.os == 'windows-latest' && github.event_name == 'workflow_dispatch'

- run: ./millw -i __.publishLocal testRepo
if: matrix.os != 'windows-latest'
- run: .\millw.bat -i __.publishLocal testRepo
Expand Down Expand Up @@ -62,6 +71,9 @@ jobs:
- uses: actions/checkout@v3
with:
fetch-depth: 0

- uses: coursier/cache-action@v6

- uses: actions/setup-java@v3
with:
java-version: 8
Expand All @@ -77,13 +89,21 @@ jobs:

steps:
- uses: actions/checkout@v3
- run: git fetch --prune --tags --unshallow
with:
fetch-depth: 0

- uses: coursier/cache-action@v6

- uses: actions/setup-java@v3
with:
java-version: 8
distribution: temurin

- run: ./millw -i findLatestMill --toFile MILL_DEV_VERSION
if: matrix.os != 'windows-latest' && github.event_name == 'workflow_dispatch'
- run: ./millw.bat -i findLatestMill --toFile MILL_DEV_VERSION
if: matrix.os == 'windows-latest' && github.event_name == 'workflow_dispatch'

- run: ./millw -i __.publishLocal $(pwd)/testRepo
if: matrix.os != 'windows-latest'
- run: .\millw.bat -i __.publishLocal %GITHUB_WORKSPACE%/testRepo
Expand All @@ -98,3 +118,8 @@ jobs:
- name: Publish to Maven Central
run: ./millw -i mill.scalalib.PublishModule/publishAll --sonatypeCreds "${{ secrets.SONATYPE_CREDS }}" --gpgArgs "--passphrase=${{ secrets.GPG_SECRET_KEY_PASS}},--batch,--yes,-a,-b,--pinentry-mode,loopback" --publishArtifacts __.publishArtifacts --readTimeout 600000 --awaitTimeout 600000 --release true --signed true
if: github.event_name != 'workflow_dispatch'

- name: Publish for Mill development version to Maven Central
run: ./millw -i mill.scalalib.PublishModule/publishAll --sonatypeCreds "${{ secrets.SONATYPE_CREDS }}" --gpgArgs "--passphrase=${{ secrets.GPG_SECRET_KEY_PASS}},--batch,--yes,-a,-b,--pinentry-mode,loopback" --publishArtifacts __[$(<MILL_DEV_VERSION)].publishArtifacts --readTimeout 600000 --awaitTimeout 600000 --release true --signed true
if: github.event_name == 'workflow_dispatch'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.idea/
/.idea_modules/
/out/
MILL_DEV_VERSION
36 changes: 33 additions & 3 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import mill.scalalib.publish._
import de.tobiasroeser.mill.integrationtest._
import de.tobiasroeser.mill.vcs.version._
import com.github.lolgab.mill.mima.Mima
import os.Path
import scala.util.Try

val baseDir = build.millSourcePath

Expand All @@ -32,6 +32,12 @@ trait Deps {
val scoverageRuntime = ivy"org.scoverage::scalac-scoverage-runtime:${scoverageVersion}"
}

class Deps_latest(override val millVersion: String) extends Deps {
override def millPlatform = millVersion
override def scalaVersion = "2.13.10"
override def testWithMill = Seq(millVersion)
override def mimaPreviousVersions = Seq()
}
object Deps_0_11 extends Deps {
override def millPlatform = "0.11.0-M8" // only valid for exact milestones!
override def millVersion = "0.11.0-M8-2-f5e4e2"
Expand Down Expand Up @@ -66,7 +72,17 @@ object Deps_0_6 extends Deps {
override def testWithMill = Seq("0.6.3", "0.6.2", "0.6.1", millVersion)
}

val crossDeps = Seq(Deps_0_11, Deps_0_10, Deps_0_9, Deps_0_7, Deps_0_6)
val latestDeps: Seq[Deps] = {
val path = baseDir / "MILL_DEV_VERSION"
println(s"Checking for file ${path}")
if (os.exists(path)) {
Try { Seq(new Deps_latest(os.read(path).trim())) }
.recover { _ => Seq() }
}.get
else Seq()
}

val crossDeps: Seq[Deps] = (Seq(Deps_0_11, Deps_0_10, Deps_0_9, Deps_0_7, Deps_0_6) ++ latestDeps).distinct
val millApiVersions = crossDeps.map(x => x.millPlatform -> x)
val millItestVersions = crossDeps.flatMap(x => x.testWithMill.map(_ -> x))

Expand Down Expand Up @@ -144,7 +160,7 @@ class ItestCross(millItestVersion: String) extends MillIntegrationTestModule {
val millApiVersion = millItestVersions.toMap.apply(millItestVersion).millPlatform
def deps: Deps = millApiVersions.toMap.apply(millApiVersion)

override def millSourcePath: Path = super.millSourcePath / os.up
override def millSourcePath: os.Path = super.millSourcePath / os.up
override def millTestVersion = millItestVersion
override def pluginsUnderTest = Seq(core(millApiVersion))

Expand Down Expand Up @@ -190,3 +206,17 @@ class ItestCross(millItestVersion: String) extends MillIntegrationTestModule {
}

}

def findLatestMill(toFile: String = "") = T.command {
import coursier._
val versions = Versions()
.withModule(mod"com.lihaoyi:mill-main_2.13")
.run()
println(s"Latest Mill versions: ${versions.latest}")
if (toFile.nonEmpty) {
val path = os.Path.expandUser(toFile, os.pwd)
println(s"Writing file: ${path}")
os.write.over(path, versions.latest, createFolders = true)
}
versions.latest
}

0 comments on commit 0763743

Please sign in to comment.