Skip to content

Commit 652fcda

Browse files
Upgrade Shipkit and Gradle, and move off JCenter (#8)
* 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
1 parent 5d5c758 commit 652fcda

File tree

10 files changed

+325
-109
lines changed

10 files changed

+325
-109
lines changed

.github/workflows/ci.yml

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
# CI build that assembles artifacts and runs tests.
2+
# If validation is successful this workflow releases from the main dev branch.
3+
#
4+
# - skipping CI: add [skip ci] to the commit message
5+
# - skipping release: add [skip release] to the commit message
6+
7+
name: CI
8+
9+
on:
10+
push:
11+
branches: ['main']
12+
tags-ignore: [v*] # release tags are autogenerated after a successful CI, no need to run CI against them
13+
paths-ignore:
14+
- 'docs/**'
15+
- '**.md'
16+
pull_request:
17+
branches: ['**']
18+
19+
jobs:
20+
build:
21+
runs-on: ubuntu-latest
22+
strategy:
23+
matrix:
24+
include:
25+
- scala-version: 2.11.8
26+
spark-version: 2.3.0
27+
- scala-version: 2.11.8
28+
spark-version: 2.4.3
29+
- scala-version: 2.12.11
30+
spark-version: 2.4.3
31+
if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')"
32+
steps:
33+
- name: Check out code
34+
# https://github.com/actions/checkout
35+
uses: actions/checkout@v2
36+
with:
37+
# Needed to get all tags. Refer https://github.com/shipkit/shipkit-changelog#fetch-depth-on-ci
38+
fetch-depth: '0'
39+
- name: Setup Java
40+
uses: actions/setup-java@v1
41+
with:
42+
java-version: 1.8
43+
- name: Build and test code, and test artifact publishing
44+
run: ./gradlew build publishToMavenLocal artifactoryPublishAll -s -Partifactory.dryRun -PscalaVersion=$SCALA_VERSION -PsparkVersion=$SPARK_VERSION
45+
env:
46+
SCALA_VERSION: ${{ matrix.scala-version }}
47+
SPARK_VERSION: ${{ matrix.spark-version }}
48+
- name: Release to Maven Central and LinkedIn Artifactory
49+
# Release job, only for pushes to the main development branch
50+
if: github.event_name == 'push'
51+
&& github.ref == 'refs/heads/main'
52+
&& github.repository == 'linkedin/LiFT'
53+
&& !contains(toJSON(github.event.commits.*.message), '[skip release]')
54+
run: ./gradlew publishToSonatype closeAndReleaseStagingRepository artifactoryPublishAll -s -PscalaVersion=$SCALA_VERSION -PsparkVersion=$SPARK_VERSION
55+
env:
56+
SCALA_VERSION: ${{ matrix.scala-version }}
57+
SPARK_VERSION: ${{ matrix.spark-version }}
58+
SONATYPE_USER: ${{ secrets.SONATYPE_USER }}
59+
SONATYPE_PWD: ${{ secrets.SONATYPE_PWD }}
60+
PGP_KEY: ${{ secrets.PGP_KEY }}
61+
PGP_PWD: ${{ secrets.PGP_PWD }}
62+
ARTIFACTORY_USER: ${{ secrets.ARTIFACTORY_USER }}
63+
ARTIFACTORY_KEY: ${{ secrets.ARTIFACTORY_KEY }}
64+
github-release:
65+
runs-on: ubuntu-latest
66+
needs: build
67+
# Release job, only for pushes to the main development branch
68+
if: github.event_name == 'push'
69+
&& github.ref == 'refs/heads/main'
70+
&& github.repository == 'linkedin/LiFT'
71+
&& !contains(toJSON(github.event.commits.*.message), '[skip release]')
72+
steps:
73+
- name: Check out code
74+
# https://github.com/actions/checkout
75+
uses: actions/checkout@v2
76+
with:
77+
# Needed to get all tags. Refer https://github.com/shipkit/shipkit-changelog#fetch-depth-on-ci
78+
fetch-depth: '0'
79+
- name: Setup Java
80+
uses: actions/setup-java@v1
81+
with:
82+
java-version: 1.8
83+
- name: Release
84+
run: ./gradlew githubRelease -s
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.travis.yml

Lines changed: 0 additions & 48 deletions
This file was deleted.

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,11 @@ Tests typically run with the `test` task. If you want to force-run all tests, yo
8181
./gradlew cleanTest test --no-build-cache
8282
```
8383

84+
To force rebuild the library, you can use:
85+
```bash
86+
./gradlew clean build --no-build-cache
87+
```
88+
8489

8590
### Add a LiFT Dependency to Your Project
8691

build.gradle

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
1-
plugins {
2-
id "org.shipkit.java" version "2.3.4"
1+
buildscript {
2+
repositories {
3+
mavenLocal() // for local testing
4+
maven {
5+
url "https://plugins.gradle.org/m2/"
6+
}
7+
}
8+
dependencies {
9+
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.+"
10+
classpath "io.github.gradle-nexus:publish-plugin:1.+"
11+
classpath "org.shipkit:shipkit-auto-version:1.+"
12+
classpath "org.shipkit:shipkit-changelog:1.+"
13+
}
314
}
415

16+
apply from: "gradle/release.gradle"
17+
518
allprojects {
619
apply plugin: "eclipse"
720
apply plugin: "idea"
821

922
group = "com.linkedin.lift"
1023

1124
repositories {
12-
jcenter()
1325
mavenCentral()
1426
}
1527
}
28+
29+
task clean(type: Delete) {
30+
delete "build"
31+
}

gradle/java-publication.gradle

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
assert plugins.hasPlugin(JavaPlugin)
2+
3+
tasks.withType(Jar) {
4+
from "$rootDir/LICENSE"
5+
from "$rootDir/NOTICE"
6+
}
7+
8+
// Auxiliary jar files required by Maven module publications
9+
task sourcesJar(type: Jar, dependsOn: classes) {
10+
classifier 'sources'
11+
from sourceSets.main.allSource
12+
}
13+
14+
task javadocJar(type: Jar, dependsOn: javadoc) {
15+
classifier 'javadoc'
16+
from javadoc.destinationDir
17+
}
18+
19+
artifacts {
20+
archives sourcesJar
21+
archives javadocJar
22+
}
23+
24+
apply plugin: "maven-publish" // https://docs.gradle.org/current/userguide/publishing_maven.html
25+
publishing {
26+
publications {
27+
liftJar(MavenPublication) {
28+
from components.java
29+
artifact sourcesJar
30+
artifact javadocJar
31+
32+
artifactId = project.archivesBaseName
33+
34+
pom {
35+
name = artifactId
36+
description = "A Scala/Spark library that enables the measurement of fairness in large scale machine learning workflows."
37+
url = "https://github.com/linkedin/LiFT"
38+
licenses {
39+
license {
40+
name = 'BSD 2-CLAUSE'
41+
url = 'https://github.com/linkedin/LiFT/blob/master/LICENSE'
42+
distribution = 'repo'
43+
}
44+
}
45+
developers {
46+
[
47+
'sriramvasudevan:Sriram Vasudevan'
48+
].each { devData ->
49+
developer {
50+
def devInfo = devData.split(':')
51+
id = devInfo[0]
52+
name = devInfo[1]
53+
url = 'https://github.com/' + devInfo[0]
54+
roles = ["Core developer"]
55+
}
56+
}
57+
}
58+
scm {
59+
url = 'https://github.com/linkedin/LiFT.git'
60+
}
61+
issueManagement {
62+
url = 'https://github.com/linkedin/LiFT/issues'
63+
system = 'GitHub issues'
64+
}
65+
ciManagement {
66+
url = 'https://travis-ci.com/linkedin/LiFT'
67+
system = 'Travis CI'
68+
}
69+
}
70+
}
71+
}
72+
73+
//useful for testing - running "publish" will create artifacts/pom in a local dir
74+
repositories { maven { url = "$rootProject.buildDir/repo" } }
75+
}
76+
77+
//fleshes out problems with Maven pom generation when building
78+
tasks.build.dependsOn("publishLiftJarPublicationToMavenLocal")
79+
80+
apply plugin: 'signing' //https://docs.gradle.org/current/userguide/signing_plugin.html
81+
signing {
82+
if (System.getenv("PGP_KEY")) {
83+
useInMemoryPgpKeys(System.getenv("PGP_KEY"), System.getenv("PGP_PWD"))
84+
sign publishing.publications.liftJar
85+
}
86+
}
87+
88+
//////////////////////////////////
89+
// LinkedIn Artifactory Config
90+
//////////////////////////////////
91+
92+
apply plugin: "com.jfrog.artifactory" //https://www.jfrog.com/confluence/display/rtf/gradle+artifactory+plugin
93+
artifactory {
94+
contextUrl = 'https://linkedin.jfrog.io/artifactory'
95+
publish {
96+
repository {
97+
repoKey = 'LiFT'
98+
username = System.getenv('ARTIFACTORY_USER')
99+
password = System.getenv('ARTIFACTORY_KEY')
100+
maven = true
101+
}
102+
103+
defaults {
104+
publications('liftJar')
105+
publishBuildInfo = true
106+
publishArtifacts = true
107+
publishPom = true
108+
publishIvy = true
109+
}
110+
}
111+
clientConfig.setIncludeEnvVars(false)
112+
}
113+
114+
artifactoryPublish {
115+
skip = project.hasProperty('artifactory.dryRun')
116+
}

gradle/release.gradle

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
//Plugin jars are added to the buildscript classpath in the root build.gradle file
2+
3+
//////////////////////////////////
4+
// Token Verification Tasks
5+
//////////////////////////////////
6+
7+
task checkGitHubToken {
8+
doFirst {
9+
if (System.getenv("GITHUB_TOKEN") == null) {
10+
throw new Exception("Environment variable GITHUB_TOKEN not set.");
11+
}
12+
println "Using repository " + System.getenv("GITHUB_REPOSITORY")
13+
}
14+
}
15+
16+
task verifyArtifactoryProperties {
17+
doFirst {
18+
if (!project.hasProperty('artifactory.dryRun')) {
19+
if (System.getenv('ARTIFACTORY_USER') == null) {
20+
throw new Exception("Environment variable ARTIFACTORY_USER not set.");
21+
}
22+
if (System.getenv('ARTIFACTORY_KEY') == null) {
23+
throw new Exception("Environment variable ARTIFACTORY_KEY not set.");
24+
}
25+
}
26+
}
27+
}
28+
29+
//////////////////////////////////
30+
// Shipkit Tasks
31+
//////////////////////////////////
32+
33+
apply plugin: "org.shipkit.shipkit-auto-version" //https://github.com/shipkit/shipkit-auto-version
34+
35+
apply plugin: "org.shipkit.shipkit-changelog" //https://github.com/shipkit/shipkit-changelog
36+
tasks.named("generateChangelog") {
37+
dependsOn checkGitHubToken
38+
previousRevision = project.ext.'shipkit-auto-version.previous-tag'
39+
githubToken = System.getenv("GITHUB_TOKEN")
40+
repository = "linkedin/LiFT"
41+
}
42+
43+
apply plugin: "org.shipkit.shipkit-github-release" //https://github.com/shipkit/shipkit-changelog
44+
tasks.named("githubRelease") {
45+
def genTask = tasks.named("generateChangelog").get()
46+
dependsOn genTask
47+
dependsOn checkGitHubToken
48+
repository = genTask.repository
49+
changelog = genTask.outputFile
50+
githubToken = System.getenv("GITHUB_TOKEN")
51+
newTagRevision = System.getenv("GITHUB_SHA")
52+
}
53+
54+
//////////////////////////////////
55+
// Maven Central Config
56+
//////////////////////////////////
57+
58+
apply plugin: "io.github.gradle-nexus.publish-plugin" //https://github.com/gradle-nexus/publish-plugin/
59+
nexusPublishing {
60+
repositories {
61+
if (System.getenv("SONATYPE_PWD")) {
62+
sonatype {
63+
username = System.getenv("SONATYPE_USER")
64+
password = System.getenv("SONATYPE_PWD")
65+
}
66+
}
67+
}
68+
}
69+
70+
//////////////////////////////////
71+
// Additional Release Tasks
72+
//////////////////////////////////
73+
74+
task artifactoryPublishAll {
75+
description = "Runs 'artifactoryPublish' tasks from all projects"
76+
}
77+
78+
allprojects {
79+
tasks.matching { it.name == "artifactoryPublish" }.all {
80+
it.dependsOn verifyArtifactoryProperties
81+
artifactoryPublishAll.dependsOn it
82+
}
83+
}

0 commit comments

Comments
 (0)