Skip to content

Commit

Permalink
Add a release workflow. (#327)
Browse files Browse the repository at this point in the history
  • Loading branch information
mwz authored Apr 1, 2020
1 parent f25ad25 commit f2116a2
Show file tree
Hide file tree
Showing 4 changed files with 86 additions and 75 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/master-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Release
on:
push:
branches: [master]
tags: ["*"]
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: git fetch --prune --unshallow
- uses: olafurpg/setup-scala@v7
with:
java-version: [email protected]
- run: |
sudo apt-get update && sudo apt-get -y install gnupg2
mkdir ~/.gnupg && chmod 700 ~/.gnupg
echo use-agent >> ~/.gnupg/gpg.conf
echo pinentry-mode loopback >> ~/.gnupg/gpg.conf
echo allow-loopback-pinentry >> ~/.gnupg/gpg-agent.conf
chmod 600 ~/.gnupg/*
echo RELOADAGENT | gpg-connect-agent
echo $PGP_SECRET | base64 --decode | gpg --import --no-tty --batch --yes
env:
PGP_SECRET: ${{secrets.PGP_SECRET}}
- uses: actions/cache@v1
with:
path: ~/.ivy2/cache
key: ivy-${{hashFiles('**/*.sbt')}}
restore-keys: |
ivy-
- uses: actions/cache@v1
with:
path: ~/.sbt
key: sbt-${{hashFiles('**/*.sbt')}}-${{hashFiles('project/build.properties')}}
restore-keys: |
sbt-
- run: sbt ci-release
env:
PGP_PASSPHRASE: ${{secrets.PGP_PASSPHRASE}}
PGP_SECRET: ${{secrets.PGP_SECRET}}
SONATYPE_PASSWORD: ${{secrets.SONATYPE_PASSWORD}}
SONATYPE_USERNAME: ${{secrets.SONATYPE_USERNAME}}
106 changes: 38 additions & 68 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,26 +1,38 @@
import com.typesafe.sbt.pgp.PgpKeys
import sbt.Keys._

// compiler plugins
addCompilerPlugin(scalafixSemanticdb)

name := "scalac-scapegoat-plugin"

organization := "com.sksamuel.scapegoat"
description := "Scala compiler plugin for static code analysis"
homepage := Some(url("https://github.com/sksamuel/scapegoat"))
licenses += ("Apache-2.0", url("http://www.apache.org/licenses/LICENSE-2.0.html"))
scmInfo := Some(
ScmInfo(
url("https://github.com/sksamuel/scapegoat"),
"scm:[email protected]:sksamuel/scapegoat.git",
Some("scm:[email protected]:sksamuel/scapegoat.git")
)
)
developers := List(
Developer(
"sksamuel",
"sksamuel",
"@sksamuel",
url("https://github.com/sksamuel")
)
)

scalaVersion := "2.13.1"
crossScalaVersions := Seq("2.11.12", "2.12.10", "2.12.11", "2.13.0", "2.13.1")
autoScalaLibrary := false
crossVersion := CrossVersion.full
crossTarget := {
// workaround for https://github.com/sbt/sbt/issues/5097
target.value / s"scala-${scalaVersion.value}"
}
releaseCrossBuild := true

sbtVersion in Global := "1.1.6"

SbtPgp.autoImport.useGpg := true

SbtPgp.autoImport.useGpgAgent := true
// https://github.com/sksamuel/scapegoat/issues/298
ThisBuild / useCoursier := false

val scalac13Options = Seq(
"-Xlint:adapted-args",
Expand All @@ -31,7 +43,6 @@ val scalac13Options = Seq(
"-Yrangepos",
"-Ywarn-unused"
)

val scalac12Options = Seq(
"-Xlint:adapted-args",
"-Ywarn-inaccessible",
Expand All @@ -41,7 +52,6 @@ val scalac12Options = Seq(
"-Xmax-classfile-name",
"254"
)

val scalac11Options = Seq(
"-Ywarn-adapted-args",
"-Ywarn-inaccessible",
Expand All @@ -54,7 +64,6 @@ val scalac11Options = Seq(
"254"
//"-Ywarn-value-discard"
)

scalacOptions := {
val common = Seq(
"-unchecked",
Expand All @@ -64,16 +73,16 @@ scalacOptions := {
"utf8",
"-Xlint"
)

common ++ (scalaBinaryVersion.value match {
case "2.11" => scalac11Options
case "2.12" => scalac12Options
case "2.13" => scalac13Options
})
}
javacOptions ++= Seq("-source", "1.8", "-target", "1.8")

fullClasspath in console in Compile ++= (fullClasspath in Test).value // because that's where "PluginRunner" is

// because that's where "PluginRunner" is
fullClasspath in console in Compile ++= (fullClasspath in Test).value
initialCommands in console := s"""
import com.sksamuel.scapegoat._
def check(code: String) = {
Expand All @@ -87,8 +96,6 @@ def check(code: String) = {
}
"""

javacOptions ++= Seq("-source", "1.8", "-target", "1.8")

libraryDependencies ++= Seq(
"org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided",
"org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided",
Expand All @@ -107,65 +114,28 @@ libraryDependencies ++= Seq(
"org.slf4j" % "slf4j-api" % "1.7.30" % "test"
)

sbtrelease.ReleasePlugin.autoImport.releasePublishArtifactsAction := PgpKeys.publishSigned.value

sbtrelease.ReleasePlugin.autoImport.releaseCrossBuild := true

publishTo := Some(
if (isSnapshot.value)
Opts.resolver.sonatypeSnapshots
else
Opts.resolver.sonatypeStaging
)

publishMavenStyle := true

publishArtifact in Test := false

// Test
fork in (Test, run) := true
logBuffered in Test := false
parallelExecution in Test := false

pomIncludeRepository := { _ => false }

pomExtra := {
<url>https://github.com/sksamuel/scapegoat</url>
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>git@github.com:sksamuel/scapegoat.git</url>
<connection>scm:git@github.com:sksamuel/scapegoat.git</connection>
</scm>
<developers>
<developer>
<id>sksamuel</id>
<name>sksamuel</name>
<url>http://github.com/sksamuel</url>
</developer>
</developers>
}
// ScalaTest reporter config:
// -o - standard output,
// D - show all durations,
// T - show reminder of failed and cancelled tests with short stack traces,
// F - show full stack traces.
testOptions in Test += Tests.Argument(TestFrameworks.ScalaTest, "-oDTF")

// Assembly
// include the scala xml and compat modules into the final jar, shaded
assemblyShadeRules in assembly := Seq(
ShadeRule.rename("scala.xml.**" -> "scapegoat.xml.@1").inAll,
ShadeRule.rename("scala.collection.compat.**" -> "scapegoat.compat.@1").inAll
)

// do not run tests during assembly
test in assembly := {}

autoScalaLibrary := false
makePom := makePom.dependsOn(assembly).value
packageBin in Compile := crossTarget.value / (assemblyJarName in assembly).value

// debug assembly process
//logLevel in assembly := Level.Debug

// https://github.com/sksamuel/scapegoat/issues/298
ThisBuild / useCoursier := false
makePom := makePom.dependsOn(assembly).value
test in assembly := {} // do not run tests during assembly
publishArtifact in Test := false

// Scalafix
scalafixDependencies in ThisBuild += "com.nequissimus" %% "sort-imports" % "0.3.1"
Expand Down
11 changes: 5 additions & 6 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
resolvers += Classpaths.sbtPluginReleases

addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2")
addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.2")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.12")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")
addSbtPlugin("com.geirsson" % "sbt-ci-release" % "1.5.2")
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.10")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.3.2")
addSbtPlugin("ch.epfl.scala" % "sbt-scalafix" % "0.9.12")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.1")

if (System.getProperty("add-scapegoat-plugin") == "true")
addSbtPlugin(s"com.sksamuel.scapegoat" % "sbt-scapegoat" % "1.1.0")
Expand Down
1 change: 0 additions & 1 deletion version.sbt

This file was deleted.

0 comments on commit f2116a2

Please sign in to comment.