Skip to content

Commit

Permalink
Setup publishing to LI artifactory (#80)
Browse files Browse the repository at this point in the history
* Setup publishing to LI artifactory

Bintray is going to be deprecated soon, prepare to switch to our artifactory instance.

* update docs
  • Loading branch information
John Plaisted authored Feb 26, 2021
1 parent 6833bb3 commit 2cffc17
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/actions/release/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ runs:
shell: bash
- run: echo Got version ${{ steps.get-tag.outputs.tag }}
shell: bash
- run: ./gradlew build publishToMavenLocal bintrayUploadAll -Pbintray.dryRun
- run: ./gradlew build publishToMavenLocal bintrayUploadAll artifactoryPublish -Pbintray.dryRun -Partifactory.dryRun
shell: bash
- run: ./gradlew ciPerformRelease
shell: bash
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ buildscript {
classpath 'com.linkedin.pegasus:gradle-plugins:' + pegasusVersion
classpath 'org.springframework.boot:spring-boot-gradle-plugin:2.1.2.RELEASE'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.+'
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4+"
classpath "org.shipkit:shipkit-auto-version:1.1.1"
classpath "org.shipkit:shipkit-changelog:1.1.1"
}
Expand Down
10 changes: 5 additions & 5 deletions docs/how/releases/continuous-releases.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# GMA Continuous Releases

We create [GitHub releases](https://github.com/linkedin/datahub-gma/releases) and publish our artifacts to
[Bintray](https://bintray.com/linkedin/maven/datahub-gma).
[LinkedIn's open source artifactory](https://linkedin.jfrog.io/artifactory).

We use [shipkit-auto-version](https://github.com/shipkit/shipkit-auto-version),
[shipkit-changelog](https://github.com/shipkit/shipkit-changelog), and shipkit-github-release (part of
Expand Down Expand Up @@ -29,8 +29,8 @@ We use shipkit changelog to create the release notes of each version. See
## Automatic Publishing

Automation is done with a [GitHub workflow](../../.github/workflows/gh-version.yml) that will create the GitHub release
and then publish to bintray for every push of the `main` branch.
and then publish to artifactory for every push of the `main` branch.

This workflow relies on the `BINTRAY_USER` and `BINTRAY_KEY` secrets, which should be a user on Bintray with permissions
to our project, and their api key, respectively. The exact user and key don't really matter, it is very easy to change
in the event that we need to.
This workflow relies on the `ARTIFACTORY_USER` and `ARTIFACTORY_KEY` secrets, which should be a user on Artifactory with
permissions to our project, and their encoded password, respectively. The exact user and key don't really matter, it is
very easy to change in the event that we need to.
13 changes: 12 additions & 1 deletion gradle/ci-release.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,20 @@ allprojects {
}
}

task artifactoryPublishAll {
description = "Runs 'artifactoryPublish' tasks from all projects"
mustRunAfter "githubRelease" // github release is easier to rollback so we run it first
}

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

task ciPerformRelease {
description = "Performs the release, intended to be ran on CI"
dependsOn "githubRelease", "bintrayUploadAll"
dependsOn "githubRelease", "bintrayUploadAll", "artifactoryPublishAll"
}

task getVersion() {
Expand Down
50 changes: 50 additions & 0 deletions gradle/java-publishing.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,13 @@ if (project.hasProperty('disableShipkit')) {
}

apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'com.jfrog.bintray'

////////////////////////////////////////////////
// Artifact setup
////////////////////////////////////////////////

tasks.withType(Jar) {
from "$rootDir/LICENSE"
from "$rootDir/NOTICE"
Expand Down Expand Up @@ -82,6 +87,51 @@ publishing {
}
}

////////////////////////////////////////////////
// Artifactory publishing
////////////////////////////////////////////////

artifactory {
contextUrl = 'https://linkedin.jfrog.io/artifactory'
publish {
repository {
repoKey = 'datahub-gma'
username = System.getenv('ARTIFACTORY_USER')
password = System.getenv('ARTIFACTORY_KEY')
maven = true
}

defaults {
if (project.ext.has('publications')) {
publications(*project.ext.publications)
} else {
publications('jar')

if (plugins.hasPlugin('pegasus')) {
publications('jar', 'dataTemplate')
}
}
}
}

resolve {
repository {
repoKey = 'release'
username = System.getenv('ARTIFACTORY_USER')
password = System.getenv('ARTIFACTORY_KEY')
maven = true
}
}
}

artifactoryPublish {
skip = project.hasProperty('artifactory.dryRun')
}

////////////////////////////////////////////////
// Bintray publishing TODO remove
////////////////////////////////////////////////

bintray {
user = System.getenv('BINTRAY_USER')
key = System.getenv('BINTRAY_KEY')
Expand Down

0 comments on commit 2cffc17

Please sign in to comment.