Skip to content

Commit

Permalink
Upgrade Shipkit and Gradle, and move off JCenter (#8)
Browse files Browse the repository at this point in the history
* Upgraded to Shipkit 3.0 and Gradle 6.x
* Moved to GH Actions from Travis CI
* Added the ability to publish to LinkedIn Artifactory and Maven Central directly
  • Loading branch information
sriramvasudevan committed Mar 30, 2021
1 parent 5d5c758 commit 652fcda
Show file tree
Hide file tree
Showing 10 changed files with 325 additions and 109 deletions.
86 changes: 86 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# 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: ['main']
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
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
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: Build and test code, and test artifact publishing
run: ./gradlew build publishToMavenLocal artifactoryPublishAll -s -Partifactory.dryRun -PscalaVersion=$SCALA_VERSION -PsparkVersion=$SPARK_VERSION
env:
SCALA_VERSION: ${{ matrix.scala-version }}
SPARK_VERSION: ${{ matrix.spark-version }}
- name: Release to Maven Central and LinkedIn Artifactory
# Release job, only for pushes to the main development branch
if: github.event_name == 'push'
&& github.ref == 'refs/heads/main'
&& github.repository == 'linkedin/LiFT'
&& !contains(toJSON(github.event.commits.*.message), '[skip release]')
run: ./gradlew publishToSonatype closeAndReleaseStagingRepository artifactoryPublishAll -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 }}
ARTIFACTORY_USER: ${{ secrets.ARTIFACTORY_USER }}
ARTIFACTORY_KEY: ${{ secrets.ARTIFACTORY_KEY }}
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/LiFT'
&& !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 }}
48 changes: 0 additions & 48 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 @@ -81,6 +81,11 @@ Tests typically run with the `test` task. If you want to force-run all tests, yo
./gradlew cleanTest test --no-build-cache
```

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


### Add a LiFT Dependency to Your Project

Expand Down
22 changes: 19 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,31 @@
plugins {
id "org.shipkit.java" version "2.3.4"
buildscript {
repositories {
mavenLocal() // for local testing
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.+"
classpath "io.github.gradle-nexus:publish-plugin:1.+"
classpath "org.shipkit:shipkit-auto-version:1.+"
classpath "org.shipkit:shipkit-changelog:1.+"
}
}

apply from: "gradle/release.gradle"

allprojects {
apply plugin: "eclipse"
apply plugin: "idea"

group = "com.linkedin.lift"

repositories {
jcenter()
mavenCentral()
}
}

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

tasks.withType(Jar) {
from "$rootDir/LICENSE"
from "$rootDir/NOTICE"
}

// Auxiliary jar files required by Maven module publications
task sourcesJar(type: Jar, dependsOn: classes) {
classifier 'sources'
from sourceSets.main.allSource
}

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

artifacts {
archives sourcesJar
archives javadocJar
}

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

artifactId = project.archivesBaseName

pom {
name = artifactId
description = "A Scala/Spark library that enables the measurement of fairness in large scale machine learning workflows."
url = "https://github.com/linkedin/LiFT"
licenses {
license {
name = 'BSD 2-CLAUSE'
url = 'https://github.com/linkedin/LiFT/blob/master/LICENSE'
distribution = 'repo'
}
}
developers {
[
'sriramvasudevan:Sriram Vasudevan'
].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/LiFT.git'
}
issueManagement {
url = 'https://github.com/linkedin/LiFT/issues'
system = 'GitHub issues'
}
ciManagement {
url = 'https://travis-ci.com/linkedin/LiFT'
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("publishLiftJarPublicationToMavenLocal")

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.liftJar
}
}

//////////////////////////////////
// LinkedIn Artifactory Config
//////////////////////////////////

apply plugin: "com.jfrog.artifactory" //https://www.jfrog.com/confluence/display/rtf/gradle+artifactory+plugin
artifactory {
contextUrl = 'https://linkedin.jfrog.io/artifactory'
publish {
repository {
repoKey = 'LiFT'
username = System.getenv('ARTIFACTORY_USER')
password = System.getenv('ARTIFACTORY_KEY')
maven = true
}

defaults {
publications('liftJar')
publishBuildInfo = true
publishArtifacts = true
publishPom = true
publishIvy = true
}
}
clientConfig.setIncludeEnvVars(false)
}

artifactoryPublish {
skip = project.hasProperty('artifactory.dryRun')
}
83 changes: 83 additions & 0 deletions gradle/release.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
//Plugin jars are added to the buildscript classpath in the root build.gradle file

//////////////////////////////////
// Token Verification Tasks
//////////////////////////////////

task checkGitHubToken {
doFirst {
if (System.getenv("GITHUB_TOKEN") == null) {
throw new Exception("Environment variable GITHUB_TOKEN not set.");
}
println "Using repository " + System.getenv("GITHUB_REPOSITORY")
}
}

task verifyArtifactoryProperties {
doFirst {
if (!project.hasProperty('artifactory.dryRun')) {
if (System.getenv('ARTIFACTORY_USER') == null) {
throw new Exception("Environment variable ARTIFACTORY_USER not set.");
}
if (System.getenv('ARTIFACTORY_KEY') == null) {
throw new Exception("Environment variable ARTIFACTORY_KEY not set.");
}
}
}
}

//////////////////////////////////
// Shipkit Tasks
//////////////////////////////////

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") {
dependsOn checkGitHubToken
previousRevision = project.ext.'shipkit-auto-version.previous-tag'
githubToken = System.getenv("GITHUB_TOKEN")
repository = "linkedin/LiFT"
}

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

//////////////////////////////////
// Maven Central Config
//////////////////////////////////

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")
}
}
}
}

//////////////////////////////////
// Additional Release Tasks
//////////////////////////////////

task artifactoryPublishAll {
description = "Runs 'artifactoryPublish' tasks from all projects"
}

allprojects {
tasks.matching { it.name == "artifactoryPublish" }.all {
it.dependsOn verifyArtifactoryProperties
artifactoryPublishAll.dependsOn it
}
}
Loading

0 comments on commit 652fcda

Please sign in to comment.