Skip to content

Commit

Permalink
Move off of JCenter / TravisCI to Maven Central / GitHub Actions. (#26)
Browse files Browse the repository at this point in the history
  • Loading branch information
jverbus authored Apr 8, 2021
1 parent 867f291 commit 35d323e
Show file tree
Hide file tree
Showing 10 changed files with 279 additions and 105 deletions.
116 changes: 116 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
#
# CI build that assembles artifacts and runs tests.
# If validation is successful this workflow releases from the main dev branch.
#
# - skipping CI: add [skip ci] to the commit message
# - skipping release: add [skip release] to the commit message
#
name: CI

on:
push:
branches: ['master']
tags-ignore: [v*] # release tags are autogenerated after a successful CI, no need to run CI against them
paths-ignore:
- 'docs/**'
- '**.md'
pull_request:
branches: ['**']

jobs:

build:
runs-on: ubuntu-latest
strategy:
matrix:
include:
- scala-version: 2.11.8
spark-version: 2.3.0
- scala-version: 2.11.8
spark-version: 2.4.3
- scala-version: 2.12.11
spark-version: 2.4.3
- scala-version: 2.12.11
spark-version: 3.0.0
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
steps:
- name: Check out code
uses: actions/checkout@v2 # https://github.com/actions/checkout
with:
fetch-depth: '0' # https://github.com/shipkit/shipkit-changelog#fetch-depth-on-ci
- name: Set up Java
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Perform build
env:
SCALA_VERSION: ${{ matrix.scala-version }}
SPARK_VERSION: ${{ matrix.spark-version }}
run: ./gradlew build publishToMavenLocal -s -PscalaVersion=$SCALA_VERSION -PsparkVersion=$SPARK_VERSION

github-release:
runs-on: ubuntu-latest
needs: build
# Release job, only for pushes to the main development branch
if: github.event_name == 'push'
&& github.ref == 'refs/heads/main'
&& github.repository == 'linkedin/isolation-forest'
&& !contains(toJSON(github.event.commits.*.message), '[skip release]')
steps:
- name: Check out code
# https://github.com/actions/checkout
uses: actions/checkout@v2
with:
# Needed to get all tags. Refer https://github.com/shipkit/shipkit-changelog#fetch-depth-on-ci
fetch-depth: '0'
- name: Setup Java
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Release
run: ./gradlew githubRelease -s
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

# release:
# runs-on: ubuntu-latest
# strategy:
# matrix:
# include:
# - scala-version: 2.11.8
# spark-version: 2.3.0
# - scala-version: 2.11.8
# spark-version: 2.4.3
# - scala-version: 2.12.11
# spark-version: 2.4.3
# - scala-version: 2.12.11
# spark-version: 3.0.0
# if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
# steps:
# - name: Check out code
# uses: actions/checkout@v2 # https://github.com/actions/checkout
# with:
# fetch-depth: '0' # https://github.com/shipkit/shipkit-changelog#fetch-depth-on-ci
# - name: Set up Java
# uses: actions/setup-java@v1
# with:
# java-version: 1.8
# - name: Perform build
# env:
# SCALA_VERSION: ${{ matrix.scala-version }}
# SPARK_VERSION: ${{ matrix.spark-version }}
# run: ./gradlew build publishToMavenLocal -s -PscalaVersion=$SCALA_VERSION -PsparkVersion=$SPARK_VERSION
# - name: Perform release
# # Release job, only for pushes to the main development branch
# if: github.event_name == 'push'
# && github.ref == 'refs/heads/master'
# && github.repository == 'linkedin/isolation-forest'
# && !contains(toJSON(github.event.commits.*.message), '[skip release]')
# run: ./gradlew publishToSonatype closeAndReleaseStagingRepository -s -PscalaVersion=$SCALA_VERSION -PsparkVersion=$SPARK_VERSION
# env:
# SCALA_VERSION: ${{ matrix.scala-version }}
# SPARK_VERSION: ${{ matrix.spark-version }}
# SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
# SONATYPE_PWD: ${{ secrets.SONATYPE_PWD }}
# PGP_KEY: ${{ secrets.PGP_KEY }}
# PGP_PWD: ${{ secrets.PGP_PWD }}
55 changes: 0 additions & 55 deletions .travis.yml

This file was deleted.

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ You can also build an artifact with Spark 2.4 (or 3.0) and Scala 2.12.
./gradlew build -PsparkVersion=3.0.0 -PscalaVersion=2.12.11
```

To force a rebuild of the library, you can use:
```bash
./gradlew clean build --no-build-cache
```

### Add an isolation-forest dependency to your project

Please check [Bintray](https://bintray.com/beta/#/linkedin/maven/isolation-forest) for the latest
Expand Down
21 changes: 20 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,22 @@
buildscript {
repositories {
jcenter()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "io.github.gradle-nexus:publish-plugin:1.+"
classpath "org.shipkit:shipkit-auto-version:1.+"
classpath "org.shipkit:shipkit-changelog:1.+"
}
}

plugins {
id "org.shipkit.java" version "2.3.0"
}

apply from: "gradle/release.gradle"

allprojects {
apply plugin: "eclipse"
apply plugin: "idea"
Expand All @@ -13,3 +28,7 @@ allprojects {
mavenCentral()
}
}

task clean(type: Delete) {
delete "build"
}
93 changes: 93 additions & 0 deletions gradle/java-publication.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
apply plugin: "java"

def licenseSpec = copySpec {
from project.rootDir
include "LICENSE"
include "NOTICE"
}

task sourcesJar(type: Jar, dependsOn: classes) {
classifier 'sources'
from sourceSets.main.allSource
with licenseSpec
}

task javadocJar(type: Jar, dependsOn: javadoc) {
classifier 'javadoc'
from tasks.javadoc
with licenseSpec
}

jar {
with licenseSpec
}

artifacts {
archives sourcesJar
archives javadocJar
}

apply plugin: "maven-publish" // https://docs.gradle.org/current/userguide/publishing_maven.html
publishing {
publications {
isolationForestJar(MavenPublication) {
from components.java
artifact sourcesJar
artifact javadocJar

artifactId = project.archivesBaseName

pom {
name = artifactId
description = "A Spark/Scala implementation of the isolation forest unsupervised outlier detection algorithm."

url = "https://github.com/linkedin/isolation-forest"
licenses {
license {
name = 'BSD 2-CLAUSE'
url = 'https://github.com/linkedin/isolation-forest/blob/master/LICENSE'
distribution = 'repo'
}
}
developers {
[
'jverbus:James Verbus'
].each { devData ->
developer {
def devInfo = devData.split(':')
id = devInfo[0]
name = devInfo[1]
url = 'https://github.com/' + devInfo[0]
roles = ["Core developer"]
}
}
}
scm {
url = 'https://github.com/linkedin/isolation-forest.git'
}
issueManagement {
url = 'https://github.com/linkedin/isolation-forest/issues'
system = 'GitHub issues'
}
ciManagement {
url = 'https://travis-ci.com/linkedin/isolation-forest'
system = 'Travis CI'
}
}
}
}

// Useful for testing - running "publish" will create artifacts/pom in a local dir.
repositories { maven { url = "$rootProject.buildDir/repo" } }
}

// Fleshes out problems with Maven pom generation when building.
tasks.build.dependsOn("publishIsolationForestJarPublicationToMavenLocal")

apply plugin: 'signing' // https://docs.gradle.org/current/userguide/signing_plugin.html
signing {
if (System.getenv("PGP_KEY")) {
useInMemoryPgpKeys(System.getenv("PGP_KEY"), System.getenv("PGP_PWD"))
sign publishing.publications.isolationForestJar
}
}
39 changes: 39 additions & 0 deletions gradle/release.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// Shipkit tasks
//

// Plugin jars are added to the buildscript classpath in the root build.gradle file.
apply plugin: "org.shipkit.shipkit-auto-version" // https://github.com/shipkit/shipkit-auto-version

apply plugin: "org.shipkit.shipkit-changelog" // https://github.com/shipkit/shipkit-changelog
tasks.named("generateChangelog") {
previousRevision = project.ext.'shipkit-auto-version.previous-tag'
githubToken = System.getenv("GITHUB_TOKEN")
repository = "linkedin/isolation-forest"
}

apply plugin: "org.shipkit.shipkit-github-release" // https://github.com/shipkit/shipkit-changelog
tasks.named("githubRelease") {
def genTask = tasks.named("generateChangelog").get()
dependsOn genTask
repository = genTask.repository
changelog = genTask.outputFile
githubToken = System.getenv("GITHUB_TOKEN")
newTagRevision = System.getenv("GITHUB_SHA")
}

//
// Maven Central configuration
//

apply plugin: "io.github.gradle-nexus.publish-plugin" // https://github.com/gradle-nexus/publish-plugin/
nexusPublishing {
repositories {
if (System.getenv("SONATYPE_PWD")) {
sonatype {
username = System.getenv("SONATYPE_USER")
password = System.getenv("SONATYPE_PWD")
}
}
}
}
44 changes: 0 additions & 44 deletions gradle/shipkit.gradle

This file was deleted.

Loading

0 comments on commit 35d323e

Please sign in to comment.