Skip to content

New scala-module-plugin with sbt-ci-release / travisci / dynver / header #54

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

Merged
merged 1 commit into from
Sep 18, 2019
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
39 changes: 14 additions & 25 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,44 +4,33 @@ scala:
- 2.13.0

env:
global:
# PGP_PASSPHRASE
- secure: "NAYlvLQD1OiF+B8NvN+l1Lh0a2xa9FYFfA7LVHt1FXkri6wM/44oVuLF2H7BQTHczFN4754lAR5nrXrBccX1pa4BFmdNLu/nzZIjzjMxz5rFJRcK3nsycJPPUSY6mh5jBP5mR+hyW1zngQPGqCMmwAPP6pANaAztKh34DMSCcdRWb9Gfz6+IL0whCUywYk6LcXBfpD+H0u2ahGUM5ZTWWqqyTDiYmGIhfkXShUZ7oRYNgxffK3BbC5c3UztOTefHMiSCVgqnqNxmFCaGijtm6P1lxW4ebXrklVdb8/Z2AOrJxjV2+Itytb/8w7ukQvYUaPwBoyJYbN0glicMXoYwXKaJ0Rs7VxLFShUQGzDuQFzn5mcjn6r46Gs7aPYC0WTRW6Tx8aaaie7kV+w1zwIx1FrK4OpGaCKGQc73sEUng9EPcVZCbBNS5MNuF/yCfyYN+tSrC7Ms7KzQUwk1aoabEctEqL/Nax8LwayuBBFGrOQnOI9Rt6IxFAze6tJShkcNrZeOp6P/2eCanipHqH18lV3gNr7mKmJL1kTiBdMHo41S/DumNblOz1n5pVOBBLIOjD2Q55uDHAWUPXLbRa+BMtGrmbY2IHIUQPZNKTvnZ5PzoOezP2nSKANUC0V4pN7gVGOmZ/2iPJ7/itdU1tqlQFGRPJvTAzRtsXbPhynEqqw="
# SONA_USER
- secure: "Uc+tOT5E5FEQwLx4ZXZO1Oum1HAhMbvCWpKpkReqdsyb+xBdMbJkt43o8jvM/2WNVMcijEku87o5yWWa/fRDfqBg4GCuwnjUYu/3S0Lyxso8Mgmlcn6khmi09inOvAMVpCdBjvr+krJG1kXgxO62qA3IM0FU9z06Kcngz8F4YhnSGBv2HkOI/+9UHjQeex7tSUSFZi8itnEIN+gK4oWLVItyo0MbH4539BeJyoq/+e70xNxolLFHpVhruBQssg8MS60C5rajo7FXo1BODv+SIR+d1UZ6z8sl2iFU2psijej39nYHzmbxuM9P5Twozs38Rq7g4CM5aFLebna8VZoO6zZtM4PIAyiExkWWILQknrZEhHSded6l73GDeX+eoIigvYNxxAgXMh+MJll1i+XEySLjku8NvarQJ8c09x4S/Rjz1CBEfvlAhM+f117PqVsB87JBnsfE7CABfusJ2wqBpFf9pq9DA3E62XSEniWTIzow37YSR7opRv6wvHzuGrO6OeadIN1P2hb/FDiXDBnqG4xtGUFx81FM0dl9jV97kYiXoaqTwjT0j3d1MBGiN7IzeHxLbczMWA9mvvXtIeOxa73mph3grKKXiRqf/U+455oEIbCObEudjI7zXbjhXGeoVb+OqU7t5Beo+0Lg3H0hyntCsewops/h52lTmgsg5Hw="
# SONA_PASS
- secure: "ggXFZBlzV5ek/rBaE9lrEZlAIfUrv4XDJ4OrP8daMrJxmwkXtoSbcB3z4VgqqWKzAzW89CcU1IiojzDbe/het3xEX4qxdz5Wt05/E+WOgbek528kelwMxq12XRe6xaCVfG+y8OISPgq1q3vKoO/xYGVbK3D6hSD+cjojEXyPpjAfrVSUof06aNPFPQeLX9exgu9zrxkJJm01PbTh19vQk4Ojc++oEmpF7HLD1CF1m7AlW0U2Rba+syivpj9Ray3Z9vu0TnFL06r4TiwZruwcXTLrWUqumFI0r5mhaY6SNH7bqttu+3RPIOdkUGxIeGlkDi3xopt7r2aEkhOKvjRXapW0e/CWmUo1J+NnlIumxrldi4n0iiJGVEvY4Krx/HGZe0wCVTh4vDNOllTGdFmkkxN6WoaHALgj3QNM3XLjvvUu3VcT+QNtsVIvgUDesrtos8zCKczzdhL/d4BMiIg7SFfA33S3vx8BeczLBqddrx+yLSPzfheKrHW7g76EAEyN26vE2/2/GRlMOlG8Lmu8rXBfIPsK9T/ztfE1CxaTW5EsMSrxO2+O/bvAa6DY0R79KkHf7LDI+azzP2NwYx8anM9WlMTp4EbawI/KGZRilWYtJ3Q3y5EQERsrP71W35dKqiBFMPdspS+lTS9hGtso08n7cR2MwTbRjoXVRcWfJ/I="
matrix:
# The empty SCALAJS_VERSION will only compile for the JVM
- SCALAJS_VERSION= ADOPTOPENJDK=8 MODULE=scala-collection-contrib
- SCALAJS_VERSION=0.6.28 ADOPTOPENJDK=8 MODULE=scala-collection-contribJS
- SCALAJS_VERSION=1.0.0-M8 ADOPTOPENJDK=8 MODULE=scala-collection-contribJS
- SCALAJS_VERSION= ADOPTOPENJDK=11 MODULE=scala-collection-contrib
- SCALAJS_VERSION= ADOPTOPENJDK=8
- SCALAJS_VERSION=0.6.29 ADOPTOPENJDK=8
- SCALAJS_VERSION=1.0.0-M8 ADOPTOPENJDK=8
- SCALAJS_VERSION= ADOPTOPENJDK=11

before_install:
# adding $HOME/.sdkman to cache would create an empty directory, which interferes with the initial installation
- "[[ -d $HOME/.sdkman/bin ]] || rm -rf $HOME/.sdkman/"
- curl -sL https://get.sdkman.io | bash
- echo sdkman_auto_answer=true > "$HOME/.sdkman/etc/config"
- echo sdkman_auto_answer=true > $HOME/.sdkman/etc/config
- source "$HOME/.sdkman/bin/sdkman-init.sh"

install:
- sdk install java $(sdk list java | grep -o "$ADOPTOPENJDK\.[0-9\.]*hs-adpt" | head -1)
- unset JAVA_HOME
- java -Xmx32m -version
- javac -J-Xmx32m -version
- git fetch --tags # get all tags for sbt-dynver

script:
- admin/build.sh
script: ./build.sh

before_cache:
- find $HOME/.sbt -name "*.lock" | xargs rm
- find $HOME/.ivy2/cache -name "ivydata-*.properties" | xargs rm
- rm -f $HOME/.ivy2/.sbt.ivy.lock
- find $HOME/.ivy2/cache -name "ivydata-*.properties" | xargs rm
- find $HOME/.sbt -name "*.lock" | xargs rm
cache:
directories:
- $HOME/.ivy2/cache
- $HOME/.coursier
- $HOME/.sbt/1.0
- $HOME/.sbt/boot
- $HOME/.sbt/launchers
- $HOME/.sdkman
- $HOME/.ivy2/cache
- $HOME/.sbt
- $HOME/.cache/coursier
- $HOME/.sdkman
68 changes: 0 additions & 68 deletions admin/README.md

This file was deleted.

48 changes: 0 additions & 48 deletions admin/build.sh

This file was deleted.

11 changes: 0 additions & 11 deletions admin/encryptEnvVars.sh

This file was deleted.

41 changes: 0 additions & 41 deletions admin/genKeyPair.sh

This file was deleted.

1 change: 0 additions & 1 deletion admin/gpg.sbt

This file was deleted.

8 changes: 0 additions & 8 deletions admin/publish-settings.sbt

This file was deleted.

18 changes: 0 additions & 18 deletions admin/pubring.asc

This file was deleted.

Binary file removed admin/secring.asc.enc
Binary file not shown.
43 changes: 15 additions & 28 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,48 +1,35 @@
import sbtcrossproject.CrossPlugin.autoImport.{ crossProject, CrossType }
import ScalaModulePlugin._
import sbtcrossproject.CrossPlugin.autoImport.{CrossType, crossProject}

lazy val root = project.in(file("."))
.aggregate(`scala-collection-contribJS`, `scala-collection-contribJVM`)
.settings(
disablePublishing,
// HACK If we don’t add this dependency the tests compilation of the aggregated projects fails
libraryDependencies += "junit" % "junit" % "4.12" % Test
)
// With CrossType.Pure, the root project also picks up the sources in `src`
Compile/sources := Nil
Test/sources := Nil

lazy val `scala-collection-contrib` = crossProject(JVMPlatform, JSPlatform)
lazy val collectionContrib = crossProject(JVMPlatform, JSPlatform)
.withoutSuffixFor(JVMPlatform)
.crossType(CrossType.Pure)
.withoutSuffixFor(JVMPlatform).in(file("."))
.settings(scalaModuleSettings)
.jvmSettings(scalaModuleSettingsJVM)
.in(file("."))
.settings(ScalaModulePlugin.scalaModuleSettings)
.jvmSettings(ScalaModulePlugin.scalaModuleSettingsJVM)
.settings(
name := "scala-collection-contrib",
version := "0.2.1-SNAPSHOT",

crossScalaVersions in ThisBuild := Seq("2.13.0"),

scalacOptions ++= Seq("-opt-warnings", "-language:higherKinds", "-deprecation", "-feature", "-Xfatal-warnings"),
scalacOptions in (Compile, doc) ++= Seq("-implicits", "-groups"),

testOptions += Tests.Argument(TestFrameworks.JUnit, "-q", "-v", "-s", "-a"),
parallelExecution in Test := false, // why?

mimaPreviousVersion := Some("0.1.0"),

homepage := Some(url("https://github.com/scala/scala-collection-contrib")),
licenses := Seq("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0")),

libraryDependencies ++= Seq(
"junit" % "junit" % "4.12" % Test,
"com.novocode" % "junit-interface" % "0.11" % Test,
"org.openjdk.jol" % "jol-core" % "0.9" % Test
)
)
.jvmSettings(
scalaModuleMimaPreviousVersion := Some("0.1.0"), // why only in jvmSettings?
// TODO: osgi settings; not trivial because of split packages.
// See https://github.com/scala/scala-collection-compat/pull/226
// OsgiKeys.exportPackage := Seq(s"scala.collection.*;version=${version.value}"),
)
.jsConfigure(_.enablePlugins(ScalaJSJUnitPlugin))
.jsSettings(
mimaPreviousVersion := None,
// Scala.js cannot run forked tests
fork in Test := false
)

lazy val `scala-collection-contribJVM` = `scala-collection-contrib`.jvm
lazy val `scala-collection-contribJS` = `scala-collection-contrib`.js
73 changes: 73 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
#!/bin/bash

set -e

# Builds of tagged revisions are published to sonatype staging.

# Travis runs a build on new revisions and on new tags, so a tagged revision is built twice.
# Builds for a tag have TRAVIS_TAG defined, which we use for identifying tagged builds.

# sbt-dynver sets the version number from the tag
# sbt-travisci sets the Scala version from the travis job matrix

# When a new binary incompatible Scala version becomes available, a previously released version
# can be released using that new Scala version by creating a new tag containing the Scala version
# after a hash, e.g., v1.2.3#2.13.0-M3. In this situation, the first job of the travis job
# matrix builds the release. All other jobs are stopped. Make sure that the first job uses
# the desired JVM version.

# For normal tags that are cross-built, we release on JDK 8 for Scala 2.x
isReleaseJob() {
if [[ "$ADOPTOPENJDK" == "8" ]]; then
true
else
false
fi
}

# For tags that define a Scala version, we pick the jobs of one Scala version (2.13.x) to do the releases
isTagScalaReleaseJob() {
if [[ "$ADOPTOPENJDK" == "8" && "$TRAVIS_SCALA_VERSION" =~ ^2\.13\.[0-9]+$ ]]; then
true
else
false
fi
}

if [[ "$SCALAJS_VERSION" != "" ]]; then
projectPrefix="collectionContribJS"
else
projectPrefix="collectionContrib"
fi

verPat="[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)?"
tagPat="^v$verPat(#$verPat)?$"

if [[ "$TRAVIS_TAG" =~ $tagPat ]]; then
releaseTask="ci-release"
tagScalaVer=$(echo $TRAVIS_TAG | sed s/[^#]*// | sed s/^#//)
if [[ "$tagScalaVer" == "" ]]; then
if ! isReleaseJob; then
echo "Not releasing on Java $ADOPTOPENJDK with Scala $TRAVIS_SCALA_VERSION"
exit 0
fi
else
if isTagScalaReleaseJob; then
setTagScalaVersion='set every scalaVersion := "'$tagScalaVer'"'
else
echo "The releases for Scala $tagScalaVer are built by other jobs in the travis job matrix"
exit 0
fi
fi
fi

# default is +publishSigned; we cross-build with travis jobs, not sbt's crossScalaVersions
export CI_RELEASE="$projectPrefix/publishSigned"
export CI_SNAPSHOT_RELEASE="$projectPrefix/publish"

# default is sonatypeBundleRelease, which closes and releases the staging repo
# see https://github.com/xerial/sbt-sonatype#commands
# for now, until we're confident in the new release scripts, just close the staging repo.
export CI_SONATYPE_RELEASE="; sonatypePrepare; sonatypeBundleUpload; sonatypeClose"

sbt "$setTagScalaVersion" clean $projectPrefix/test $projectPrefix/publishLocal $releaseTask
Loading