Skip to content

Commit

Permalink
Upgrade to mill 0.8.0 and improve import syntax on example (#13)
Browse files Browse the repository at this point in the history
  • Loading branch information
vic authored Oct 3, 2020
1 parent e17e6ac commit 62aff79
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 41 deletions.
30 changes: 23 additions & 7 deletions .github/workflows/workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,44 @@ on:
- cron: "0 0 * * 5"

jobs:
test:

scalafmt:
strategy:
matrix:
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v2
- uses: coursier/cache-action@v3
with:
extraFiles: cs
- run: ./ci scalafmt-test

example:
strategy:
matrix:
os: [ubuntu-latest]

runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Test
run: ./ci test
- uses: actions/checkout@v2
- uses: coursier/cache-action@v3
with:
extraFiles: cs
- run: ./ci example

jitpack-commit:
needs: test
needs: example
runs-on: ubuntu-latest
steps:
- name: JitPack commit build
run: curl -vSL https://jitpack.io/com/github/$GITHUB_REPOSITORY/$GITHUB_SHA/build.log || true

jitpack-release:
needs: test
needs: example
runs-on: ubuntu-latest
if: contains(github.ref, 'tags')
steps:
Expand Down
2 changes: 1 addition & 1 deletion .mill-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.3
0.8.0
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## 0.5.1 - [Unreleased]

- Upgrade to mill 0.8.0

## [0.5.0]

### Changed
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.5.0
0.5.1
28 changes: 17 additions & 11 deletions build.sc
Original file line number Diff line number Diff line change
@@ -1,22 +1,28 @@
// -*- mode: scala -*-

import $ivy.`io.get-coursier:interface:0.0.21`
import mill._, scalalib._, publish._
import ammonite.ops._
import scala.util.Properties

// Dont use sonatype's maven-central as it timeouts in travis.
interp.repositories() =
List(coursierapi.MavenRepository.of("https://jcenter.bintray.com"))
object meta {
val crossVersions = Seq("2.13.2", "2.12.11")

@
implicit val wd: os.Path = os.pwd

val crossVersions = Seq("2.13.2", "2.12.11")
def nonEmpty(s: String): Option[String] = s.trim match {
case v if v.isEmpty => None
case v => Some(v)
}

import mill._
import scalalib._
import publish._
val versionFromEnv = Properties.propOrNone("PUBLISH_VERSION")
val gitSha = nonEmpty(%%("git", "rev-parse", "--short", "HEAD").out.trim)
val gitTag = nonEmpty(%%("git", "tag", "-l", "-n0", "--points-at", "HEAD").out.trim)
val publishVersion = (versionFromEnv orElse gitTag orElse gitSha).getOrElse("latest")
}

object docker extends Cross[Docker](crossVersions: _*)
object docker extends Cross[Docker](meta.crossVersions: _*)
class Docker(val crossScalaVersion: String) extends CrossScalaModule with PublishModule {
def publishVersion = os.read(os.pwd / "VERSION").trim
def publishVersion = meta.publishVersion

def artifactName = "mill-docker"

Expand Down
36 changes: 25 additions & 11 deletions ci
Original file line number Diff line number Diff line change
@@ -1,37 +1,51 @@
#!/usr/bin/env bash
set -ex

BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"

function die {
echo "$*" >&2
exit 1
}

case "$1" in

jitpack)
exec $0 mill -j 0 __.publishM2Local
;;

mill)
exec $0 cs launch mill -- "${@:2}"
exec $0 cs launch "mill:$(< $BASE_DIR/.mill-version)" -- "${@:2}"
;;

mill-i)
exec $0 cs launch "mill-interactive:$(< $BASE_DIR/.mill-version)" -- -i "${@:2}"
;;

scalafmt)
exec $0 cs launch scalafmt -- --mode diff --diff-branch master "${@:2}"
;;

scalafmt-test)
$0 scalafmt --test
;;

cs)
test -x cs || {
curl -o cs -qL https://git.io/coursier-cli
chmod +x cs
test -x $BASE_DIR/cs || {
curl -o $BASE_DIR/cs -qL https://git.io/coursier-cli
chmod +x $BASE_DIR/cs
}
exec ./cs "${@:2}"
exec $BASE_DIR/cs "${@:2}"
;;

example)
(cd example; ../ci mill hello.dockerBuild)
docker run -i hello:latest
$0 mill-i -j 0 -D PUBLISH_VERSION=latest __.publishLocal
(cd example; ../ci mill hello.dockerBuild)
docker run -i hello:latest
;;

test)
$0 scalafmt --test
$0 mill -j 0 __.publishLocal
$0 example
$0 mill -j 0 __.tests
;;

release)
Expand Down
Binary file added cs
Binary file not shown.
15 changes: 5 additions & 10 deletions example/build.sc
Original file line number Diff line number Diff line change
@@ -1,24 +1,19 @@
// -*- mode: scala -*-

import $ivy.`io.get-coursier:interface:0.0.21`

// add mill-docker artifact repo
import mill._
interp.repositories() =
interp.repositories() ++ Seq(coursierapi.MavenRepository.of("https://jitpack.io"))

@
import $repo.`https://jitpack.io`

import mill._, scalalib._

// import mill-docker
import $ivy.`io.github.vic::mill-docker:0.5.0`, mill.docker._
import $ivy.`io.github.vic::mill-docker:latest`
import mill.docker._


object hello extends ScalaModule with DockerModule {
def scalaVersion = "2.13.2"
def dockerTag = "hello:latest"

override def finalMainClass = T("example.hello")

// optionally provide default arguments to your program
// def dockerMainArgs = Seq("world")

Expand Down

0 comments on commit 62aff79

Please sign in to comment.