diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..77edb2508 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,51 @@ +# +# 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 + pull_request: + branches: ['**'] + +jobs: + + build: + runs-on: ubuntu-latest + if: "! contains(toJSON(github.event.commits.*.message), '[skip ci]')" + + steps: + + - name: 1. 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: 2. Set up Java + uses: actions/setup-java@v1 + with: + java-version: 1.8 + + - name: 3. Perform build + run: ./gradlew build + + - name: 4. 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/coral' + && !contains(toJSON(github.event.commits.*.message), '[skip release]') + + run: ./gradlew githubRelease publishToSonatype closeAndReleaseStagingRepository + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + SONATYPE_USER: ${{secrets.SONATYPE_USER}} + SONATYPE_PWD: ${{secrets.SONATYPE_PWD}} + PGP_KEY: ${{secrets.PGP_KEY}} + PGP_PWD: ${{secrets.PGP_PWD}} \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index a2f733686..558181f3b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,9 +23,14 @@ branches: #Build and perform release (if needed) script: - # Print output every minute to avoid travis timeout + + # 1. Print output every minute to avoid travis timeout - while sleep 1m; do echo "=====[ $SECONDS seconds elapsed -- still running ]====="; done & - - ./gradlew build -s && ./gradlew ciPerformRelease -s - # Killing background sleep loop + + # 2. Run build (we're moving to GH Actions, this is just to compare build times Travis vs. GH Actions + - > + ./gradlew build + + # 3. Killing background sleep loop - kill %1 diff --git a/build.gradle b/build.gradle index 8d31be1a0..755111ed9 100644 --- a/build.gradle +++ b/build.gradle @@ -2,12 +2,27 @@ // Licensed under the BSD-2 Clause license. // See LICENSE in the project root for license information. +buildscript { + repositories { + jcenter() + maven { + url "https://plugins.gradle.org/m2/" + } + } + dependencies { + classpath "io.github.gradle-nexus:publish-plugin:1.0.0" + classpath "org.shipkit:shipkit-auto-version:1.1.1" + classpath "org.shipkit:shipkit-changelog:1.1.10" + } +} + plugins { id "com.diffplug.spotless" version "5.8.2" id 'com.github.johnrengelman.shadow' version '5.2.0' - id "org.shipkit.java" version "2.3.4" } +apply from: "gradle/shipkit.gradle" + configurations { provided } diff --git a/coral-hive/build.gradle b/coral-hive/build.gradle index 7739fb55a..37935f96a 100644 --- a/coral-hive/build.gradle +++ b/coral-hive/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'java' +apply from: "$rootDir/gradle/java-publication.gradle" apply plugin: 'antlr' dependencies { diff --git a/coral-pig/build.gradle b/coral-pig/build.gradle index 0dbef1842..2bb29b9a7 100644 --- a/coral-pig/build.gradle +++ b/coral-pig/build.gradle @@ -1,5 +1,4 @@ -apply plugin: 'java' -apply plugin: 'maven-publish' +apply from: "$rootDir/gradle/java-publication.gradle" dependencies { compile deps.'javax-annotation' diff --git a/coral-presto/build.gradle b/coral-presto/build.gradle index 67c9309fc..832acb8fb 100644 --- a/coral-presto/build.gradle +++ b/coral-presto/build.gradle @@ -1,4 +1,4 @@ -apply plugin: 'java' +apply from: "$rootDir/gradle/java-publication.gradle" dependencies { compile deps.'gson' diff --git a/coral-schema/build.gradle b/coral-schema/build.gradle index 58b48d5d7..38956ed29 100644 --- a/coral-schema/build.gradle +++ b/coral-schema/build.gradle @@ -1,5 +1,4 @@ -apply plugin: 'java' -apply plugin: 'maven-publish' +apply from: "$rootDir/gradle/java-publication.gradle" dependencies { compile deps.'slf4j-api' diff --git a/coral-spark-plan/build.gradle b/coral-spark-plan/build.gradle index 46ccd7863..7118269f0 100644 --- a/coral-spark-plan/build.gradle +++ b/coral-spark-plan/build.gradle @@ -1,5 +1,4 @@ -apply plugin:'java' -apply plugin: 'maven-publish' +apply from: "$rootDir/gradle/java-publication.gradle" dependencies { compile deps.'gson' diff --git a/coral-spark/build.gradle b/coral-spark/build.gradle index 5202d41ff..8eaacd20e 100644 --- a/coral-spark/build.gradle +++ b/coral-spark/build.gradle @@ -1,5 +1,4 @@ -apply plugin: 'java' -apply plugin: 'maven-publish' +apply from: "$rootDir/gradle/java-publication.gradle" dependencies { compile deps.'gson' diff --git a/gradle/java-publication.gradle b/gradle/java-publication.gradle new file mode 100644 index 000000000..fa40e2482 --- /dev/null +++ b/gradle/java-publication.gradle @@ -0,0 +1,96 @@ +apply plugin: "java" + +def licenseSpec = copySpec { + from project.rootDir + include "LICENSE" +} + +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 { + javaLibrary(MavenPublication) { + from components.java + artifact sourcesJar + artifact javadocJar + + artifactId = project.archivesBaseName + + pom { + name = artifactId + description = "A library for analyzing, processing, and rewriting views defined in the Hive Metastore, and sharing them across multiple execution engines" + + url = "https://github.com/linkedin/coral" + licenses { + license { + name = 'The MIT License' + url = 'https://github.com/linkedin/coral/blob/master/LICENSE' + distribution = 'repo' + } + } + developers { + [ + 'wmoustafa:Walaa Eldin Moustafa', + 'khaitranq:Khai Tranh', + 'funcheetah:Wenye Zhang', + 'shardulm94:Shardul Mahadik', + 'hotsushi:Sushant Raikar' + ].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/coral.git' + } + issueManagement { + url = 'https://github.com/linkedin/coral/issues' + system = 'GitHub issues' + } + ciManagement { + url = 'https://travis-ci.com/linkedin/coral' + 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("publishJavaLibraryPublicationToMavenLocal") + +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.javaLibrary + } +} diff --git a/gradle/shipkit.gradle b/gradle/shipkit.gradle index 5e5348eae..05c5c28d3 100644 --- a/gradle/shipkit.gradle +++ b/gradle/shipkit.gradle @@ -1,50 +1,31 @@ -shipkit { - gitHub.repository = "linkedin/coral" +//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 - gitHub.readOnlyAuthToken = "967ad570c37790a939" + "366590ca3035ed56b8d2ae" - - // The GitHub write token is required for committing release notes and bumping up project version - // Ensure that the release machine or Travis CI has this env variable exported - gitHub.writeAuthToken = System.getenv("GH_WRITE_TOKEN") - - git.releasableBranchRegex = "master|release/.+" - - team.developers = [ - 'wmoustafa:Walaa Eldin Moustafa', - 'khaitranq:Khai Tranh', - 'funcheetah:Wenye Zhang', - 'shardulm94:Shardul Mahadik', - 'hotsushi:Sushant Raikar' - ] +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/coral" } -allprojects { - plugins.withId("org.shipkit.bintray") { +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") +} - //Bintray configuration is handled by JFrog Bintray Gradle Plugin - //For reference see the official documentation: https://github.com/bintray/gradle-bintray-plugin - bintray { - // The Bintray API token is required to publish artifacts to Bintray - // Ensure that the release machine or Travis CI has this env variable exported - key = System.getenv("BINTRAY_API_KEY") - pkg { - repo = 'maven' - user = 'lnkd-apa' - userOrg = 'linkedin' - name = 'coral' - licenses = ['BSD 2-Clause'] - labels = [ - 'coral', - 'sql', - 'presto', - 'spark', - 'hive', - 'views' - ] - vcsUrl = "https://github.com/linkedin/coral.git" - description = "A library for analyzing, processing, and rewriting views defined in the Hive Metastore, and sharing them across multiple execution engines" +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") } - publish = true } } } diff --git a/version.properties b/version.properties index d3bffe6bb..7876fce23 100644 --- a/version.properties +++ b/version.properties @@ -1,4 +1,3 @@ -#Version of the produced binaries. This file is intended to be checked-in. -#It will be automatically bumped by release automation. -version=1.0.33 -previousVersion=1.0.32 +# Version of the produced binaries. +# The version is inferred by shipkit-auto-version Gradle plugin (https://github.com/shipkit/shipkit-auto-version) +version=1.0.* \ No newline at end of file