Skip to content

tag-driven publishing v2, corss-build with 2.10, 2.11 and 2.12 #45

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 3 commits into from
May 12, 2015
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
28 changes: 12 additions & 16 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,17 @@ language: scala

env:
global:
- PUBLISH_JDK=openjdk6 # admin/build.sh only publishes when running on this jdk
# Don't commit sensitive files, instead commit a version encrypted with $SECRET,
# this environment variable is encrypted with this repo's private key and stored below:
# (See http://docs.travis-ci.com/user/environment-variables/#Secure-Variables.)
- secure: "g/d6gjq6g+t5ieI6DwOiL5k8XJ/ethlZ1ZZDA/uvOsCfkIu0MBL2cYGmwQ0gcBNBQ/02wZjXnTIgMhFhYLcgHtnicAjy+53fhjCYcTM6A61DCPhJ6txOjEEPrpnlqbvKauw0WuVGT8Kd52bhaMXPCE2GOWgPe+bJfDUTHSm86dw="
- PUBLISH_JDK=openjdk6
# PGP_PASSPHRASE
- secure: "bTGw0loJcnmzNuJG3bjGLs7tfnrWlLb3oi6nBeYUS+coRhKzK4jMN6luuh89gVwIcbFK2nZUkm1s59UZzQA0SMBsdL/Js9Zi6jiUj4NBIVEOzgQxp/vlScF/kF7HxxBji6Gxp/TpqW2MOFxCtWWGBoktuAsufFEhJ47m/cVUZBY="
# SONA_USER
- secure: "uJEIIJGX+xviY5prNor9WW8JuV4MdQbNvGe6nO4Cwumv8LEXALlpONZrmF5BvEB7HrmB/VUqwDO9utrhN7VPaFhCTnoHuslbSdhdB9Yg/lwD+0FpszvKjjraoWeQqqJuXoml9kmH4kQBIP4RxPTnzocPHRIfVyEOYRnMtydImBA="
# SONA_PASS
- secure: "SlbOg79Jzzg7QQeVDu8Q+zZM/GRLFZxPjud9DsLCu4tkTVXWHcYn6FaXuOvVsLkgeALT2pM5j6Zcpp6WqyGRJiSkVqVGqM3jXWov+esgSmhu9pIMvVtxmvfiHBXofiKNYax3XCX+hTwCVuh2pEZ5Thy8i+fXVElCCqzcgTnp+DQ="

script:
- admin/build.sh
scala:
- 2.11.0
jdk:
- openjdk6
notifications:
email:
- adriaan.moors@typesafe.com
script: admin/build.sh

jdk: openjdk6

# if we get weird timeouts, see https://github.com/spray/spray/pull/233
# 'set concurrentRestrictions in Global += Tags.limit(Tags.Test, 1)'
notifications:
email: adriaan.moors@typesafe.com
61 changes: 61 additions & 0 deletions admin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
## Tag Driven Releasing

Copied from https://github.com/scala/scala-java8-compat/commit/4a6cfc97cd95227b86650410e1b632e5ff79335b.

### Background Reading

- http://docs.travis-ci.com/user/environment-variables/
- http://docs.travis-ci.com/user/encryption-keys/
- http://docs.travis-ci.com/user/encrypting-files/

### Initial setup for the repository

To configure tag driven releases from Travis CI.

1. Generate a key pair for this repository with `./admin/genKeyPair.sh`.
Edit `.travis.yml` and `admin/build.sh` as prompted.
2. Publish the public key to https://pgp.mit.edu
3. Store other secrets as encrypted environment variables with `admin/encryptEnvVars.sh`.
Edit `.travis.yml` as prompted.
4. Edit `.travis.yml` to use `./admin/build.sh` as the build script,
and edit that script to use the tasks required for this project.
5. Edit `.travis.yml` to select which JDK will be used for publishing.

It is important to add comments in .travis.yml to identify the name
of each environment variable encoded in a `:secure` section.

After all of these steps, your .travis.yml should contain config of the
form:

language: scala
env:
global:
- PUBLISH_JDK=openjdk6
# PGP_PASSPHRASE
- secure: "XXXXXX"
# SONA_USER
- secure: "XXXXXX"
# SONA_PASS
- secure: "XXXXXX"
script: admin/build.sh

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

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

### Testing

1. Follow the release process below to create a dummy release (e.g. 0.1.0-TEST1).
Confirm that the release was staged to Sonatype but do not release it to Maven
central. Instead, drop the staging repository.

### Performing a release

1. Create a GitHub "Release" (with a corresponding tag) via the GitHub
web interface.
2. Travis CI will schedule a build for this release. Review the build logs.
3. Log into https://oss.sonatype.org/ and identify the staging repository.
4. Sanity check its contents
5. Release staging repository to Maven and send out release announcement.

16 changes: 11 additions & 5 deletions admin/build.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/bash

set -e

# prep environment for publish to sonatype staging if the HEAD commit is tagged

# git on travis does not fetch tags, but we have TRAVIS_TAG
Expand All @@ -9,11 +11,15 @@ if [ "$TRAVIS_JDK_VERSION" == "$PUBLISH_JDK" ] && [[ "$TRAVIS_TAG" =~ ^v[0-9]+\.
echo "Going to release from tag $TRAVIS_TAG!"
myVer=$(echo $TRAVIS_TAG | sed -e s/^v//)
publishVersion='set every version := "'$myVer'"'
extraTarget="publish-signed"

extraTarget="+publish-signed"
cat admin/gpg.sbt >> project/plugins.sbt
admin/decrypt.sh sensitive.sbt
(cd admin/ && ./decrypt.sh secring.asc)
cp admin/publish-settings.sbt .

# Copied from the output of genKeyPair.sh
K=$encrypted_e923b9d88d53_key
IV=$encrypted_e923b9d88d53_iv

openssl aes-256-cbc -K $K -iv $IV -in admin/secring.asc.enc -out admin/secring.asc -d
fi

sbt ++$TRAVIS_SCALA_VERSION "$publishVersion" clean update compile test $extraTarget
sbt "$publishVersion" clean update +test +publishLocal $extraTarget
2 changes: 0 additions & 2 deletions admin/decrypt.sh

This file was deleted.

2 changes: 0 additions & 2 deletions admin/encrypt.sh

This file was deleted.

19 changes: 0 additions & 19 deletions admin/encryptAll.sh

This file was deleted.

11 changes: 11 additions & 0 deletions admin/encryptEnvVars.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
#
# Encrypt sonatype credentials so that they can be
# decrypted in trusted builds on Travis CI.
#
set -e

read -s -p 'SONA_USER: ' SONA_USER
travis encrypt SONA_USER="$SONA_USER"
read -s -p 'SONA_PASS: ' SONA_PASS
travis encrypt SONA_PASS="$SONA_PASS"
41 changes: 41 additions & 0 deletions admin/genKeyPair.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
#
# Generates a key pair for this repository to sign artifacts.
# Encrypt the private key and its passphrase in trusted builds
# on Travis CI.
#
set -e

# Based on https://gist.github.com/kzap/5819745:
function promptDelete() {
if [[ -f "$1" ]]; then
echo About to delete $1, Enter for okay / CTRL-C to cancel
read
rm "$1"
fi
}
for f in admin/secring.asc.enc admin/secring.asc admin/pubring.asc; do promptDelete "$f"; done

echo Generating key pair. Please enter 1. repo name 2. scala-internals@googlegroups.com, 3. a new passphrase
echo Be careful when using special characters in the passphrase, see http://docs.travis-ci.com/user/encryption-keys/#Note-on-escaping-certain-symbols
cp admin/gpg.sbt project
sbt 'set pgpReadOnly := false' \
'set pgpPublicRing := file("admin/pubring.asc")' \
'set pgpSecretRing := file("admin/secring.asc")' \
'pgp-cmd gen-key'
rm project/gpg.sbt

echo ============================================================================================
echo Encrypting admin/secring.asc. Update K and IV variables in admin/build.sh accordingly.
echo ============================================================================================
travis encrypt-file admin/secring.asc
rm admin/secring.asc
mv secring.asc.enc admin

echo ============================================================================================
echo Encrypting environment variables. Add each to a line in .travis.yml. Include a comment
echo with the name of the corresponding variable
echo ============================================================================================
read -s -p 'PGP_PASSPHRASE: ' PGP_PASSPHRASE
travis encrypt PGP_PASSPHRASE="$PGP_PASSPHRASE"

26 changes: 1 addition & 25 deletions admin/gpg.sbt
Original file line number Diff line number Diff line change
@@ -1,26 +1,2 @@

addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.3") // only added when publishing:

// There's a companion sensitive.sbt, which was created like this:
//
// 1. in an sbt shell that has the sbt-pgp plugin, create pgp key in admin/:
//
// sbt
// set pgpReadOnly := false
// set pgpPublicRing := file("admin/pubring.asc")
// set pgpSecretRing := file("admin/secring.asc")
// pgp-cmd gen-key // use $passPhrase
// Please enter the name associated with the key: $repoName
// Please enter the email associated with the key: scala-internals@googlegroups.com
// Please enter the passphrase for the key: $passphrase
//
// 2. create sensitive.sbt with contents:
//
// pgpPassphrase := Some($passPhrase.toArray)
//
// pgpPublicRing := file("admin/pubring.asc")
//
// pgpSecretRing := file("admin/secring.asc")
//
// credentials += Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", $sonaUser, $sonaPass)

addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.3") // only added when publishing, see build.sh
9 changes: 9 additions & 0 deletions admin/publish-settings.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def env(key: String) = Option(System.getenv(key)).getOrElse("")

pgpPassphrase := Some(env("PGP_PASSPHRASE").toArray)

pgpPublicRing := file("admin/pubring.asc")

pgpSecretRing := file("admin/secring.asc")

credentials += Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", env("SONA_USER"), env("SONA_PASS"))
28 changes: 14 additions & 14 deletions admin/pubring.asc
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: BCPG v1.49

mQENBFSA12QBCACmD7LIMlzS+Qf/dyyQQn2wjgrk9kCazfVP6pb++wizYq4AkN6Q
cFti0YCSB+EzS+dqFO4wSIprenB/jfuLEnjfDSupjFLgTmjo8Komkk/9ynHSowJl
ofkDPS/qgcr1mAmuc72CrIqKfc3Dojscug3ChmY3tbezAgPmGV/tu8V/uAAsnVOE
AsmCOimTcWjA6bgvEkPyyzHp5uinU29tuFAxIAm2pJ+EmNebRnVF3lG+GotP2Ojy
wsfS8iMmV2g4KQd4WmFes9F2R/lkApGgnDTimk9Rj/QswhPuVeiHPS1OBjWPqoEw
N9lL1lyiOYoX+MHryTlJE7lZqDHwhUAiQxatABEBAAG0LnNjYWxhLXN3aW5nIDxz
Y2FsYS1pbnRlcm5hbHNAZ29vZ2xlZ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flvreJG4qaYD1rmpks6NmCiL84x2kFraAuSnl0YCYfi7GIUWrUtjl
PDk9Cex1o5r8NN1vijRcDpU4jD4NyF7G5/G1Qr9IB9ZZFJQbk1JLsI6v//70xI6Q
C/mumWgyhJJHATA9OXTDfuT1Od0eN2E10Ez8u0mYvQ==
=D3ls
-----END PGP PUBLIC KEY BLOCK-----
Binary file modified admin/secring.asc.enc
Binary file not shown.
4 changes: 3 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ name := "scala-swing"

version := "1.0.3-SNAPSHOT"

scalaVersion := "2.11.6"
scalaVersion := crossScalaVersions.value.head

crossScalaVersions := Seq("2.11.6", "2.12.0-M1", "2.10.5")

// important!! must come here (why?)
scalaModuleOsgiSettings
Expand Down
7 changes: 0 additions & 7 deletions sensitive.sbt.enc

This file was deleted.