diff --git a/.github/workflows/main.yml b/.github/workflows/ci.yml similarity index 57% rename from .github/workflows/main.yml rename to .github/workflows/ci.yml index 8542d37..e37c075 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/ci.yml @@ -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 \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..a6fcc55 --- /dev/null +++ b/.github/workflows/release.yml @@ -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 \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a740073..0000000 --- a/.travis.yml +++ /dev/null @@ -1,35 +0,0 @@ -language: scala -jdk: - - openjdk8 - -stages: - - name: test - - name: release - if: ((branch = master AND type = push) OR (tag IS present)) AND NOT fork - -jobs: - include: - - env: TEST="scalafmt" - script: ./bin/scalafmt --test - - env: TEST="compile" - script: sbt compile - - stage: release - script: sbt ci-release - -cache: - directories: - - $HOME/.sbt/1.0/dependency - - $HOME/.sbt/boot/scala* - - $HOME/.sbt/launchers - - $HOME/.ivy2/cache - - $HOME/.coursier - -before_cache: - - du -h -d 1 $HOME/.ivy2/cache - - du -h -d 2 $HOME/.sbt/ - - find $HOME/.sbt -name "*.lock" -type f -delete - - find $HOME/.ivy2/cache -name "ivydata-*.properties" -type f -delete - - rm -rf $HOME/.ivy2/local - -before_install: - - git fetch --tags diff --git a/bin/install-java.sh b/bin/install-java.sh index 1ee8db1..99bb741 100755 --- a/bin/install-java.sh +++ b/bin/install-java.sh @@ -8,4 +8,3 @@ sdk install java $(sdk list java | grep -o "$ADOPTOPENJDK\.[0-9\.]*hs-adpt" | he unset JAVA_HOME java -Xmx32m -version git fetch --tags -echo 'source "$HOME/.sdkman/bin/sdkman-init.sh"' >> $HOME/.bash_profile diff --git a/build.sbt b/build.sbt index 8b0c59c..929bbda 100644 --- a/build.sbt +++ b/build.sbt @@ -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"), diff --git a/plugin/src/main/scala/com/geirsson/CiReleasePlugin.scala b/plugin/src/main/scala/com/geirsson/CiReleasePlugin.scala index 9f8a3c7..d3d830b 100644 --- a/plugin/src/main/scala/com/geirsson/CiReleasePlugin.scala +++ b/plugin/src/main/scala/com/geirsson/CiReleasePlugin.scala @@ -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("") def travisBranch: String = Option(System.getenv("TRAVIS_BRANCH")) .orElse(Option(System.getenv("BUILD_SOURCEBRANCH"))) + .orElse(Option(System.getenv("GITHUB_REF"))) .getOrElse("") 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") @@ -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 => @@ -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 @@ -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 := diff --git a/project/build.properties b/project/build.properties index c0bab04..8522443 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.2.8 +sbt.version=1.3.2 diff --git a/project/plugins.sbt b/project/plugins.sbt index 3f93598..0452dde 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -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 diff --git a/project/project/plugins.sbt b/project/project/plugins.sbt deleted file mode 100644 index cc0b724..0000000 --- a/project/project/plugins.sbt +++ /dev/null @@ -1 +0,0 @@ -addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.1.0-M4")