Skip to content

Commit 675831f

Browse files
authored
Merge pull request #108 from lrytz/simplerRelease
Simplify tag-driven releases, no longer use `scalaVersionsByJvm`
2 parents 7256ed1 + 4803962 commit 675831f

File tree

6 files changed

+58
-63
lines changed

6 files changed

+58
-63
lines changed

.travis.yml

+13-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
language: scala
2+
23
sudo: false
4+
5+
jdk:
6+
- oraclejdk8
7+
8+
scala:
9+
# no 2.13 for now in cross-build because of
10+
# https://github.com/scala/scala-java8-compat/issues/97
11+
- 2.11.12
12+
- 2.12.6
13+
314
env:
415
global:
516
# PGP_PASSPHRASE
@@ -8,10 +19,10 @@ env:
819
- secure: "lx2qFeFxh9AFmyHR7hH4Qf9flIEx8VgYj6ebzuxp1cc1ZZiXHC1256x0bHFDUH9bhJACOazOrco/+v6MBAriBkWxLBc98FrC6OkVeQMFW2ffWSBuHRclilKsQA/Lsgc81Wg+WV105hOqUNAkTXgroblInNt+KS+DhC/8FVoh9ZY="
920
# SONA_PASS
1021
- secure: "FZC+FZnBNeklA150vW5QDZJ5J7t+DExJrgyXWM46Wh0MobjH8cvydgC3qatItb0rDBV8l7zO1LDwl2KEi92aefw2a8E49z6qVOHgUXiI3SAx7M0UO0FFeKPmTXCLcBlbnGLcUqNjIZfuIEufQvPblKTl8qN4eMmcMn9jsNzJr28="
22+
1123
script:
1224
- admin/build.sh
13-
jdk:
14-
- oraclejdk8
25+
1526
notifications:
1627
email:
1728

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.

admin/build.sh

+20-29
Original file line numberDiff line numberDiff line change
@@ -9,45 +9,36 @@ 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+
RELEASE_COMBO=true
1820

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

2224
if [[ "$TRAVIS_TAG" =~ $tagPat ]]; then
23-
currentJvmVer=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | sed 's/^1\.//' | sed 's/[^0-9].*//')
24-
2525
tagVer=$(echo $TRAVIS_TAG | sed s/#.*// | sed s/^v//)
2626
publishVersion='set every version := "'$tagVer'"'
2727
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
28+
if [ "$RELEASE_COMBO" = "true" ]; then
29+
currentJvmVer=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | sed 's/^1\.//' | sed 's/[^0-9].*//')
30+
echo "Releasing $tagVer with Scala $TRAVIS_SCALA_VERSION on Java version $currentJvmVer."
4131
42-
extraTarget="+publish-signed"
43-
cat admin/gpg.sbt >> project/plugins.sbt
44-
cp admin/publish-settings.sbt .
32+
publishTask="publish-signed"
4533
46-
# Copied from the output of genKeyPair.sh
47-
K=$encrypted_1ce132863fa7_key
48-
IV=$encrypted_1ce132863fa7_iv
34+
cat admin/gpg.sbt >> project/plugins.sbt
35+
cp admin/publish-settings.sbt .
4936
50-
openssl aes-256-cbc -K $K -iv $IV -in admin/secring.asc.enc -out admin/secring.asc -d
37+
# Copied from the output of genKeyPair.sh
38+
K=$encrypted_1ce132863fa7_key
39+
IV=$encrypted_1ce132863fa7_iv
40+
openssl aes-256-cbc -K $K -iv $IV -in admin/secring.asc.enc -out admin/secring.asc -d
41+
fi
5142
fi
5243
53-
sbt "$publishVersion" "$publishScalaVersion" clean update +test +publishLocal $extraTarget
44+
sbt "++$TRAVIS_SCALA_VERSION" "$publishVersion" clean test publishLocal "$publishTask"

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+
))

build.sbt

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
import ScalaModulePlugin._
22

3-
scalaVersionsByJvm in ThisBuild := {
4-
// no 2.13 for now in cross-build because of
5-
// https://github.com/scala/scala-java8-compat/issues/97
6-
val versions = List("2.12.6", "2.11.12").map(_ -> true)
7-
Map(8 -> versions, 9 -> versions, 10 -> versions)
8-
}
3+
// no 2.13 for now in cross-build because of
4+
// https://github.com/scala/scala-java8-compat/issues/97
5+
crossScalaVersions in ThisBuild := List("2.12.6", "2.11.12")
96

107
val disableDocs = sys.props("nodocs") == "true"
118

project/plugins.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
scalacOptions += "-Xfatal-warnings"
22

3-
addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "1.0.13")
3+
addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "1.0.14")

0 commit comments

Comments
 (0)