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

enable github actions #1220

Merged
merged 1 commit into from
Nov 10, 2020
Merged
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
41 changes: 41 additions & 0 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: PR Build

on: [pull_request]

jobs:
build:
runs-on: macos-latest
strategy:
matrix:
java: [15]
scala: [2.13.3]
steps:
- uses: actions/checkout@v2
- name: Set up JDK ${{ matrix.java }}
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
- uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2
key: ${{ runner.os }}-${{ hashFiles('**/*.sbt') }}
- name: Build
run: cat /dev/null | project/sbt ++${{ matrix.scala }} clean test
check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 15
uses: actions/setup-java@v1
with:
java-version: 15
- uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2
key: ${{ runner.os }}-${{ hashFiles('**/*.sbt') }}
- name: Build
run: cat /dev/null | project/sbt checkLicenseHeaders scalafmtCheckAll
31 changes: 31 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Release

on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+
- v[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 15
- uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2
key: ${{ runner.os }}-${{ hashFiles('**/*.sbt') }}
- name: Build
env:
bintrayUser: ${{ secrets.ORG_BINTRAY_USER }}
bintrayKey: ${{ secrets.ORG_BINTRAY_KEY }}
run: |
git fetch --unshallow --tags
cat /dev/null | project/sbt storeBintrayCredentials
cat /dev/null | project/sbt clean test publish bintrayRelease
30 changes: 30 additions & 0 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Snapshot

on:
push:
branches:
- master

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 15
- uses: actions/cache@v2
with:
path: |
~/.sbt
~/.ivy2
key: ${{ runner.os }}-${{ hashFiles('**/*.sbt') }}
- name: Build
env:
bintrayUser: ${{ secrets.ORG_BINTRAY_USER }}
bintrayKey: ${{ secrets.ORG_BINTRAY_KEY }}
run: |
git fetch --unshallow --tags
cat /dev/null | project/sbt storeBintrayCredentials
cat /dev/null | project/sbt clean test publish
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ matrix:
scala: 2.13.3
os: linux
dist: xenial
env: BINTRAY_PUBLISH=true
env: BINTRAY_PUBLISH=false
script:
- ./scripts/buildViaTravis.sh
env:
Expand Down
3 changes: 1 addition & 2 deletions project/Bintray.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@ import bintray.BintrayKeys._
object Bintray {

lazy val now = System.currentTimeMillis
lazy val isPullRequest = sys.env.getOrElse("TRAVIS_PULL_REQUEST", "false") != "false"

private def get(k: String): String = {
if (isPullRequest) s"dummy$k" else sys.env.getOrElse(s"bintray$k", s"missing$k")
sys.env.getOrElse(s"bintray$k", s"missing$k")
}

lazy val user = get("User")
Expand Down
4 changes: 2 additions & 2 deletions project/BuildSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ object BuildSettings {
},
packageOptions in (Compile, packageBin) += Package.ManifestAttributes(
"Build-Date" -> java.time.Instant.now().toString,
"Build-Number" -> sys.env.getOrElse("TRAVIS_BUILD_NUMBER", "unknown"),
"Commit" -> sys.env.getOrElse("TRAVIS_COMMIT", "unknown")
"Build-Number" -> sys.env.getOrElse("GITHUB_RUN_ID", "unknown"),
"Commit" -> sys.env.getOrElse("GITHUB_SHA", "unknown")
),
// scaladoc crashes on jdk11 using `-release 8` with assertion failure:
// type AnyRef in java.lang
Expand Down
13 changes: 11 additions & 2 deletions project/GitVersion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ object GitVersion {
* Needs to check for "false", don't assume it will ever be set to "true".
* http://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
*/
private def isPullRequest: Boolean = sys.env.getOrElse("TRAVIS_PULL_REQUEST", "false") != "false"
private def isPullRequest: Boolean = sys.env.getOrElse("GITHUB_EVENT_NAME", "unknown") == "pull_request"

/**
* Bump the last git described version to use for the current snapshot. If it is a version branch
Expand All @@ -44,9 +44,18 @@ object GitVersion {
}
}

private def extractBranchName(dflt: String): String = {
val ref = sys.env.getOrElse("GITHUB_REF", dflt)
// Return last part if there is a '/', e.g. refs/heads/feature-branch-1. For
// this use-case we only care about master and version branches so it is ok
// if something like 'feature/branch/1' exacts just the '1'.
val parts = ref.split("/")
parts(parts.length - 1)
}

lazy val settings: Seq[Def.Setting[_]] = Seq(
version in ThisBuild := {
val branch = sys.env.getOrElse("TRAVIS_BRANCH", git.gitCurrentBranch.value)
val branch = extractBranchName(git.gitCurrentBranch.value)
val branchVersion = if (branch == "master") baseVersion else branch
git.gitDescribedVersion.value.getOrElse("0.1-SNAPSHOT") match {
case _ if isPullRequest => s"0.0.0-PULLREQUEST"
Expand Down