Skip to content
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

Add automated releases to Sonatype Nexus through CI #98

Merged
merged 12 commits into from
May 22, 2019
68 changes: 58 additions & 10 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
aliases:
- &restore_sbt_cache
key: sbt-{{ checksum "/tmp/scala_version" }}-cache
key: sbt-cache-{{ checksum "/tmp/scala_version" }}

- &save_sbt_cache
key: sbt-{{ checksum "/tmp/scala_version" }}-cache-{{ epoch }}
key: sbt-cache-{{ checksum "/tmp/scala_version" }}-{{ epoch }}
paths:
- "~/.ivy2/cache"
- "~/.sbt"
Expand All @@ -18,25 +18,73 @@ aliases:
command: ./scripts/cibuild
- save_cache: *save_sbt_cache

- &run_cipublish
- checkout
- run: echo "${SCALA_VERSION}" > /tmp/scala_version
- restore_cache: *restore_sbt_cache
- run:
name: "Import signing key"
hectcastro marked this conversation as resolved.
Show resolved Hide resolved
command: |
echo "${GPG_KEY}" | base64 -d > signing_key.asc && \
hectcastro marked this conversation as resolved.
Show resolved Hide resolved
gpg --batch \
--passphrase "${GPG_PASSPHRASE}" \
--import signing_key.asc
- run:
name: Executing cipublish
command: ./scripts/cipublish

# Build environments
- &openjdk8-scala2_11_12-nodelts_environment
docker:
- image: circleci/openjdk:8-stretch-node
environment:
SCALA_VERSION: 2.11.12

- &openjdk8-scala2_12_8-nodelts_environment
docker:
- image: circleci/openjdk:8-stretch-node
environment:
SCALA_VERSION: 2.12.8

version: 2
workflows:
version: 2
build:
jobs:
- "openjdk8-scala2.11.12-nodelts"
- "openjdk8-scala2.12.8-nodelts"
- "openjdk8-scala2.11.12-nodelts_deploy":
requires:
- "openjdk8-scala2.11.12-nodelts"
filters:
branches:
only:
- develop
- master
hectcastro marked this conversation as resolved.
Show resolved Hide resolved
- feature/jrb/automated-releases-to-sonatype
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder to remove before merging.

- "openjdk8-scala2.12.8-nodelts_deploy":
requires:
- "openjdk8-scala2.12.8-nodelts"
filters:
branches:
only:
- develop
- master
- feature/jrb/automated-releases-to-sonatype

jobs:
"openjdk8-scala2.11.12-nodelts":
docker:
- image: circleci/openjdk:8-stretch-node
environment:
SCALA_VERSION: 2.11.12
<<: *openjdk8-scala2_11_12-nodelts_environment
steps: *run_cibuild

"openjdk8-scala2.12.8-nodelts":
docker:
- image: circleci/openjdk:8-stretch-node
environment:
SCALA_VERSION: 2.12.8
<<: *openjdk8-scala2_12_8-nodelts_environment
steps: *run_cibuild

"openjdk8-scala2.11.12-nodelts_deploy":
<<: *openjdk8-scala2_11_12-nodelts_environment
steps: *run_cipublish

"openjdk8-scala2.12.8-nodelts_deploy":
<<: *openjdk8-scala2_12_8-nodelts_environment
steps: *run_cipublish
31 changes: 31 additions & 0 deletions .github/ISSUE_TEMPLATE/release.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
---
hectcastro marked this conversation as resolved.
Show resolved Hide resolved
name: Release
about: When ready to cut a release
title: Release X.Y.Z
labels: release
assignees: ''

---

- [ ] Start a new release branch:
```bash
$ git flow release start X.Y.Z
```
- [ ] Rotate `CHANGELOG.md` (following [Keep a Changelog](https://keepachangelog.com/) principles)
- [ ] Ensure outstanding changes are committed:
```bash
$ git status # Is the git staging area clean?
$ git add CHANGELOG.md
$ git commit -m "X.Y.Z"
```
- [ ] Publish the release branch:
```bash
$ git flow release publish X.Y.Z
```
- [ ] Ensure that CI checks pass
- [ ] Finish and publish the release branch:
- When prompted, keep default commit messages
- Use `X.Y.Z` as the tag message
```bash
$ git flow release finish -p X.Y.Z
```
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Add README [#92](https://github.com/geotrellis/maml/pull/92)
- Add STRTA and migrate to CircleCI [#93](https://github.com/geotrellis/maml/pull/93)
- Add changelog and pull request template [#96](https://github.com/geotrellis/maml/pull/96)
- Add automated releases to Sonatype Nexus through CI [#98](https://github.com/geotrellis/maml/pull/98)

### Changed
- Fixed 2.12 compilation in tests [#95](https://github.com/geotrellis/maml/pull/95)
Expand Down
141 changes: 93 additions & 48 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,22 +1,105 @@
import xerial.sbt.Sonatype._

import com.scalapenos.sbt.prompt.SbtPrompt.autoImport._

promptTheme := com.scalapenos.sbt.prompt.PromptThemes.ScalapenosTheme

/** Project configurations */
val commonSettings = Seq(
// sbt-git provides the isSnapshot.value variable, which will return true if there
rbreslow marked this conversation as resolved.
Show resolved Hide resolved
// are no tags associated with the HEAD commit, or if there are uncommitted
// changes. However, sbt-git only appends the -SNAPSHOT suffix if there are
// uncommitted changes in the workspace.
//
// https://github.com/sbt/sbt-git/blob/f8caf9365be380cf101e9605af159b5e7f842d0c/src/main/scala/com/typesafe/sbt/SbtGit.scala#L173
version := {
// Avoid Cyclic reference involving error
if (git.gitCurrentTags.value.isEmpty || git.gitUncommittedChanges.value)
git.gitDescribedVersion.value.get + "-SNAPSHOT"
else
git.gitDescribedVersion.value.get
},
scalaVersion := "2.11.12",
crossScalaVersions := Seq("2.11.12", "2.12.8"),
resolvers ++= Seq(
Resolver.sonatypeRepo("releases"),
"locationtech-releases" at "https://repo.locationtech.org/content/groups/releases",
"locationtech-snapshots" at "https://repo.locationtech.org/content/groups/snapshots"
),
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full),
scalacOptions := Seq(
"-deprecation",
"-unchecked",
"-feature",
"-language:implicitConversions",
"-language:reflectiveCalls",
"-language:higherKinds",
"-language:postfixOps",
"-language:existentials",
"-language:experimental.macros",
"-feature",
"-Ypatmat-exhaust-depth", "100"
)
)

lazy val noPublishSettings = Seq(
publish := {},
publishLocal := {},
publishArtifact := false
)

lazy val publishSettings = Seq(
organization := "com.azavea.geotrellis",
rbreslow marked this conversation as resolved.
Show resolved Hide resolved
organizationName := "GeoTrellis",
organizationHomepage := Some(new URL("https://geotrellis.io/")),
description := "MAML is used to create a declarative structure that describes a combination of map algebra operations.",
publishArtifact in Test := false
) ++ sonatypeSettings ++ credentialSettings

lazy val sonatypeSettings = Seq(
publishMavenStyle := true,

sonatypeProfileName := "com.azavea",
sonatypeProjectHosting := Some(GitHubHosting(user="geotrellis", repository="maml", email="[email protected]")),
developers := List(
Developer(id = "moradology", name = "Nathan Zimmerman", email = "[email protected]", url = url("https://github.com/moradology")),
Developer(id = "echeipesh", name = "Eugene Cheipesh", email = "[email protected]", url = url("https://github.com/echeipesh")),
Developer(id = "lossyrob", name = "Rob Emanuele", email = "[email protected]", url = url("https://github.com/lossyrob"))
),
licenses := Seq("Apache-2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")),

publishTo := sonatypePublishTo.value
rbreslow marked this conversation as resolved.
Show resolved Hide resolved
)

lazy val credentialSettings = Seq(
credentials += Credentials(
"GnuPG Key ID",
"gpg",
System.getenv().get("GPG_KEY_ID"),
"ignored"
),

credentials += Credentials(
"Sonatype Nexus Repository Manager",
"oss.sonatype.org",
System.getenv().get("SONATYPE_USERNAME"),
System.getenv().get("SONATYPE_PASSWORD")
)
)

lazy val root = project.in(file("."))
.settings(commonSettings)
.settings(publishSettings) // these settings are needed to release all aggregated modules under this root module
.settings(noPublishSettings) // this is to exclue the root module itself from being published
.aggregate(mamlJs, mamlJvm, mamlSpark)
.settings(commonSettings:_*)
.settings(
licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0.txt"))
).enablePlugins(ScalaJSPlugin)
.enablePlugins(ScalaJSPlugin)

val circeVer = "0.11.1"
val circeOpticsVer = "0.11.0"
val gtVer = "3.0.0-M3"

lazy val maml = crossProject.in(file("."))
.settings(publishSettings:_*)
.settings(commonSettings:_*)
.settings(commonSettings)
.settings(publishSettings)
.settings(
libraryDependencies ++= Seq(
"org.scalacheck" %% "scalacheck" % "1.13.4" % "test",
Expand All @@ -40,51 +123,13 @@ lazy val maml = crossProject.in(file("."))
lazy val mamlJvm = maml.jvm
lazy val mamlJs = maml.js
lazy val mamlSpark = project.in(file("spark"))
.dependsOn(mamlJvm)
.settings(commonSettings)
.settings(publishSettings)
.settings(
libraryDependencies ++= Seq(
"org.locationtech.geotrellis" %% "geotrellis-spark-testkit" % gtVer % "test",
"org.apache.spark" %% "spark-core" % "2.4.0" % "provided",
"org.apache.spark" %% "spark-sql" % "2.4.0" % "provided"
)
).settings(publishSettings:_*)
.settings(commonSettings:_*)


/** Common settings */
lazy val publishSettings =
Seq(
bintrayOrganization := Some("azavea"),
bintrayRepository := "maven",
bintrayVcsUrl := Some("https://github.com/geotrellis/maml.git"),
publishMavenStyle := true,
publishArtifact in Test := false,
pomIncludeRepository := { _ => false },
homepage := Some(url("https://geotrellis.github.io/maml"))
)

val commonSettings = Seq(
organization := "com.azavea",
licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0.txt")),
scalaVersion := "2.11.12",
crossScalaVersions := Seq("2.11.12", "2.12.7"),
resolvers ++= Seq(
Resolver.sonatypeRepo("releases"),
"locationtech-releases" at "https://repo.locationtech.org/content/groups/releases",
"locationtech-snapshots" at "https://repo.locationtech.org/content/groups/snapshots"
),
addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full),
scalacOptions := Seq(
"-deprecation",
"-unchecked",
"-feature",
"-language:implicitConversions",
"-language:reflectiveCalls",
"-language:higherKinds",
"-language:postfixOps",
"-language:existentials",
"-language:experimental.macros",
"-feature",
"-Ypatmat-exhaust-depth", "100"
)
)
.dependsOn(mamlJvm)
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=0.13.16
sbt.version=1.2.8
29 changes: 11 additions & 18 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
resolvers ++= Seq(
Classpaths.sbtPluginReleases,
Opts.resolver.sonatypeReleases
)
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.4.0")

resolvers += Classpaths.typesafeResolver

addSbtPlugin("org.foundweekends" % "sbt-bintray" % "0.5.1")

addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.1.10")

addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.5")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.9")

addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.9.2")

addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.25")
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.27")

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.1.0")
addSbtPlugin("io.spray" % "sbt-revolver" % "0.9.1")

addSbtPlugin("io.spray" % "sbt-revolver" % "0.8.0")
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.3.19")

addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.2.0")

addSbtPlugin("com.47deg" % "sbt-microsites" % "0.6.1")
addSbtPlugin("com.47deg" % "sbt-microsites" % "0.9.0")

addSbtPlugin("com.scalapenos" % "sbt-prompt" % "1.0.2")

addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.11")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.5")

addSbtPlugin("io.crashbox" % "sbt-gpg" % "0.2.0")

addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
27 changes: 27 additions & 0 deletions scripts/cipublish
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

set -e

if [[ -n "${MAML_DEBUG}" ]]; then
set -x
fi

function usage() {
echo -n \
"Usage: $(basename "$0")
Publish artifacts to Sonatype.
"
}

if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
if [[ "${1:-}" == "--help" ]]; then
usage
else
echo "Publishing artifacts to Sonatype"
if [[ -n "${CIRCLE_TAG}" ]]; then
./sbt -J-Xmx4G "++${SCALA_VERSION:-2.11.12}" publish sonatypeRelease
else
./sbt -J-Xmx4G "++${SCALA_VERSION:-2.11.12}" publish
fi
fi
fi
2 changes: 1 addition & 1 deletion scripts/test
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
usage
else
echo "Executing Scala test suite"
./sbt "++${SCALA_VERSION:-2.11.12}" test
./sbt -J-Xmx4G "++${SCALA_VERSION:-2.11.12}" test
rbreslow marked this conversation as resolved.
Show resolved Hide resolved
fi
fi
1 change: 0 additions & 1 deletion version.sbt

This file was deleted.