Skip to content

Commit 9a36184

Browse files
committed
Allow building an existing tag against a new Scala version
For tags of the form `v1.2.3-suffix#2.13.0-M1#8`, the build script releases version `1.2.3-suffix` using Scala version `2.13.0-M1` on Java version 8. This allows building an existing tag against a new Scala version.
1 parent d01afce commit 9a36184

File tree

6 files changed

+89
-56
lines changed

6 files changed

+89
-56
lines changed

.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ sudo: required
44

55
env:
66
global:
7-
- PUBLISH_JDK=oraclejdk8
87
# PGP_PASSPHRASE
98
- secure: "aL0veasRyeyMG6GILAQlWdo7r7yEW3zuG5c79eCaO0j26EFSNHsW04gwEJrj1FNuD7YRTHxBQoUnaYF+lr8d9CVYS1+TkHmqIaYpbgkpVa4DY7WdCSaHdqr0C6FkBtCRhtFseS4db7HkT4EsJPFR42NR7/uo1pSY1V/SebanaRfMbCcBUOqzpFBIAHMOJzpFSO9EqAPI7MZKWT8iLU2gluhDAD/5LMG2iDsqUvuqWvCMPEV00a1G4Fq6O29KHYUTsGNgF8p+4GVRJgAxxQKydeNKDWuZ1cPGulxLTWSxlMlFtGuN1qEZUUbb93w+kgAXky5X7CkOcBEtQs8+XgiMc0DvZvxvprPHYyGBUr6dRo8f1ztZtcDr3IEVZ6brfTflCufvokHrfdcIdsRj7MYnVS8QWHikPBaSsMjsqLEOh0VjtQQ4DkmMSo1U0XIIzMm3U61xrSpdMQYhByFWJA63m3pxj0Qt80TGABB0zW4+sLZaAuX+tjF6mA2JncKqUausJ4LWMPmxh35/s0tTc7FzQsZUjTVZ3Kii80uZPtDhiyXcPfErXMIXj8EjPm6n8pM+/AMdb+FH9vAkZ/T6LW9TOZsPY9dNqyZcyXmJ2vvza9HTOzTTutOf1dVqx9rFXD89uIwH8OQtsVpk0X0Oo7ctlNNRURk/oWEuD4VW0L3PviY="
109
# SONA_USER

admin/README.md

+41-30
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
## Tag Driven Releasing
22

3-
Copied from https://github.com/scala/scala-java8-compat/commit/4a6cfc97cd95227b86650410e1b632e5ff79335b.
4-
53
### Background Reading
64

75
- http://docs.travis-ci.com/user/environment-variables/
@@ -14,48 +12,61 @@ To configure tag driven releases from Travis CI.
1412

1513
1. Generate a key pair for this repository with `./admin/genKeyPair.sh`.
1614
Edit `.travis.yml` and `admin/build.sh` as prompted.
17-
2. Publish the public key to https://pgp.mit.edu
18-
3. Store other secrets as encrypted environment variables with `admin/encryptEnvVars.sh`.
15+
1. Publish the public key to https://pgp.mit.edu
16+
1. Store other secrets as encrypted environment variables with `admin/encryptEnvVars.sh`.
1917
Edit `.travis.yml` as prompted.
20-
4. Edit `.travis.yml` to use `./admin/build.sh` as the build script,
18+
1. Edit `.travis.yml` to use `./admin/build.sh` as the build script,
2119
and edit that script to use the tasks required for this project.
22-
5. Edit `.travis.yml` to select which JDK will be used for publishing.
20+
1. Edit `build.sbt`'s `scalaVersionsByJvm` to select Scala and JVM version combinations that
21+
will be used for publishing.
2322

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

27-
After all of these steps, your .travis.yml should contain config of the
28-
form:
29-
30-
language: scala
31-
env:
32-
global:
33-
- PUBLISH_JDK=openjdk6
34-
# PGP_PASSPHRASE
35-
- secure: "XXXXXX"
36-
# SONA_USER
37-
- secure: "XXXXXX"
38-
# SONA_PASS
39-
- secure: "XXXXXX"
40-
script: admin/build.sh
26+
After these steps, your `.travis.yml` should contain config of the form:
27+
28+
```
29+
language: scala
30+
31+
env:
32+
global:
33+
# PGP_PASSPHRASE
34+
- secure: "XXXXXX"
35+
# SONA_USER
36+
- secure: "XXXXXX"
37+
# SONA_PASS
38+
- secure: "XXXXXX"
39+
40+
script: admin/build.sh
41+
42+
jdk:
43+
- openjdk6
44+
- oraclejdk8
45+
46+
notifications:
47+
email:
48+
49+
```
4150

4251
If Sonatype credentials change in the future, step 3 can be repeated
4352
without generating a new key.
4453

45-
Be sure to use SBT 0.13.7 or higher to avoid [#1430](https://github.com/sbt/sbt/issues/1430)!
46-
4754
### Testing
4855

49-
1. Follow the release process below to create a dummy release (e.g. 0.1.0-TEST1).
56+
1. Follow the release process below to create a dummy release (e.g., `v0.1.0-TEST1`).
5057
Confirm that the release was staged to Sonatype but do not release it to Maven
5158
central. Instead, drop the staging repository.
5259

5360
### Performing a release
5461

55-
1. Create a GitHub "Release" (with a corresponding tag) via the GitHub
62+
1. Create a GitHub "Release" with a corresponding tag (e.g., `v0.1.1`) via the GitHub
5663
web interface.
57-
2. Travis CI will schedule a build for this release. Review the build logs.
58-
3. Log into https://oss.sonatype.org/ and identify the staging repository.
59-
4. Sanity check its contents
60-
5. Release staging repository to Maven and send out release announcement.
61-
64+
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.
69+
1. Travis CI will schedule a build for this release. Review the build logs.
70+
1. Log into https://oss.sonatype.org/ and identify the staging repository.
71+
1. Sanity check its contents.
72+
1. Release staging repository to Maven and send out release announcement.

admin/build.sh

+36-8
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,43 @@
22

33
set -e
44

5-
# prep environment for publish to sonatype staging if the HEAD commit is tagged
5+
# Builds of tagged revisions are published to sonatype staging.
66

7-
# git on travis does not fetch tags, but we have TRAVIS_TAG
8-
# headTag=$(git describe --exact-match ||:)
7+
# Travis runs a build on new revisions and on new tags, so a tagged revision is built twice.
8+
# Builds for a tag have TRAVIS_TAG defined, which we use for identifying tagged builds.
9+
# Checking the local git clone would not work because git on travis does not fetch tags.
10+
11+
# 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`.
13+
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.
18+
19+
verPat="[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)?"
20+
tagPat="^v$verPat(#$verPat#[0-9]+)?$"
21+
22+
if [[ "$TRAVIS_TAG" =~ $tagPat ]]; then
23+
currentJvmVer=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | sed 's/^1\.//' | sed 's/[^0-9].*//')
24+
25+
tagVer=$(echo $TRAVIS_TAG | sed s/#.*// | sed s/^v//)
26+
publishVersion='set every version := "'$tagVer'"'
27+
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 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
941
10-
if [ "$TRAVIS_JDK_VERSION" == "$PUBLISH_JDK" ] && [[ "$TRAVIS_TAG" =~ ^v[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)? ]]; then
11-
echo "Going to release from tag $TRAVIS_TAG!"
12-
myVer=$(echo $TRAVIS_TAG | sed -e s/^v//)
13-
publishVersion='set every version := "'$myVer'"'
1442
extraTarget="+publish-signed"
1543
cat admin/gpg.sbt >> project/plugins.sbt
1644
cp admin/publish-settings.sbt .
@@ -22,4 +50,4 @@ if [ "$TRAVIS_JDK_VERSION" == "$PUBLISH_JDK" ] && [[ "$TRAVIS_TAG" =~ ^v[0-9]+\.
2250
openssl aes-256-cbc -K $K -iv $IV -in admin/secring.asc.enc -out admin/secring.asc -d
2351
fi
2452
25-
sbt "$publishVersion" clean update +test +checkHeaders +publishLocal $extraTarget
53+
sbt "$publishVersion" "$publishScalaVersion" clean update +test +checkHeaders +publishLocal $extraTarget

build.sbt

+10-15
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
1-
resolvers in ThisBuild += "scala-pr" at "https://scala-ci.typesafe.com/artifactory/scala-integration/"
1+
import ScalaModulePlugin._
22

3-
crossScalaVersions in ThisBuild := Seq("2.13.0-M1")
3+
version in ThisBuild := "0.1.2-SNAPSHOT"
44

5-
scalaVersion in ThisBuild := crossScalaVersions.value.head
5+
scalaVersionsByJvm in ThisBuild := {
6+
val v213 = "2.13.0-M1"
7+
Map(
8+
8 -> List(v213 -> true),
9+
9 -> List(v213 -> false))
10+
}
611

7-
version in ThisBuild := "0.1.2-SNAPSHOT"
8-
9-
scalacOptions in ThisBuild ++= Seq("-deprecation", "-feature", "-Xfatal-warnings")
12+
scalacOptions in ThisBuild ++= Seq("-deprecation", "-feature", "-Xfatal-warnings")
1013

1114
cancelable in Global := true
1215

13-
val disablePublishing = Seq[Setting[_]](
14-
publishArtifact := false,
15-
// The above is enough for Maven repos but it doesn't prevent publishing of ivy.xml files
16-
publish := {},
17-
publishLocal := {},
18-
publishTo := Some(Resolver.file("devnull", file("/dev/null")))
19-
)
20-
2116
disablePublishing // in root
2217

2318
/** Create an OSGi version range for standard Scala / Lightbend versioning
@@ -30,7 +25,7 @@ def osgiVersionRange(version: String): String =
3025
def osgiImport(pattern: String, version: String): String =
3126
pattern + ";version=\"" + osgiVersionRange(version) + "\""
3227

33-
lazy val core = project.in(file("core")).settings(scalaModuleSettings).settings(scalaModuleOsgiSettings).settings(
28+
lazy val core = project.in(file("core")).settings(scalaModuleSettings).settings(
3429
name := "scala-parallel-collections",
3530
OsgiKeys.exportPackage := Seq(
3631
s"scala.collection.parallel.*;version=${version.value}",

project/build.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
sbt.version=0.13.13
1+
sbt.version=0.13.15

project/plugins.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
addSbtPlugin("org.scala-lang.modules" % "scala-module-plugin" % "1.0.4")
1+
addSbtPlugin("org.scala-lang.modules" % "scala-module-plugin" % "1.0.7")
22
addSbtPlugin("de.heikoseeberger" % "sbt-header" % "1.8.0")

0 commit comments

Comments
 (0)