Skip to content
Open
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
20 changes: 20 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Release
on:
push:
branches: ["*"]
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2.3.4
with:
fetch-depth: 0
- uses: olafurpg/setup-scala@v10
- run: sbt clean test
- uses: blended-zio/setup-gpg@v3
- run: sbt ci-publish
env:
PGP_PASSPHRASE: ${{ secrets.PGP_PASSPHRASE }}
PGP_SECRET: ${{ secrets.PGP_SECRET }}
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
SONATYPE_USERNAME: ${{ secrets.SONATYPE_USERNAME }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.bsp
.idea
.idea_modules
target
Expand All @@ -6,4 +7,4 @@ publish/releases
publish/gpg
bin
todo.txt
logs
logs
45 changes: 13 additions & 32 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import bintray.Keys.{bintray, bintrayOrganization, repository}

import scala.util.Try

name := "scala-embedded-jetty"
Expand All @@ -8,46 +6,29 @@ organization := "io.shaka"

version := Try(sys.env("LIB_VERSION")).getOrElse("1")

scalaVersion := "2.12.0"
scalaVersion := "2.13.5"

crossScalaVersions := Seq("2.11.8", "2.12.0")
crossScalaVersions := Seq("2.12.13", "2.13.5")

val jettyVersion = "9.2.11.v20150529"
homepage := Some(url("https://github.com/timt/scala-embedded-jetty"))

licenses +=("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0.html"))

externalResolvers := Seq("Bintray JCenter" at "https://jcenter.bintray.com/")
val jettyVersion = "9.2.11.v20150529"

libraryDependencies ++= Seq(
"org.eclipse.jetty" % "jetty-webapp" % jettyVersion % "provided",
"org.eclipse.jetty" % "jetty-servlets" % jettyVersion % "provided",
"io.shaka" %% "naive-http" % "90" % "provided",
"org.scalatest" %% "scalatest" % "3.0.0" % "test"
"io.shaka" %% "naive-http" % "122" % "provided",
"org.scalatest" %% "scalatest" % "3.1.2" % "test"
)

pgpPassphrase := Some(Try(sys.env("SECRET")).getOrElse("goaway").toCharArray)

pgpSecretRing := file("./publish/sonatype.asc")

bintrayPublishSettings

repository in bintray := "repo"
developers := List(
Developer("timt", "Tim Tennant", "", url("https://github.com/timt"))
)

bintrayOrganization in bintray := None
usePgpKeyHex("timt-ci bot")

publishMavenStyle := true

publishArtifact in Test := false

homepage := Some(url("https://github.com/timt/scala-embedded-jetty"))

licenses +=("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0.html"))

pomExtra :=
<scm>
<url>git@github.com:timt/scala-embedded-jetty.git</url>
<connection>scm:git:git@github.com:timt/scala-embedded-jetty.git</connection>
</scm>
<developers>
<developer>
<id>timt</id>
</developer>
</developers>
publishArtifact in Test := false
97 changes: 97 additions & 0 deletions project/CiPublishPlugin.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import com.jsuereth.sbtpgp.SbtPgp
import com.typesafe.sbt.GitPlugin
import sbt.Keys._
import sbt.{Def, _}
import sbt.plugins.JvmPlugin
import xerial.sbt.Sonatype
import xerial.sbt.Sonatype.autoImport._

import scala.sys.process._
import scala.util.control.NonFatal

object CiPublishPlugin extends AutoPlugin {

override def trigger: PluginTrigger = allRequirements
override def requires: Plugins = JvmPlugin && SbtPgp && GitPlugin && Sonatype

def isSecure: Boolean =
System.getenv("PGP_SECRET") != null

def setupGpg(): Unit = {
val versionLine = List("gpg", "--version").!!.linesIterator.toList.head

println(versionLine)

val TaggedVersion = """(\d{1,14})([\.\d{1,14}]*)((?:-\w+)*)""".r

val gpgVersion: Long = versionLine.split(" ").last match {
case TaggedVersion(m, _, _) ⇒ m.toLong
case _ ⇒ 0L
}

// https://dev.gnupg.org/T2313
val importCommand = if (gpgVersion < 2L) "--import" else "--batch --import"

val secret = sys.env("PGP_SECRET")

(s"echo $secret" #| "base64 --decode" #| s"gpg $importCommand").!
}

private def gitHubScmInfo(user: String, repo: String) =
ScmInfo(
url(s"https://github.com/$user/$repo"),
s"scm:git:https://github.com/$user/$repo.git",
Some(s"scm:git:git@github.com:$user/$repo.git")
)

override lazy val buildSettings: Seq[Def.Setting[_]] = List(
scmInfo ~= {
case Some(info) ⇒ Some(info)
case None ⇒ {
import scala.sys.process._
val identifier = """([^\/]+?)"""
val GitHubHttps = s"https://github.com/$identifier/$identifier(?:\\.git)?".r
val GitHubGit = s"git://github.com:$identifier/$identifier(?:\\.git)?".r
val GitHubSsh = s"git@github.com:$identifier/$identifier(?:\\.git)?".r
try {
val remote = List("git", "ls-remote", "--get-url", "origin").!!.trim()
remote match {
case GitHubHttps(user, repo) ⇒ Some(gitHubScmInfo(user, repo))
case GitHubGit(user, repo) ⇒ Some(gitHubScmInfo(user, repo))
case GitHubSsh(user, repo) ⇒ Some(gitHubScmInfo(user, repo))
case _ ⇒ None
}
} catch {
case NonFatal(_) ⇒ None
}
}
}
)

override lazy val globalSettings: Seq[Def.Setting[_]] = List(
publishArtifact.in(Test) := false,
publishMavenStyle := true,
commands += Command.command("ci-publish")(currentState ⇒ {
if (!isSecure) {
println("No access to secret variables, skipping publish")
currentState
} else {
println("Running ci-publish")
setupGpg()
// https://github.com/olafurpg/sbt-ci-release/issues/64

"set pgpSecretRing := pgpSecretRing.value" ::
"set pgpPublicRing := pgpPublicRing.value" ::
"+publishSigned" ::
"sonatypeBundleRelease" ::
currentState
}
})
)

override lazy val projectSettings: Seq[Def.Setting[_]] = List(
publishConfiguration := publishConfiguration.value.withOverwrite(true),
publishLocalConfiguration := publishLocalConfiguration.value.withOverwrite(true),
publishTo := sonatypePublishToBundle.value
)
}
2 changes: 2 additions & 0 deletions project/build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
sbt.version=1.4.8

8 changes: 3 additions & 5 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
resolvers ++= Seq( "bintray-sbt-plugin-releases" at "http://dl.bintray.com/content/sbt/sbt-plugin-releases" )

addSbtPlugin("me.lessis" % "bintray-sbt" % "0.1.1")

addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.3")
addSbtPlugin("com.github.sbt" % "sbt-pgp" % "2.1.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.7")
3 changes: 2 additions & 1 deletion src/main/scala/io/shaka/jetty/Handlers.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package io.shaka.jetty

import javax.servlet.http.{HttpServletRequest, HttpServletResponse}
import scala.language.postfixOps

import javax.servlet.http.{HttpServletRequest, HttpServletResponse}
import io.shaka.http.Http.HttpHandler
import io.shaka.http.HttpHeader.httpHeader
import io.shaka.http.Method.method
Expand Down
4 changes: 2 additions & 2 deletions src/test/scala/io/shaka/jetty/EmbeddedJettyLoggingSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import scala.collection.mutable
class EmbeddedJettyLoggingSpec extends FunSuite {

test("Override the logging") {
val logMessages = mutable.MutableList[String]()
val logMessages = mutable.ListBuffer[String]()

val logSpy: ToLog = (message) ⇒ logMessages += message

Expand All @@ -25,7 +25,7 @@ class EmbeddedJettyLoggingSpec extends FunSuite {
}

test("Override the request logging") {
val logMessages = mutable.MutableList[String]()
val logMessages = mutable.ListBuffer[String]()

val requestLogSpy: RequestLog = new AbstractNCSARequestLog {
override def isEnabled = true
Expand Down