Skip to content

Commit dfcb00e

Browse files
authored
Merge pull request scala#31 from SethTisue/add-admin-directory
add tag-based publishing infra
2 parents 28fb1b3 + 1a4ea59 commit dfcb00e

11 files changed

+220
-7
lines changed

.travis.yml

+10-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,16 @@ scala:
88
- 2.13.0
99

1010
script:
11-
- sbt ++$TRAVIS_SCALA_VERSION test
11+
- admin/build.sh
12+
13+
env:
14+
global:
15+
# PGP_PASSPHRASE
16+
- secure: "NAYlvLQD1OiF+B8NvN+l1Lh0a2xa9FYFfA7LVHt1FXkri6wM/44oVuLF2H7BQTHczFN4754lAR5nrXrBccX1pa4BFmdNLu/nzZIjzjMxz5rFJRcK3nsycJPPUSY6mh5jBP5mR+hyW1zngQPGqCMmwAPP6pANaAztKh34DMSCcdRWb9Gfz6+IL0whCUywYk6LcXBfpD+H0u2ahGUM5ZTWWqqyTDiYmGIhfkXShUZ7oRYNgxffK3BbC5c3UztOTefHMiSCVgqnqNxmFCaGijtm6P1lxW4ebXrklVdb8/Z2AOrJxjV2+Itytb/8w7ukQvYUaPwBoyJYbN0glicMXoYwXKaJ0Rs7VxLFShUQGzDuQFzn5mcjn6r46Gs7aPYC0WTRW6Tx8aaaie7kV+w1zwIx1FrK4OpGaCKGQc73sEUng9EPcVZCbBNS5MNuF/yCfyYN+tSrC7Ms7KzQUwk1aoabEctEqL/Nax8LwayuBBFGrOQnOI9Rt6IxFAze6tJShkcNrZeOp6P/2eCanipHqH18lV3gNr7mKmJL1kTiBdMHo41S/DumNblOz1n5pVOBBLIOjD2Q55uDHAWUPXLbRa+BMtGrmbY2IHIUQPZNKTvnZ5PzoOezP2nSKANUC0V4pN7gVGOmZ/2iPJ7/itdU1tqlQFGRPJvTAzRtsXbPhynEqqw="
17+
# SONA_USER
18+
- secure: "Uc+tOT5E5FEQwLx4ZXZO1Oum1HAhMbvCWpKpkReqdsyb+xBdMbJkt43o8jvM/2WNVMcijEku87o5yWWa/fRDfqBg4GCuwnj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g76EAEyN26vE2/2/GRlMOlG8Lmu8rXBfIPsK9T/ztfE1CxaTW5EsMSrxO2+O/bvAa6DY0R79KkHf7LDI+azzP2NwYx8anM9WlMTp4EbawI/KGZRilWYtJ3Q3y5EQERsrP71W35dKqiBFMPdspS+lTS9hGtso08n7cR2MwTbRjoXVRcWfJ/I="
1221

1322
before_cache:
1423
- find $HOME/.sbt -name "*.lock" | xargs rm

README.md

+15-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
# Scala Collection Contrib
1+
# scala-collection-contrib
22

3-
This module provides extra features to the Scala standard collections.
3+
This module provides various additions to the Scala 2.13 standard collections.
44

5-
## New Collection Types
5+
## New collection types
66

77
- `MultiSet` (both mutable and immutable)
88
- `SortedMultiSet` (both mutable and immutable)
99
- `MultiDict` (both mutable and immutable)
1010
- `SortedMultiDict` (both mutable and immutable)
1111

12-
## New Operations
12+
## New operations
1313

1414
The new operations are provided via an implicit enrichment. You need to add the following
1515
import to make them available:
@@ -27,3 +27,14 @@ The following operations are provided:
2727
- `zipByKey` / `join` / `zipByKeyWith`
2828
- `mergeByKey` / `fullOuterJoin` / `mergeByKeyWith` / `leftOuterJoin` / `rightOuterJoin`
2929

30+
## Maintenance status
31+
32+
This module is community-maintained. If you are interested in
33+
participating, please jump right in on issues and pull requests.
34+
35+
## Releasing
36+
37+
As with other Scala standard modules, build and release infrastructure
38+
is provided by the
39+
[sbt-scala-module](https://github.com/scala/sbt-scala-module/) sbt
40+
plugin.

admin/README.md

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
## Tag Driven Releasing
2+
3+
### Initial setup for the repository
4+
5+
To configure tag driven releases from Travis CI.
6+
7+
1. Generate a key pair for this repository with `./admin/genKeyPair.sh`.
8+
Edit `.travis.yml` and `admin/build.sh` as prompted.
9+
1. Publish the public key to https://pgp.mit.edu
10+
1. Store other secrets as encrypted environment variables with `./admin/encryptEnvVars.sh`.
11+
Edit `.travis.yml` as prompted.
12+
1. Edit `.travis.yml` to use `./admin/build.sh` as the build script,
13+
and edit that script to use the tasks required for this project.
14+
Ensure that `RELEASE_COMBO` is `true` for build matrix combinations
15+
that should be released to sonatype (when building a tag).
16+
17+
It is important to add comments in `.travis.yml` to identify the name
18+
of each environment variable encoded in a `secure` section.
19+
20+
After these steps, your `.travis.yml` should contain config of the form:
21+
22+
```
23+
language: scala
24+
25+
jdk:
26+
- openjdk8
27+
28+
scala:
29+
- 2.11.12
30+
- 2.12.6
31+
32+
env:
33+
global:
34+
# PGP_PASSPHRASE
35+
- secure: "XXXXXX"
36+
# SONA_USER
37+
- secure: "XXXXXX"
38+
# SONA_PASS
39+
- secure: "XXXXXX"
40+
41+
script: admin/build.sh
42+
43+
notifications:
44+
email:
45+
46+
```
47+
48+
If Sonatype credentials change in the future, step 3 can be repeated
49+
without generating a new key.
50+
51+
### Testing
52+
53+
1. Follow the release process below to create a dummy release (e.g., `v0.1.0-TEST1`).
54+
Confirm that the release was staged to Sonatype but do not release it to Maven
55+
central. Instead, drop the staging repository.
56+
57+
### Performing a release
58+
59+
1. Create a GitHub "Release" with a corresponding tag (e.g., `v0.1.1`) via the GitHub
60+
web interface.
61+
1. The release will be published using the Scala and JVM version combinations specified
62+
in the travis build matrix where `[ "$RELEASE_COMBO" = "true" ]`.
63+
- If you need to release against a different Scala version, create a new commit that modifies
64+
`.travis.yml` and push a new tag, e.g., `v1.2.3#2.13.0-M5`. The suffix after `#` is ignored.
65+
1. Travis CI will schedule a build for this release. Review the build logs.
66+
1. Log into https://oss.sonatype.org/ and identify the staging repository.
67+
1. Sanity check its contents.
68+
1. Release staging repository to Maven and send out release announcement.

admin/build.sh

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Builds of tagged revisions are published to sonatype staging.
6+
7+
# Travis runs a build on revisions, including on new tags.
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 on all combinations of the travis matrix where `[ "$RELEASE_COMBO" = "true" ]`.
13+
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" == "openjdk8" ]]; then
20+
RELEASE_COMBO=true;
21+
fi
22+
23+
verPat="[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9-]+)?"
24+
tagPat="^v$verPat(#.*)?$"
25+
26+
if [[ "$TRAVIS_TAG" =~ $tagPat ]]; then
27+
tagVer=${TRAVIS_TAG}
28+
tagVer=${tagVer#v} # Remove `v` at beginning.
29+
tagVer=${tagVer%%#*} # Remove anything after `#`.
30+
publishVersion='set every version := "'$tagVer'"'
31+
32+
if [ "$RELEASE_COMBO" = "true" ]; then
33+
currentJvmVer=$(java -version 2>&1 | awk -F '"' '/version/ {print $2}' | sed 's/^1\.//' | sed 's/[^0-9].*//')
34+
echo "Releasing $tagVer with Scala $TRAVIS_SCALA_VERSION on Java version $currentJvmVer."
35+
36+
publishTask="publishSigned"
37+
38+
cat admin/gpg.sbt >> project/plugins.sbt
39+
cp admin/publish-settings.sbt .
40+
41+
# Copied from the output of genKeyPair.sh
42+
K=$encrypted_6b8d67feaab7_key
43+
IV=$encrypted_6b8d67feaab7_iv
44+
openssl aes-256-cbc -K $K -iv $IV -in admin/secring.asc.enc -out admin/secring.asc -d
45+
fi
46+
fi
47+
48+
sbt "++$TRAVIS_SCALA_VERSION" "$publishVersion" "clean" "test" "publishLocal" "$publishTask"

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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2-1") // only added when publishing, see build.sh

admin/publish-settings.sbt

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

admin/pubring.asc

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
-----BEGIN PGP PUBLIC KEY BLOCK-----
2+
Version: BCPG v1.51
3+
4+
mQENBF0w4ZMBCACLX2RqR9L5J9wti2G8Hgi0XktuUtaHighmKT31tQgQf4RleHsR
5+
kd+cVKaop623+LTf+8HHBquB2ZbIGg0gnyFUluPJEIanSYAJbM373snvwkUzU28x
6+
g0KTHWg3HaX+2Yg2TemL2EW6TQYdOpHk7jkxUMxOAIAd+YalEZpGCgEEiKqTTNIt
7+
24sqZHyS8n6rT+RD+PcyQBqRG6eoPRQdjUzNaFcD+SEilpqVlG3I3qAdsdPMI7bi
8+
O2jWVKE38NMemiPweGdAgZrya4a7srg9x5lujlqN3LtzBhwZLolymGYLEQfE2v1v
9+
4Mr4fO2roFpSVkZQSdeqVqfjDHMaz0mY6tUFABEBAAG0O3NjYWxhLWNvbGxlY3Rp
10+
b24tY29udHJpYiA8c2NhbGEtaW50ZXJuYWxzQGdvb2dsZWdyb3Vwcy5jb20+iQEc
11+
BBMBAgAGBQJdMOGTAAoJEJUcb0POSwjJw+sH/AvkB05NR3ojI8880WIceWeFPPHF
12+
ISK9l5KNchBB0+3OwB9w6X2J75MV7F/stNfgYe+meQlxveHNi/z4ULKxhFVMj7JK
13+
ldr2H5rvtxNyLgSL8ljBGPAcHml81SML8J0qNoRPXPkmbnXPdZZ7NPqMGUIbZtCX
14+
40HD5LAjv+q2Q4OERtQpjN9qK0c2pWi2W3JzfUh55adPAoPXSVBIfxImLSdPGKBc
15+
Dj8ugFAqxivUvCQhwa91RkFLL+PefRDvSalPofRXY6P0Vn+gQZm4wgGerp05uEnk
16+
v5ZEO2WrXxffwMsZog6CCFuNgmjJrMkhaAF4/JO/7mlrmpkf6tpXxF+MabA=
17+
=tc/r
18+
-----END PGP PUBLIC KEY BLOCK-----

admin/secring.asc.enc

1.84 KB
Binary file not shown.

project/plugins.sbt

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
scalacOptions ++= Seq("-deprecation", "-feature", "-Xfatal-warnings")
22

3-
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3")
4-
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2")
53
addSbtPlugin("org.scala-lang.modules" % "sbt-scala-module" % "2.0.0")

0 commit comments

Comments
 (0)