Skip to content

Commit f781ed8

Browse files
Move from Bintray/Artifactory to OSSRH (#34)
1 parent 7a09bf9 commit f781ed8

File tree

3 files changed

+42
-57
lines changed

3 files changed

+42
-57
lines changed

RELEASE.md

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Releasing OpenTelemetry Java Contrib Artifacts
22

3-
This project currently has two gradle tasks capable of preparing and releasing artifacts: `mavenPublish`
4-
and `ossSnapshot`. In order for you to register your contributed project to be published by these commands,
5-
you must apply the provided publish script plugin in your subproject's gradle file:
3+
This project currently has three gradle tasks capable of preparing and releasing artifacts: `mavenPublish`,
4+
`ossSnapshot`, and `otelRelease`. In order for you to register your contributed project to be published by
5+
these commands, you must apply the provided publish script plugin in your subproject's gradle file:
66

77
```groovy
88
apply from: project.publish
@@ -33,18 +33,20 @@ your machine. The ability to publish to a stable remote repository like Maven Ce
3333

3434
## `./gradlew ossSnapshot`
3535

36-
This task will invoke the [Artifactory Plugin](https://www.jfrog.com/confluence/display/JFROG/Gradle+Artifactory+Plugin)
37-
and publish all applicable snapshot artifacts to https://oss.jfrog.org/artifactory/oss-snapshot-local. It's important
36+
This task will invoke the [Gradle Nexus Publish Plugin](https://github.com/gradle-nexus/publish-plugin)
37+
and publish all applicable snapshot artifacts to https://oss.sonatype.org/content/repositories/snapshots. It's important
3838
to note that these snapshot releases are often from unstable development states and should generally not be used in
3939
production environments.
4040

41-
This task requires an account and API key for the OpenTelemetry Bintray organization. If you have been provided access
42-
and configured your key, please set the required environment variables detailed in the publish script plugin.
41+
This task requires an account and password for Sonatype's OSSRH with `io.opentelemetry` group permissions. If you have been
42+
provided access please set the required gradle properties detailed in the publish script plugin.
4343

4444
## `./gradlew otelRelease`
4545

46-
This task will invoke the [Bintray Plugin](https://github.com/bintray/gradle-bintray-plugin)
47-
and publish all applicable snapshot artifacts to https://dl.bintray.com/open-telemetry/maven/io/opentelemetry/contrib/,
48-
assuming the current version is not a snapshot. Syncing with Maven Central is not performed at this time.
46+
This task will also invoke the [Gradle Nexus Publish Plugin](https://github.com/gradle-nexus/publish-plugin)
47+
and publish all applicable artifacts to a new staging repository at https://oss.sonatype.org/#stagingRepositories before
48+
closing it for manual release through the Nexus UI. Releasing the repository will initiate automatic syncing with
49+
Maven Central.
4950

50-
Like `ossSnapshot`, this task requires an account and API key for the OpenTelemetry Bintray organization.
51+
Like `ossSnapshot`, this task requires an account and permissions for Sonatype OSSRH, in addition to a PGP key registered
52+
with a public keyserver.

build.gradle

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
plugins {
22
id 'com.diffplug.spotless' version '5.1.1'
33
id "com.github.johnrengelman.shadow" version "6.0.0" apply false
4-
id "com.jfrog.artifactory" version "4.17.2" apply false
5-
id 'com.jfrog.bintray' version '1.8.5' apply false
4+
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
65
}
76

87
description = 'OpenTelemetry Contrib libraries and utilities for the JVM'
@@ -37,3 +36,11 @@ task integrationTest {
3736
}
3837
}
3938
integrationTest.finalizedBy allprojects.test
39+
40+
// At this time authentication relies on sonatypeUsername and sonatypePassword project properties or
41+
// ORG_GRADLE_PROJECT_sonatypeUsername and ORG_GRADLE_PROJECT_sonatypePassword environment variables.
42+
nexusPublishing {
43+
repositories {
44+
sonatype()
45+
}
46+
}

gradle/publish.gradle

Lines changed: 20 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
apply plugin: 'maven-publish'
2-
apply plugin: 'com.jfrog.artifactory'
3-
apply plugin: 'com.jfrog.bintray'
2+
apply plugin: 'signing'
43

54
publishing {
65
repositories {
@@ -36,8 +35,8 @@ publishing {
3635
developers {
3736
developer {
3837
id = 'opentelemetry'
39-
name = 'OpenTelemetry Gitter'
40-
url = 'https://gitter.im/open-telemetry/community'
38+
name = 'OpenTelemetry'
39+
url = "https://github.com/open-telemetry/opentelemetry-java-contrib/issues"
4140
}
4241
}
4342

@@ -78,52 +77,29 @@ task mavenPublish {
7877
}
7978
}
8079

81-
artifactory {
82-
contextUrl = 'https://oss.jfrog.org'
83-
publish {
84-
repository {
85-
repoKey = 'oss-snapshot-local'
86-
username = System.getenv('BINTRAY_USER')
87-
password = System.getenv('BINTRAY_API_KEY')
80+
task ossSnapshot {
81+
if (version.toString().endsWith("-SNAPSHOT")) {
82+
it.finalizedBy tasks.publishToSonatype
83+
} else {
84+
it.doFirst {
85+
println "ossSnapshot: ${version} isn't a snapshot. Not releasing."
8886
}
8987
}
9088
}
9189

92-
bintray {
93-
user = System.getenv('BINTRAY_USER')
94-
key = System.getenv('BINTRAY_API_KEY')
95-
publications = ['maven']
96-
publish = true
97-
98-
pkg {
99-
repo = 'maven'
100-
name = 'opentelemetry-java-contrib'
101-
userOrg = 'open-telemetry'
102-
licenses = ['Apache-2.0']
103-
vcsUrl = 'https://github.com/open-telemetry/opentelemetry-java-contrib.git'
104-
105-
githubRepo = 'open-telemetry/opentelemetry-java-contrib'
106-
107-
version {
108-
name = project.version
109-
gpg {
110-
sign = true
111-
}
90+
task otelRelease {
91+
if (!version.toString().endsWith("-SNAPSHOT")) {
92+
// closeSonatypeStagingRepository is a dynamically registered task and cannot be referenced directly
93+
it.finalizedBy "publishToSonatype", rootProject.tasks.named("closeSonatypeStagingRepository")
94+
} else {
95+
it.doFirst {
96+
println "otelRelease: ${version} is a snapshot. Not releasing."
11297
}
11398
}
11499
}
115100

116-
task ossSnapshot {
117-
artifactoryPublish {
118-
enabled = version.toString().contains('SNAPSHOT')
119-
publications('maven')
120-
}
121-
finalizedBy artifactoryPublish
122-
}
123-
124-
task otelRelease {
125-
bintrayUpload {
126-
enabled = !version.toString().contains('SNAPSHOT')
127-
}
128-
finalizedBy bintrayUpload
101+
// At this time signing depends on properly configured gradle properties for registered public key:
102+
// https://docs.gradle.org/current/userguide/signing_plugin.html#sec:signatory_credentials.
103+
signing {
104+
sign publishing.publications.maven
129105
}

0 commit comments

Comments
 (0)