Skip to content
This repository was archived by the owner on Jun 23, 2020. It is now read-only.

Commit 6c79e8c

Browse files
authored
Merge pull request #33 from lrytz/publishing-cleanups
Updates to travis publishing
2 parents 32588c0 + 189e91d commit 6c79e8c

16 files changed

+197
-108
lines changed

.travis.yml

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@ language: scala
22

33
env:
44
global:
5-
# Don't commit sensitive files, instead commit a version encrypted with $SECRET,
6-
# this environment variable is encrypted with this repo's private key and stored below:
7-
# (See http://docs.travis-ci.com/user/environment-variables/#Secure-Variables.)
8-
- secure: "apmuVagS7WgWzg9HeDLCcX4INxazi50qukOfPkvluJjm58RCJsDwaZseXrQGqyPzRKuBnAetJ4NDWbZMRkm6QpTiH8grPwDl6iNUSVivvzOZGl3Iy8LvNxUv6CYoQBG+R7d8dW//1xcoHtT2zYo3dYEFpSelfNMMLADNUKXSQmI="
5+
# PGP_PASSPHRASE
6+
- secure: "ImY9KGs8EmTk1mPgZJEWqfy0GR7Wp2lZ07z1eSVwMQTGvYZIPZchNa30jzjB4YVHrG5PvwOSXaGx3ivFRZk/FElWbJ1skFXfHz+JwvNRvN6fhNIhoD0mkPWDTDtA3NnlLen4hbC9rZCPuP4RqrS1jy2nZuD36ZLx2NU9tQM6tUc="
7+
# SONA_USER
8+
- secure: "f0Acd/hWkgHoT5uyFL+K3D8DB2bRSoXRJhnTueMzJvTHBJZd2kpPo9t7YsmH7fowopVMCcBPzfRyiPoJVf4CJKc/SHCKn/YMJInCC1YPOrchLX/ShTPTeaP4lxFnm/bmmdPOmqfLSQsPIuEP6LBffsq1lvLO6VL61QrDy+D4EQs="
9+
# SONA_PASS
10+
- secure: "E6OE1MoZ4VQHRNtEyyKfmnj8Bj7uGpgHLmlvJR/iy7qdxBbNA8cEz/Qs64uTft5zfZ9bJsQhiuxLcTtFKYKFP4qvExz8FyilhmUwKjD5Eux4FAeBjDBeXBETM1JYFB+JYP9l8dcQecMeGpd46I52pLjYYmNyQQ1YpOvK29GIQLA="
911

1012
before_install:
1113
- sudo hostname "$(hostname | cut -c1-63)"

admin/README.md

+72
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
## Tag Driven Releasing
2+
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+
9+
### Initial setup for the repository
10+
11+
To configure tag driven releases from Travis CI.
12+
13+
1. Generate a key pair for this repository with `./admin/genKeyPair.sh`.
14+
Edit `.travis.yml` and `admin/build.sh` as prompted.
15+
1. Publish the public key to https://pgp.mit.edu
16+
1. Store other secrets as encrypted environment variables with `admin/encryptEnvVars.sh`.
17+
Edit `.travis.yml` as prompted.
18+
1. Edit `.travis.yml` to use `./admin/build.sh` as the build script,
19+
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.
22+
23+
It is important to add comments in `.travis.yml` to identify the name
24+
of each environment variable encoded in a `:secure` section.
25+
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+
```
50+
51+
If Sonatype credentials change in the future, step 3 can be repeated
52+
without generating a new key.
53+
54+
### Testing
55+
56+
1. Follow the release process below to create a dummy release (e.g., `v0.1.0-TEST1`).
57+
Confirm that the release was staged to Sonatype but do not release it to Maven
58+
central. Instead, drop the staging repository.
59+
60+
### Performing a release
61+
62+
1. Create a GitHub "Release" with a corresponding tag (e.g., `v0.1.1`) via the GitHub
63+
web interface.
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

+27-20
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,42 @@ set -e
1212
# version 1.2.3 using all Scala versions in build.sbt's `crossScalaVersions`.
1313

1414
# 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 version
16-
# after a hash, e.g., v1.2.3#2.13.0-M1.
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.
1718

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

21-
scalaVer=$(echo $TRAVIS_TAG | sed s/[^#]*// | sed s/^#//)
22-
if [[ $scalaVer == "2.11"* ]]; then
23-
publishJdk="openjdk6"
24-
else
25-
publishJdk="oraclejdk8"
26-
fi
27-
28-
if [ "$TRAVIS_JDK_VERSION" == "$publishJdk" ] && [[ "$TRAVIS_TAG" =~ $tagPat ]]; then
29-
30-
echo "Going to release from tag $TRAVIS_TAG!"
22+
if [[ "$TRAVIS_TAG" =~ $tagPat ]]; then
23+
currentJvmVer=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | sed 's/^1\.//' | sed 's/[^0-9].*//')
3124

3225
tagVer=$(echo $TRAVIS_TAG | sed s/#.*// | sed s/^v//)
3326
publishVersion='set every version := "'$tagVer'"'
3427
35-
if [ "$scalaVer" != "" ]; then
36-
publishScalaVersion='set every crossScalaVersions := Seq("'$scalaVer'")'
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."
3740
fi
38-
39-
extraTarget="+publish-signed"
4041
42+
extraTarget="+publish-signed"
4143
cat admin/gpg.sbt >> project/plugins.sbt
42-
admin/decrypt.sh sensitive.sbt
43-
(cd admin/ && ./decrypt.sh secring.asc)
44+
cp admin/publish-settings.sbt .
45+
46+
# Copied from the output of genKeyPair.sh
47+
K=$encrypted_566e85990f00_key
48+
IV=$encrypted_566e85990f00_iv
49+
50+
openssl aes-256-cbc -K $K -iv $IV -in admin/secring.asc.enc -out admin/secring.asc -d
4451
fi
4552
46-
sbt "$publishVersion" "$publishScalaVersion" clean update +test +publishLocal $extraTarget
53+
sbt "$publishVersion" "$publishScalaVersion" clean update +test +publishLocal $extraTarget

admin/decrypt.sh

-2
This file was deleted.

admin/encrypt.sh

-2
This file was deleted.

admin/encryptAll.sh

-19
This file was deleted.

admin/encryptEnvVars.sh

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/bin/bash
2+
#
3+
# Encrypt sonatype credentials so that they can be
4+
# decrypted in trusted builds on Travis CI.
5+
#
6+
set -e
7+
8+
read -s -p 'SONA_USER: ' SONA_USER
9+
travis encrypt SONA_USER="$SONA_USER"
10+
read -s -p 'SONA_PASS: ' SONA_PASS
11+
travis encrypt SONA_PASS="$SONA_PASS"

admin/genKeyPair.sh

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/bin/bash
2+
#
3+
# Generates a key pair for this repository to sign artifacts.
4+
# Encrypt the private key and its passphrase in trusted builds
5+
# on Travis CI.
6+
#
7+
set -e
8+
9+
# Based on https://gist.github.com/kzap/5819745:
10+
function promptDelete() {
11+
if [[ -f "$1" ]]; then
12+
echo About to delete $1, Enter for okay / CTRL-C to cancel
13+
read
14+
rm "$1"
15+
fi
16+
}
17+
for f in admin/secring.asc.enc admin/secring.asc admin/pubring.asc; do promptDelete "$f"; done
18+
19+
echo Generating key pair. Please enter 1. repo name 2. [email protected], 3. a new passphrase
20+
echo Be careful when using special characters in the passphrase, see http://docs.travis-ci.com/user/encryption-keys/#Note-on-escaping-certain-symbols
21+
cp admin/gpg.sbt project
22+
sbt 'set pgpReadOnly := false' \
23+
'set pgpPublicRing := file("admin/pubring.asc")' \
24+
'set pgpSecretRing := file("admin/secring.asc")' \
25+
'pgp-cmd gen-key'
26+
rm project/gpg.sbt
27+
28+
echo ============================================================================================
29+
echo Encrypting admin/secring.asc. Update K and IV variables in admin/build.sh accordingly.
30+
echo ============================================================================================
31+
travis encrypt-file admin/secring.asc
32+
rm admin/secring.asc
33+
mv secring.asc.enc admin
34+
35+
echo ============================================================================================
36+
echo Encrypting environment variables. Add each to a line in .travis.yml. Include a comment
37+
echo with the name of the corresponding variable
38+
echo ============================================================================================
39+
read -s -p 'PGP_PASSPHRASE: ' PGP_PASSPHRASE
40+
travis encrypt PGP_PASSPHRASE="$PGP_PASSPHRASE"
41+

admin/gpg.sbt

+1-25
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,2 @@
11

2-
addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.3") // only added when publishing:
3-
4-
// There's a companion sensitive.sbt, which was created like this:
5-
//
6-
// 1. in an sbt shell that has the sbt-pgp plugin, create pgp key in admin/:
7-
//
8-
// sbt
9-
// set pgpReadOnly := false
10-
// set pgpPublicRing := file("admin/pubring.asc")
11-
// set pgpSecretRing := file("admin/secring.asc")
12-
// pgp-cmd gen-key // use $passPhrase
13-
// Please enter the name associated with the key: $repoName
14-
// Please enter the email associated with the key: [email protected]
15-
// Please enter the passphrase for the key: $passphrase
16-
//
17-
// 2. create sensitive.sbt with contents:
18-
//
19-
// pgpPassphrase := Some($passPhrase.toArray)
20-
//
21-
// pgpPublicRing := file("admin/pubring.asc")
22-
//
23-
// pgpSecretRing := file("admin/secring.asc")
24-
//
25-
// credentials += Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", $sonaUser, $sonaPass)
26-
2+
addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.3") // only added when publishing, see build.sh

admin/publish-settings.sbt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def env(key: String) = Option(System.getenv(key)).getOrElse("")
2+
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"))

admin/pubring.asc

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
-----BEGIN PGP PUBLIC KEY BLOCK-----
22
Version: BCPG v1.49
33

4-
mQENBFSA7OUBCACJr0pqlTj37dACmNdB6i4IzxkJZCj+MdIfxHI0DxIEtFadpSd3
5-
qQgR42jv6AuxuSAEDJgFooRmMyBuNScjYTn/CCE68VVpsE8eVHOOytPJmRR0fmNu
6-
6tDaH/rrYTOGOrPDs9OflkgX9Z53u+dymDCQulP08+VLJxxrzDeYNRtQucrWhMjh
7-
xe6/9riLaUBEzsJXQRmLlUdumdySTjE8y7nJZK79EerzrLaIs0IjRukPRmbICaT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i1J+MRlO/ahnKvNyC
12+
oOY7Whj1oh17SxzHPKv/FOBh/QzUC36ADfhPQdn6NFlC0B589KfB5ICXeRLD5Rtb
13+
q+Cn284mtih40IgmLqMlHGNB5KaZmESN0mFVHn4PcieXunc1AWvtqaI8xxQdKNIW
14+
qucRS6bOfJrvgghDHMkIJfE0st7okRhSHjHPxwLHQ6+Osf7bXG3bSoakafgiqK3I
15+
1u3JXJuTQhxhVSQy8hQZ4nFtyrzwQB998rXUKwRCsJJSfYj79Eu261Q3MlA73pDA
16+
Sp8Vgh7hIzvg9LpxXXeUVO1j/FgZ1mqWWW5w/tBABMExc9iXBK92
17+
=v5XR
1818
-----END PGP PUBLIC KEY BLOCK-----

admin/secring.asc.enc

-688 Bytes
Binary file not shown.

build.sbt

+13-12
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
import Keys.{ `package` => packageTask }
2+
import ScalaModulePlugin._
23

34
// plugin logic of build based on https://github.com/retronym/boxer
45

6+
scalaVersionsByJvm in ThisBuild := {
7+
val j67 = List("2.11.8", "2.11.11")
8+
val j89 = List("2.12.0", "2.12.1", "2.12.2", "2.13.0-M1")
9+
// Map[JvmVersion, List[(ScalaVersion, UseForPublishing)]]
10+
Map(
11+
6 -> j67.map(_ -> true),
12+
7 -> j67.map(_ -> false),
13+
8 -> j89.map(_ -> true),
14+
9 -> j89.map(_ -> false)
15+
)
16+
}
17+
518
lazy val commonSettings = scalaModuleSettings ++ Seq(
619
repoName := "scala-continuations",
720
organization := "org.scala-lang.plugins",
821
version := "1.0.3-SNAPSHOT",
922

10-
scalaVersionsByJvm := {
11-
val j67 = List("2.11.8", "2.11.11")
12-
val j89 = List("2.12.0", "2.12.1", "2.12.2", "2.13.0-M1")
13-
// Map[JvmVersion, List[(ScalaVersion, UseForPublishing)]]
14-
Map(
15-
6 -> j67.map(_ -> true),
16-
7 -> j67.map(_ -> false),
17-
8 -> j89.map(_ -> true),
18-
9 -> j89.map(_ -> false)
19-
)
20-
},
21-
2223
scalacOptions ++= Seq(
2324
"-deprecation",
2425
"-feature")

plugin/src/main/scala/scala/tools/selectivecps/CPSUtils.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ trait CPSUtils {
1313
def vprintln(x: =>Any): Unit = if (verbose) println(x)
1414

1515
object cpsNames {
16-
val catches = newTermName("$catches")
17-
val ex = newTermName("$ex")
16+
val catches = newTermName(s"$$catches")
17+
val ex = newTermName(s"$$ex")
1818
val flatMapCatch = newTermName("flatMapCatch")
1919
val getTrivialValue = newTermName("getTrivialValue")
2020
val isTrivial = newTermName("isTrivial")
2121
val reify = newTermName("reify")
2222
val reifyR = newTermName("reifyR")
2323
val shift = newTermName("shift")
2424
val shiftR = newTermName("shiftR")
25-
val shiftSuffix = newTermName("$shift")
25+
val shiftSuffix = newTermName(s"$$shift")
2626
val shiftUnit0 = newTermName("shiftUnit0")
2727
val shiftUnit = newTermName("shiftUnit")
2828
val shiftUnitR = newTermName("shiftUnitR")

project/plugins.sbt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
addSbtPlugin("org.scala-lang.modules" % "scala-module-plugin" % "1.0.6")
1+
addSbtPlugin("org.scala-lang.modules" % "scala-module-plugin" % "1.0.8")

sensitive.sbt.enc

-7
This file was deleted.

0 commit comments

Comments
 (0)