Skip to content

Commit 8a00d5f

Browse files
authored
Merge pull request #223 from lrytz/crossTravis
No longer use `scalaVersionsByJvm`
2 parents b04fc82 + bded45d commit 8a00d5f

File tree

7 files changed

+95
-89
lines changed

7 files changed

+95
-89
lines changed

Diff for: .gitignore

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
*.jar
1313
*~
1414

15-
build.properties
16-
1715
# target directories for ant build
1816
/build/
1917
/dists/

Diff for: .travis.yml

+30-13
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,20 @@
1-
# opt-in to Travis's newer/faster container-based infrastructure
2-
sudo: false
3-
41
language: scala
52

3+
addons:
4+
apt:
5+
packages:
6+
- openjdk-6-jdk
7+
8+
jdk:
9+
- openjdk6
10+
- oraclejdk8
11+
- oraclejdk9
12+
13+
scala:
14+
- 2.11.12
15+
- 2.12.6
16+
- 2.13.0-M3
17+
618
env:
719
global:
820
# PGP_PASSPHRASE
@@ -11,18 +23,23 @@ env:
1123
- secure: "OpBwPc1GNvauageYOH3RscAa7wpZxgpmqDz15aigIKLNWzAhAtVUx0MleZ8rQeoqml6nrAvlnzuVHjKL2lVcjMPpjUis7bcQ5UAGK7tZK8x+qZNQxXmpXu8+pENwQA2yFaqt/xy7K5jFOrHJHTRxcPnyVG1yKakPWz53PPYUwbc="
1224
# SONA_PASS
1325
- secure: "Xw7rI/qlML1nD2e2XwlakkhKAWNGZKqqE+Q3ntTvFpfHryl7KLCvVzJ4LIavnL6kGJaWOgy9vlSoEWn5g9nqHSfE31C/k5pY5nTMAKiwiJzfAS+r0asKXW2gmKhwtcTBkqyLVOZLCJSPVlFRQyfBJHY+Fs0L3KWcnMQgtBlyDhU="
26+
matrix:
27+
- SCALAJS_VERSION=
28+
- SCALAJS_VERSION=0.6.23
29+
- SCALAJS_VERSION=1.0.0-M3
1430

15-
script: admin/build.sh
16-
17-
addons:
18-
apt:
19-
packages:
20-
- openjdk-6-jdk
31+
matrix:
32+
exclude:
33+
- scala: 2.13.0-M3
34+
env: SCALAJS_VERSION=1.0.0-M3
35+
- jdk: oraclejdk9
36+
env: SCALAJS_VERSION=1.0.0-M3
37+
- scala: 2.12.6
38+
jdk: openjdk6
39+
- scala: 2.13.0-M3
40+
jdk: openjdk6
2141

22-
jdk:
23-
- openjdk6
24-
- oraclejdk8
25-
- oraclejdk9
42+
script: admin/build.sh
2643

2744
notifications:
2845

Diff for: admin/README.md

+15-18
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,35 @@
11
## Tag Driven Releasing
22

3-
### Background Reading
4-
5-
- http://docs.travis-ci.com/user/environment-variables/
6-
- http://docs.travis-ci.com/user/encryption-keys/
7-
- http://docs.travis-ci.com/user/encrypting-files/
8-
93
### Initial setup for the repository
104

115
To configure tag driven releases from Travis CI.
126

137
1. Generate a key pair for this repository with `./admin/genKeyPair.sh`.
148
Edit `.travis.yml` and `admin/build.sh` as prompted.
159
1. Publish the public key to https://pgp.mit.edu
16-
1. Store other secrets as encrypted environment variables with `admin/encryptEnvVars.sh`.
10+
1. Store other secrets as encrypted environment variables with `./admin/encryptEnvVars.sh`.
1711
Edit `.travis.yml` as prompted.
1812
1. Edit `.travis.yml` to use `./admin/build.sh` as the build script,
1913
and edit that script to use the tasks required for this project.
20-
1. Edit `build.sbt`'s `scalaVersionsByJvm in ThisBuild` to select Scala and JVM version
21-
combinations that will be used for publishing.
14+
Ensure that `RELEASE_COMBO` is `true` for build matrix combinations
15+
that should be released to sonatype (when building a tag).
2216

2317
It is important to add comments in `.travis.yml` to identify the name
24-
of each environment variable encoded in a `:secure` section.
18+
of each environment variable encoded in a `secure` section.
2519

2620
After these steps, your `.travis.yml` should contain config of the form:
2721

2822
```
2923
language: scala
3024
25+
jdk:
26+
- openjdk6
27+
- oraclejdk8
28+
29+
scala:
30+
- 2.11.12
31+
- 2.12.6
32+
3133
env:
3234
global:
3335
# PGP_PASSPHRASE
@@ -39,10 +41,6 @@ env:
3941
4042
script: admin/build.sh
4143
42-
jdk:
43-
- openjdk6
44-
- oraclejdk8
45-
4644
notifications:
4745
email:
4846
@@ -62,10 +60,9 @@ without generating a new key.
6260
1. Create a GitHub "Release" with a corresponding tag (e.g., `v0.1.1`) via the GitHub
6361
web interface.
6462
1. The release will be published using the Scala and JVM version combinations specified
65-
in `scalaVersionsByJvm` in `build.sbt`.
66-
- If you need to release against a different Scala version, include the Scala version
67-
and the JVM version to use in the tag name, separated by `#`s (e.g., `v0.1.1#2.13.0-M1#8`).
68-
Note that the JVM version needs to be listed in `.travis.yml` for the build to run.
63+
in the travis build matrix where `[ "$RELEASE_COMBO" = "true" ]`.
64+
- If you need to release against a different Scala version, create a new commit that modifies
65+
`.travis.yml` and push a new tag, e.g., `v1.2.3#2.13.0-M5`. The suffix after `#` is ignored.
6966
1. Travis CI will schedule a build for this release. Review the build logs.
7067
1. Log into https://oss.sonatype.org/ and identify the staging repository.
7168
1. Sanity check its contents.

Diff for: admin/build.sh

+28-29
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,44 @@ set -e
99
# Checking the local git clone would not work because git on travis does not fetch tags.
1010

1111
# The version number to be published is extracted from the tag, e.g., v1.2.3 publishes
12-
# version 1.2.3 using all Scala versions in build.sbt's `crossScalaVersions`.
12+
# version 1.2.3 on all combinations of the travis matrix where `[ "$RELEASE_COMBO" = "true" ]`.
1313

14-
# When a new, binary incompatible Scala version becomes available, a previously released version
15-
# can be released using that new Scala version by creating a new tag containing the Scala and the
16-
# JVM version after hashes, e.g., v1.2.3#2.13.0-M1#8. The JVM version needs to be listed in
17-
# `.travis.yml`, otherwise the required build doesn't run.
14+
# In order to build a previously released version against a new (binary incompatible) Scala release,
15+
# a new commit that modifies (and prunes) the Scala versions in .travis.yml needs to be added on top
16+
# of the existing tag. Then a new tag can be created for that commit, e.g., `v1.2.3#2.13.0-M5`.
17+
# Everything after the `#` in the tag name is ignored.
18+
19+
if [[ "$TRAVIS_JDK_VERSION" == "openjdk6" && "$TRAVIS_SCALA_VERSION" =~ 2\.11\..* || "$TRAVIS_JDK_VERSION" == "oraclejdk8" && "$TRAVIS_SCALA_VERSION" =~ 2\.1[23]\..* ]]; then
20+
RELEASE_COMBO=true;
21+
fi
22+
23+
if [ "$SCALAJS_VERSION" = "" ]; then
24+
projectPrefix="xml"
25+
else
26+
projectPrefix="xmlJS"
27+
fi
1828

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

2232
if [[ "$TRAVIS_TAG" =~ $tagPat ]]; then
23-
currentJvmVer=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | sed 's/^1\.//' | sed 's/[^0-9].*//')
24-
2533
tagVer=$(echo $TRAVIS_TAG | sed s/#.*// | sed s/^v//)
2634
publishVersion='set every version := "'$tagVer'"'
2735
28-
scalaAndJvmVer=$(echo $TRAVIS_TAG | sed s/[^#]*// | sed s/^#//)
29-
if [ "$scalaAndJvmVer" != "" ]; then
30-
scalaVer=$(echo $scalaAndJvmVer | sed s/#.*//)
31-
jvmVer=$(echo $scalaAndJvmVer | sed s/[^#]*// | sed s/^#//)
32-
if [ "$jvmVer" != "$currentJvmVer" ]; then
33-
echo "Not publishing $TRAVIS_TAG on Java version $currentJvmVer."
34-
exit 0
35-
fi
36-
publishScalaVersion='set every ScalaModulePlugin.scalaVersionsByJvm := Map('$jvmVer' -> List("'$scalaVer'" -> true))'
37-
echo "Releasing $tagVer using Scala $scalaVer on Java version $jvmVer."
38-
else
39-
echo "Releasing $tagVer on Java version $currentJvmVer according to 'scalaVersionsByJvm' in build.sbt."
40-
fi
36+
if [ "$RELEASE_COMBO" = "true" ]; then
37+
currentJvmVer=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | sed 's/^1\.//' | sed 's/[^0-9].*//')
38+
echo "Releasing $tagVer with Scala $TRAVIS_SCALA_VERSION on Java version $currentJvmVer."
4139
42-
extraTarget="+publish-signed"
43-
cat admin/gpg.sbt >> project/plugins.sbt
44-
cp admin/publish-settings.sbt .
40+
publishTask="$projectPrefix/publish-signed"
4541
46-
# Copied from the output of genKeyPair.sh
47-
K=$encrypted_6b8d67feaab7_key
48-
IV=$encrypted_6b8d67feaab7_iv
42+
cat admin/gpg.sbt >> project/plugins.sbt
43+
cp admin/publish-settings.sbt .
4944
50-
openssl aes-256-cbc -K $K -iv $IV -in admin/secring.asc.enc -out admin/secring.asc -d
45+
# Copied from the output of genKeyPair.sh
46+
K=$encrypted_6b8d67feaab7_key
47+
IV=$encrypted_6b8d67feaab7_iv
48+
openssl aes-256-cbc -K $K -iv $IV -in admin/secring.asc.enc -out admin/secring.asc -d
49+
fi
5150
fi
5251
53-
sbt "$publishVersion" "$publishScalaVersion" clean update +test +publishLocal $extraTarget
52+
sbt "++$TRAVIS_SCALA_VERSION" "$publishVersion" "$projectPrefix/clean" "$projectPrefix/test" "$projectPrefix/publishLocal" "$publishTask"

Diff for: admin/publish-settings.sbt

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
def env(key: String) = Option(System.getenv(key)).getOrElse("")
22

3-
pgpPassphrase := Some(env("PGP_PASSPHRASE").toArray)
4-
5-
pgpPublicRing := file("admin/pubring.asc")
6-
7-
pgpSecretRing := file("admin/secring.asc")
8-
9-
credentials += Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", env("SONA_USER"), env("SONA_PASS"))
3+
inThisBuild(Seq(
4+
pgpPassphrase := Some(env("PGP_PASSPHRASE").toArray),
5+
pgpPublicRing := file("admin/pubring.asc"),
6+
pgpSecretRing := file("admin/secring.asc"),
7+
credentials += Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", env("SONA_USER"), env("SONA_PASS"))
8+
))

Diff for: build.sbt

+10-17
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,12 @@
1+
import sbtcrossproject.{crossProject, CrossType}
12
import ScalaModulePlugin._
23

3-
scalaVersionsByJvm in ThisBuild := {
4-
val v211 = "2.11.12"
5-
val v212 = "2.12.4"
6-
val v213 = "2.13.0-M3"
7-
Map(
8-
6 -> List(v211 -> true),
9-
7 -> List(v211 -> false),
10-
8 -> List(v212 -> true, v213 -> true, v211 -> false),
11-
9 -> List(v212 -> false, v213 -> false, v211 -> false))
12-
}
4+
crossScalaVersions in ThisBuild := List("2.12.6", "2.11.12", "2.13.0-M3")
135

14-
lazy val root = project.in(file("."))
15-
.aggregate(xmlJS, xmlJVM)
16-
.settings(disablePublishing)
17-
18-
lazy val xml = crossProject.in(file("."))
6+
lazy val xml = crossProject(JSPlatform, JVMPlatform)
7+
.withoutSuffixFor(JVMPlatform)
8+
.crossType(CrossType.Full)
9+
.in(file("."))
1910
.settings(scalaModuleSettings)
2011
.jvmSettings(scalaModuleSettingsJVM)
2112
.settings(
@@ -27,7 +18,10 @@ lazy val xml = crossProject.in(file("."))
2718
scalacOptions ++= "-deprecation:false -feature -Xlint:-stars-align,-nullary-unit,_".split("\\s+").to[Seq],
2819
scalacOptions in Test += "-Xxml:coalescing",
2920

30-
mimaPreviousVersion := Some("1.1.0"),
21+
mimaPreviousVersion := {
22+
if (System.getenv("SCALAJS_VERSION") == "1.0.0-M3") None // No such release yet
23+
else Some("1.1.0")
24+
},
3125

3226
apiMappings ++= Map(
3327
scalaInstance.value.libraryJar
@@ -48,7 +42,6 @@ lazy val xml = crossProject.in(file("."))
4842
-> url("http://docs.oracle.com/javase/9/docs/api"),
4943
file("/modules/java.xml")
5044
-> url("http://docs.oracle.com/javase/9/docs/api")
51-
5245
)
5346
}
5447
}

Diff for: project/plugins.sbt

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
1-
addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "1.0.14")
2-
31
if (System.getProperty("java.version").startsWith("1."))
42
Seq()
53
else
64
// override to version that works on Java 9,
75
// see https://github.com/scala/sbt-scala-module/issues/35
86
Seq(addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.3"))
97

10-
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.22")
8+
val scalaJSVersion =
9+
Option(System.getenv("SCALAJS_VERSION")).filter(_.nonEmpty).getOrElse("0.6.23")
10+
11+
addSbtPlugin("org.scala-js" % "sbt-scalajs" % scalaJSVersion)
12+
addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.4.0")
13+
addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "1.0.14")

0 commit comments

Comments
 (0)