Artifactory and bintray publish (#403)

* Artifactory and bintray publish

* Delegate version management to Nebula

* Proposal of new release process

* New CI jobs for releasing

* Fix nebula versioning

* Polish

* Fix CI

* Publish snapshot from master must depend on test_8

* Fix repo name

* Restore version file creation

* Use correct env variable for Bintray credentials

Co-authored-by: Trask Stalnaker <trask.stalnaker@gmail.com>
This commit is contained in:
Nikita Salnikov-Tarnovski 2020-06-09 07:56:12 +03:00 committed by GitHub
parent f13a9c4932
commit c248f140aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 248 additions and 121 deletions

View File

@ -200,15 +200,43 @@ jobs:
name: Publish master to Artifactory name: Publish master to Artifactory
command: | command: |
./gradlew \ ./gradlew \
-PbintrayUser=${BINTRAY_USER} \
-PbintrayApiKey=${BINTRAY_API_KEY} \
-PbuildInfo.build.number=${CIRCLE_BUILD_NUM} \ -PbuildInfo.build.number=${CIRCLE_BUILD_NUM} \
artifactoryPublish --max-workers=1 --build-cache --stacktrace --no-daemon snapshot --max-workers=1 --build-cache --stacktrace --no-daemon
publish_master: publish_master:
<<: *publish <<: *publish
publish_tag:
<<: *publish release:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: .
- restore_cache:
<<: *cache_keys
- run: ./gradlew -Prelease.useLastTag=true final
patch_release:
<<: *defaults
steps:
- checkout
- run: |
if [[ $(git tag --points-at HEAD | grep "^v") ]]; then
echo "Don't make patch release on commit which already has version tag"
circleci-agent step halt
fi
- attach_workspace:
at: .
- restore_cache:
<<: *cache_keys
- run: ./gradlew -Prelease.scope=patch final
workflows: workflows:
version: 2 version: 2
@ -218,7 +246,6 @@ workflows:
filters: filters:
tags: tags:
only: /.*/ only: /.*/
- test_7: - test_7:
requires: requires:
- build - build
@ -237,60 +264,18 @@ workflows:
filters: filters:
tags: tags:
only: /.*/ only: /.*/
# - test_ibm8:
# requires:
# - build
# filters:
# tags:
# only: /.*/
# - test_zulu8:
# requires:
# - build
# filters:
# tags:
# only: /.*/
- test_11: - test_11:
requires: requires:
- build - build
filters: filters:
tags: tags:
only: /.*/ only: /.*/
# - test_zulu11:
# requires:
# - build
# filters:
# tags:
# only: /.*/
# - test_12:
# requires:
# - build
# filters:
# tags:
# only: /.*/
# - test_13:
# requires:
# - build
# filters:
# tags:
# only: /.*/
# - test_zulu13:
# requires:
# - build
# filters:
# tags:
# only: /.*/
- test_14: - test_14:
requires: requires:
- build - build
filters: filters:
tags: tags:
only: /.*/ only: /.*/
# - test_zulu14:
# requires:
# - build
# filters:
# tags:
# only: /.*/
- check: - check:
requires: requires:
@ -309,17 +294,10 @@ workflows:
- publish_master: - publish_master:
requires: requires:
- test_7 - test_7
# - test_8 - test_8
- test_latest - test_latest
# - test_ibm8
# - test_zulu8
- test_11 - test_11
# - test_zulu11
# - test_12
# - test_13
# - test_zulu13
- test_14 - test_14
# - test_zulu14
- check - check
filters: filters:
branches: branches:
@ -327,26 +305,6 @@ workflows:
tags: tags:
ignore: /.*/ ignore: /.*/
- publish_tag:
requires:
- test_7
# - test_8
- test_latest
# - test_ibm8
# - test_zulu8
- test_11
# - test_zulu11
# - test_12
# - test_13
# - test_zulu13
- test_14
# - test_zulu14
- check
filters:
branches:
ignore: /.*/
tags:
only: /^v.*/
nightly_snapshot: nightly_snapshot:
triggers: triggers:
- schedule: - schedule:
@ -356,4 +314,65 @@ workflows:
only: only:
- depends-on-otel-java-snapshot - depends-on-otel-java-snapshot
jobs: jobs:
- test_8 - test_11
release:
jobs:
- release:
filters:
branches:
ignore: /.*/
tags:
# Only for major and minor releases
only: /^v.*\.0$/
patch_release:
jobs:
- build:
filters:
branches:
only: /\d+\.\d+\.x$/
- test_7:
filters:
branches:
only: /\d+\.\d+\.x$/
requires:
- build
- test_8:
filters:
branches:
only: /\d+\.\d+\.x$/
requires:
- build
- test_11:
filters:
branches:
only: /\d+\.\d+\.x$/
requires:
- build
- test_14:
filters:
branches:
only: /\d+\.\d+\.x$/
requires:
- build
- check:
filters:
branches:
only: /\d+\.\d+\.x$/
requires:
- build
- muzzle:
filters:
branches:
only: /\d+\.\d+\.x$/
requires:
- build
- patch_release:
requires:
- test_7
- test_11
- test_14
- check
- muzzle
filters:
branches:
only: /\d+\.\d+\.x$/

2
.gitignore vendored
View File

@ -57,4 +57,4 @@ derby.log
hs_err_pid* hs_err_pid*
replay_pid* replay_pid*
!java-agent/benchmark/releases/*.jar !java-agent/benchmark/releases/*.jar

32
RELEASING.md Normal file
View File

@ -0,0 +1,32 @@
# Versioning and releasing
OpenTelemetry Auto-Instrumentation for Java uses [SemVer standard](https://semver.org) for versioning of its artifacts.
Instead of manually specifying project version (and by extension the version of built artifacts)
in gradle build scripts, we use [nebula-release-plugin](https://github.com/nebula-plugins/nebula-release-plugin)
to calculate the current version based on git tags. This plugin looks for the latest tag of the form
`vX.Y.Z` on the current branch and calculates the current project version as `vX.Y.(Z+1)-SNAPSHOT`.
## Snapshot builds
Every successful CI build of the master branch automatically executes `./gradlew snapshot` as the last task.
This signals Nebula plugin to build and publish to JFrog OSS repository next _minor_ release version.
This means version `vX.(Y+1).0-SNAPSHOT`.
## Public releases
All major and minor public releases are initiated by creating a git tag with a version to be released.
Do the following:
- Checkout a branch that you want to release.
- Tag a commit on which you want to base the release by executing `git tag vX.Y.0` with the expected version string.
- Push new tag to upstream repo.
On new tag creation a CI will start a new release build.
It will do the following:
- Checkout requested tag.
- Run `./gradlew -Prelease.useLastTag=true final`.
This signals Nebula plugin to build `X.Y.0` version and to publish it to [Bintray repository](https://bintray.com/open-telemetry/maven).
## Patch releases
Whenever a fix is needed to any older branch, a PR should be made into the corresponding maintenance branch.
When that PR is merge, CI will notice the new commit into maintenance branch and will initiate a new build for this.
That build, after usual building and checking, will run `./gradlew -Prelease.scope=patch final`.
This will signal Nebula plugin to build a new version `vX.Y.(Z+1)` and publish it to Bintray repo.

View File

@ -3,6 +3,7 @@ plugins {
} }
apply from: "${rootDir}/gradle/java.gradle" apply from: "${rootDir}/gradle/java.gradle"
apply from: "${rootDir}/gradle/publish.gradle"
dependencies { dependencies {
compile(deps.opentelemetryJaeger) { compile(deps.opentelemetryJaeger) {

View File

@ -3,6 +3,7 @@ plugins {
} }
apply from: "${rootDir}/gradle/java.gradle" apply from: "${rootDir}/gradle/java.gradle"
apply from: "${rootDir}/gradle/publish.gradle"
dependencies { dependencies {
compileOnly deps.opentelemetrySdk compileOnly deps.opentelemetrySdk

View File

@ -3,6 +3,7 @@ plugins {
} }
apply from: "${rootDir}/gradle/java.gradle" apply from: "${rootDir}/gradle/java.gradle"
apply from: "${rootDir}/gradle/publish.gradle"
dependencies { dependencies {
compile(deps.opentelemetryOtlp) { compile(deps.opentelemetryOtlp) {

View File

@ -29,6 +29,7 @@ dependencies {
compile("com.google.guava", "guava", "20.0") compile("com.google.guava", "guava", "20.0")
compile("org.ow2.asm", "asm", "7.0-beta") compile("org.ow2.asm", "asm", "7.0-beta")
compile("org.ow2.asm", "asm-tree", "7.0-beta") compile("org.ow2.asm", "asm-tree", "7.0-beta")
compile("org.apache.httpcomponents:httpclient:4.5.10")
testCompile("org.spockframework", "spock-core", "1.3-groovy-2.5") testCompile("org.spockframework", "spock-core", "1.3-groovy-2.5")
testCompile("org.codehaus.groovy", "groovy-all", "2.5.8") testCompile("org.codehaus.groovy", "groovy-all", "2.5.8")

View File

@ -35,6 +35,8 @@ java {
targetCompatibility = JavaVersion.toVersion(project.ext.release) targetCompatibility = JavaVersion.toVersion(project.ext.release)
// See https://docs.gradle.org/current/userguide/upgrading_version_5.html, Automatic target JVM version // See https://docs.gradle.org/current/userguide/upgrading_version_5.html, Automatic target JVM version
disableAutoTargetJvm() disableAutoTargetJvm()
withJavadocJar()
withSourcesJar()
} }
sourceSets { sourceSets {
@ -156,22 +158,6 @@ javadoc {
} }
} }
tasks.register("sourceJar", Jar) {
from sourceSets.main.allJava
classifier = 'sources'
}
tasks.register("javaDocJar", Jar) {
from javadoc.destinationDir
classifier = 'javadoc'
dependsOn javadoc
}
artifacts {
archives sourceJar
archives javaDocJar
}
project.afterEvaluate { project.afterEvaluate {
if (project.plugins.hasPlugin('org.unbroken-dome.test-sets') && configurations.hasProperty("latestDepTestRuntime")) { if (project.plugins.hasPlugin('org.unbroken-dome.test-sets') && configurations.hasProperty("latestDepTestRuntime")) {
tasks.withType(Test).configureEach { tasks.withType(Test).configureEach {
@ -184,22 +170,6 @@ project.afterEvaluate {
} }
} }
if (project.plugins.hasPlugin('com.github.johnrengelman.shadow')) {
// Remove the no-deps jar from the archives to prevent publication
configurations.archives.with {
artifacts.remove artifacts.find {
if (it.hasProperty("delegate")) {
it.delegate.archiveTask.is jar
} else {
it.archiveTask.is jar
}
}
}
artifacts {
archives shadowJar
}
}
if (project.hasProperty("removeJarVersionNumbers") && removeJarVersionNumbers) { if (project.hasProperty("removeJarVersionNumbers") && removeJarVersionNumbers) {
tasks.withType(AbstractArchiveTask).configureEach { tasks.withType(AbstractArchiveTask).configureEach {
version = null version = null

101
gradle/publish.gradle Normal file
View File

@ -0,0 +1,101 @@
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.artifactory'
apply plugin: 'com.jfrog.bintray'
publishing {
repositories {
maven {
url = "$rootDir/build/repo"
}
}
publications {
maven(MavenPublication) {
artifact javadocJar
artifact sourcesJar
artifact shadowJar
pom {
name = 'OpenTelemetry Instrumentation for Java'
packaging = 'jar'
url = 'https://github.com/open-telemetry/opentelemetry-java-instrumentation'
licenses {
license {
name = 'The Apache License, Version 2.0'
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id = 'opentelemetry'
name = 'OpenTelemetry Gitter'
url = 'https://gitter.im/open-telemetry/opentelemetry-java-instrumentation'
}
}
scm {
connection = 'scm:git:git@github.com:open-telemetry/opentelemetry-java-instrumentation.git'
developerConnection = 'scm:git:git@github.com:open-telemetry/opentelemetry-java-instrumentation.git'
url = 'git@github.com:open-telemetry/opentelemetry-auto-instr-java.git'
}
afterEvaluate {
// description is not available until evaluated.
description = project.description
}
}
}
}
}
bintray {
user = System.getenv('BINTRAY_USER')
key = System.getenv('BINTRAY_API_KEY')
publications = ['maven']
publish = true
pkg {
repo = 'maven'
name = 'opentelemetry-java-instrumentation'
licenses = ['Apache-2.0']
websiteUrl = 'https://github.com/open-telemetry/opentelemetry-java-instrumentation'
issueTrackerUrl = 'https://github.com/open-telemetry/opentelemetry-java-instrumentation/issues'
vcsUrl = 'https://github.com/open-telemetry/opentelemetry-java-instrumentation.git'
userOrg = 'open-telemetry'
githubRepo = 'open-telemetry/opentelemetry-java-instrumentation'
version {
name = project.version
released = new Date()
gpg {
sign = true
}
mavenCentralSync {
user = System.getenv("SONATYPE_USER")
password = System.getenv("SONATYPE_KEY")
}
}
}
}
bintrayUpload.enabled = !version.toString().contains('SNAPSHOT')
// Snapshot publishing.
artifactory {
contextUrl = 'https://oss.jfrog.org'
publish {
repository {
repoKey = 'oss-snapshot-local'
username = System.getenv("BINTRAY_USER")
password = System.getenv("BINTRAY_KEY")
}
}
}
artifactoryPublish {
publications ('maven')
}

View File

@ -10,7 +10,7 @@ def getGitHash = { ->
tasks.register("writeVersionNumberFile") { tasks.register("writeVersionNumberFile") {
def versionFile = file("${sourceSets.main.output.resourcesDir}/${project.name}.version") def versionFile = file("${sourceSets.main.output.resourcesDir}/${project.name}.version")
inputs.property "version", project.version inputs.property "version", project.version.toString()
outputs.file versionFile outputs.file versionFile
doFirst { doFirst {

View File

@ -6,6 +6,7 @@ description = 'opentelemetry-auto'
apply from: "${rootDir}/gradle/java.gradle" apply from: "${rootDir}/gradle/java.gradle"
apply from: "${rootDir}/gradle/version.gradle" apply from: "${rootDir}/gradle/version.gradle"
apply from: "${rootDir}/gradle/publish.gradle"
configurations { configurations {
shadowInclude shadowInclude
@ -23,8 +24,6 @@ processResources {
} }
jar { jar {
archiveClassifier = 'unbundled'
manifest { manifest {
attributes( attributes(
"Main-Class": "io.opentelemetry.auto.bootstrap.AgentBootstrap", "Main-Class": "io.opentelemetry.auto.bootstrap.AgentBootstrap",
@ -95,4 +94,4 @@ tasks.withType(Test).configureEach {
} }
dependsOn shadowJar dependsOn shadowJar
} }

View File

@ -198,7 +198,7 @@ public class AgentBootstrap {
try (final BufferedReader reader = try (final BufferedReader reader =
new BufferedReader( new BufferedReader(
new InputStreamReader( new InputStreamReader(
AgentBootstrap.class.getResourceAsStream("/java-agent.version"), AgentBootstrap.class.getResourceAsStream("/opentelemetry-auto.version"),
StandardCharsets.UTF_8))) { StandardCharsets.UTF_8))) {
for (int c = reader.read(); c != -1; c = reader.read()) { for (int c = reader.read(); c != -1; c = reader.read()) {

View File

@ -1,12 +1,11 @@
plugins { plugins {
id 'io.franzbecker.gradle-lombok' version '1.14' // Last to support Java 7 id 'io.franzbecker.gradle-lombok' version '1.14' // Last to support Java 7
id 'com.jfrog.artifactory' version '4.9.8' id "com.jfrog.artifactory" version "4.15.2" apply false
// ^ Last version to not have problems with NoSuchMethodError HttpClientBuilder.setPublicSuffixMatcher... id 'com.jfrog.bintray' version '1.8.5' apply false
// See also https://www.jfrog.com/jira/browse/GAP-317 id "nebula.release" version "15.0.1"
id 'com.jfrog.bintray' version '1.8.5' id 'org.unbroken-dome.test-sets' version '2.2.1'
id 'org.unbroken-dome.test-sets' version '3.0.1'
id 'com.github.ben-manes.versions' version '0.27.0' id 'com.github.ben-manes.versions' version '0.27.0'
// Not applying google java format by default because it gets confused by stray java build // Not applying google java format by default because it gets confused by stray java build
@ -20,11 +19,14 @@ plugins {
id "com.github.spotbugs" version "4.0.1" id "com.github.spotbugs" version "4.0.1"
} }
release {
defaultVersionStrategy = nebula.plugin.release.git.opinion.Strategies.SNAPSHOT
}
def isCI = System.getenv("CI") != null def isCI = System.getenv("CI") != null
allprojects { allprojects {
group = 'io.opentelemetry.auto' group = 'io.opentelemetry.auto'
version = '0.4.0-SNAPSHOT'
if (isCI) { if (isCI) {
buildDir = "${rootDir}/workspace/${projectDir.path.replace(rootDir.path, '')}/build/" buildDir = "${rootDir}/workspace/${projectDir.path.replace(rootDir.path, '')}/build/"