Skip to content

Commit

Permalink
Setup GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
olafurpg committed Sep 22, 2019
1 parent 41dbf40 commit 8034b75
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 72 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/main.yml → .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: ci
on: [push]
name: CI
on:
push:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: olafurpg/setup-java@v1
- name: Compile
run: ./bin/sbt compile


run: csbt compile
14 changes: 14 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Release
on:
push:
branches: [master]
tags:
jobs:
release:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: olafurpg/setup-java@v1
- name: Publish
run: csbt ci-release
35 changes: 0 additions & 35 deletions .travis.yml

This file was deleted.

11 changes: 0 additions & 11 deletions bin/install-java.sh

This file was deleted.

7 changes: 4 additions & 3 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,19 @@ inThisBuild(
"olafurpg@gmail.com",
url("https://geirsson.com")
)
),
resolvers += Resolver.sonatypeRepo("releases"),
scalaVersion := "2.12.8"
)
)
)

onLoadMessage := s"Welcome to sbt-ci-release ${version.value}"

skip in publish := true // don't publish the root project

lazy val plugin = project
.settings(
moduleName := "sbt-ci-release",
sbtPlugin := true,
sbtVersion in pluginCrossBuild := "1.0.4",
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.0.0"),
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0"),
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.7"),
Expand Down
22 changes: 13 additions & 9 deletions plugin/src/main/scala/com/geirsson/CiReleasePlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,23 +22,29 @@ object CiReleasePlugin extends AutoPlugin {
override def requires =
JvmPlugin && SbtPgp && DynVerPlugin && GitPlugin && Sonatype

def isTravisSecure: Boolean =
System.getenv("TRAVIS_SECURE_ENV_VARS") == "true" ||
System.getenv("BUILD_REASON") == "IndividualCI" ||
System.getenv("PGP_SECRET") != null
def isTravisTag: Boolean =
Option(System.getenv("TRAVIS_TAG")).exists(_.nonEmpty) ||
Option(System.getenv("BUILD_SOURCEBRANCH"))
.orElse(Option(System.getenv("GITHUB_REF")))
.exists(_.startsWith("refs/tags"))
def isTravisSecure: Boolean =
System.getenv("TRAVIS_SECURE_ENV_VARS") == "true" ||
System.getenv("BUILD_REASON") == "IndividualCI"
def travisTag: String =
Option(System.getenv("TRAVIS_TAG"))
.orElse(Option(System.getenv("BUILD_SOURCEBRANCH")))
.orElse(Option(System.getenv("GITHUB_REF")))
.getOrElse("<unknown>")
def travisBranch: String =
Option(System.getenv("TRAVIS_BRANCH"))
.orElse(Option(System.getenv("BUILD_SOURCEBRANCH")))
.orElse(Option(System.getenv("GITHUB_REF")))
.getOrElse("<unknown>")
def isAzure: Boolean =
System.getenv("TF_BUILD") == "True"
def isGithub: Boolean =
System.getenv("GITHUB_ACTION") != null

def setupGpg(): Unit = {
val secret = sys.env("PGP_SECRET")
Expand All @@ -53,12 +59,12 @@ object CiReleasePlugin extends AutoPlugin {
}
}

override def buildSettings: Seq[Def.Setting[_]] = List(
override lazy val buildSettings: Seq[Def.Setting[_]] = List(
dynverSonatypeSnapshots := true,
pgpPassphrase := sys.env.get("PGP_PASSPHRASE").map(_.toCharArray())
)

override def globalSettings: Seq[Def.Setting[_]] = List(
override lazy val globalSettings: Seq[Def.Setting[_]] = List(
publishArtifact.in(Test) := false,
publishMavenStyle := true,
commands += Command.command("ci-release") { currentState =>
Expand All @@ -68,9 +74,7 @@ object CiReleasePlugin extends AutoPlugin {
} else {
println(
s"Running ci-release.\n" +
s" TRAVIS_SECURE_ENV_VARS=$isTravisSecure\n" +
s" TRAVIS_BRANCH=$travisBranch\n" +
s" TRAVIS_TAG=$travisTag"
s" branch=$travisBranch"
)
setupGpg()
// https://github.com/olafurpg/sbt-ci-release/issues/64
Expand Down Expand Up @@ -101,7 +105,7 @@ object CiReleasePlugin extends AutoPlugin {
}
)

override def projectSettings: Seq[Def.Setting[_]] = List(
override lazy val projectSettings: Seq[Def.Setting[_]] = List(
publishConfiguration :=
publishConfiguration.value.withOverwrite(true),
publishLocalConfiguration :=
Expand Down
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.2.8
sbt.version=1.3.2
7 changes: 0 additions & 7 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
unmanagedSourceDirectories.in(Compile) +=
baseDirectory.in(ThisBuild).value.getParentFile /
"plugin" / "src" / "main" / "scala"
addSbtPlugin(
"io.get-coursier" % "sbt-coursier" % coursier.util.Properties.version
)
addSbtPlugin(
"io.get-coursier" % "sbt-shading" % coursier.util.Properties.version
)
addSbtPlugin("com.dwijnand" % "sbt-dynver" % "4.0.0")
addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.7")
addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0")
libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value
1 change: 0 additions & 1 deletion project/project/plugins.sbt

This file was deleted.

0 comments on commit 8034b75

Please sign in to comment.