Skip to content

Commit

Permalink
Release automation 2.0 (#52)
Browse files Browse the repository at this point in the history
Implemented migrations:
- Bintray -> Sonatype Nexus
- Travis -> GH Actions
- Shipkit 2.0 -> Shipkit 3.0 (new plugins)

Benefits:
- enables concurrent releases
- migrates off discontinued tech
- eliminates version bump commits

Co-authored-by: Walaa Eldin Moustafa <[email protected]>
  • Loading branch information
mockitoguy and wmoustafa authored Mar 22, 2021
1 parent b655721 commit 636fb8c
Show file tree
Hide file tree
Showing 12 changed files with 203 additions and 60 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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}}
11 changes: 8 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

17 changes: 16 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion coral-hive/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apply plugin: 'java'
apply from: "$rootDir/gradle/java-publication.gradle"
apply plugin: 'antlr'

dependencies {
Expand Down
3 changes: 1 addition & 2 deletions coral-pig/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
apply plugin: 'java'
apply plugin: 'maven-publish'
apply from: "$rootDir/gradle/java-publication.gradle"

dependencies {
compile deps.'javax-annotation'
Expand Down
2 changes: 1 addition & 1 deletion coral-presto/build.gradle
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
apply plugin: 'java'
apply from: "$rootDir/gradle/java-publication.gradle"

dependencies {
compile deps.'gson'
Expand Down
3 changes: 1 addition & 2 deletions coral-schema/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
apply plugin: 'java'
apply plugin: 'maven-publish'
apply from: "$rootDir/gradle/java-publication.gradle"

dependencies {
compile deps.'slf4j-api'
Expand Down
3 changes: 1 addition & 2 deletions coral-spark-plan/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
apply plugin:'java'
apply plugin: 'maven-publish'
apply from: "$rootDir/gradle/java-publication.gradle"

dependencies {
compile deps.'gson'
Expand Down
3 changes: 1 addition & 2 deletions coral-spark/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
apply plugin: 'java'
apply plugin: 'maven-publish'
apply from: "$rootDir/gradle/java-publication.gradle"

dependencies {
compile deps.'gson'
Expand Down
96 changes: 96 additions & 0 deletions gradle/java-publication.gradle
Original file line number Diff line number Diff line change
@@ -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
}
}
65 changes: 23 additions & 42 deletions gradle/shipkit.gradle
Original file line number Diff line number Diff line change
@@ -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
}
}
}
7 changes: 3 additions & 4 deletions version.properties
Original file line number Diff line number Diff line change
@@ -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.*

0 comments on commit 636fb8c

Please sign in to comment.