Skip to content

Commit 5fb0ace

Browse files
authored
3.x: Release to Sonatype directly (#7181)
* 3.x: Release to Sonatype directly * Update build.gradle * Update gradle.properties * Turn RS into compile dependency in POM * Fix the POM of the snapshot/artifactory upload
1 parent 0cb8978 commit 5fb0ace

File tree

4 files changed

+66
-122
lines changed

4 files changed

+66
-122
lines changed

Diff for: .github/workflows/gradle_release.yml

+9-5
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,11 @@ jobs:
1717
env:
1818
# Define secrets at https://github.com/ReactiveX/RxJava/settings/secrets/actions
1919
# ------------------------------------------------------------------------------
20-
bintrayUser: ${{ secrets.BINTRAY_USER }}
21-
bintrayKey: ${{ secrets.BINTRAY_KEY }}
22-
sonatypeUsername: ${{ secrets.SONATYPE_USER }}
23-
sonatypePassword: ${{ secrets.SONATYPE_PASSWORD }}
2420
JAVADOCS_TOKEN: ${{ secrets.JAVADOCS_TOKEN }}
21+
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_USERNAME: ${{ secrets.SONATYPE_USER }}
22+
ORG_GRADLE_PROJECT_SONATYPE_NEXUS_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
23+
ORG_GRADLE_PROJECT_SIGNING_PRIVATE_KEY: ${{ secrets.SIGNING_PRIVATE_KEY }}
24+
ORG_GRADLE_PROJECT_SIGNING_PASSWORD: ${{ secrets.SIGNING_PASSWORD }}
2525
# ------------------------------------------------------------------------------
2626
CI_BUILD_NUMBER: ${{ github.run_number }}
2727
steps:
@@ -43,8 +43,12 @@ jobs:
4343
- name: Extract version tag
4444
run: echo "BUILD_TAG=${GITHUB_REF:10}" >> $GITHUB_ENV
4545
- name: Build and Release
46-
run: ./gradlew -PreleaseMode=full -PbintrayUser="${bintrayUser}" -PbintrayKey="${bintrayKey}" -PsonatypeUsername="${sonatypeUsername}" -PsonatypePassword="${sonatypePassword}" build --stacktrace
46+
run: ./gradlew -PreleaseMode=full build --stacktrace --no-daemon
4747
- name: Upload to Codecov
4848
uses: codecov/codecov-action@v1
49+
- name: Upload release
50+
run: ./gradlew -PreleaseMode=full javadocCleanup uploadArchives --no-daemon --no-parallel
51+
- name: Publish release
52+
run: ./gradlew -PreleaseMode=full closeAndReleaseRepository --no-daemon --no-parallel
4953
- name: Push Javadocs
5054
run: ./push_javadoc.sh

Diff for: build.gradle

+34-115
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,14 @@ buildscript {
1313
ext.jacocoVersion = "0.8.4"
1414
ext.animalSnifferVersion = "1.5.2"
1515
ext.licenseVersion = "0.15.0"
16-
ext.bintrayVersion = "1.8.5"
1716
ext.jfrogExtractorVersion = "4.20.0"
1817
ext.bndVersion = "5.2.0"
1918
ext.checkstyleVersion = "8.26"
19+
ext.vanniktechPublishPlugin = "0.13.0"
2020

2121
// --------------------------------------
2222

2323
repositories {
24-
jcenter()
2524
mavenCentral()
2625
maven {
2726
url "https://plugins.gradle.org/m2/"
@@ -31,28 +30,27 @@ buildscript {
3130
classpath "ru.vyarus:gradle-animalsniffer-plugin:$animalSnifferVersion"
3231
classpath "gradle.plugin.com.hierynomus.gradle.plugins:license-gradle-plugin:$licenseVersion"
3332
classpath "me.champeau.gradle:jmh-gradle-plugin:$jmhGradleVersion"
34-
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:$bintrayVersion"
3533
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:$jfrogExtractorVersion"
3634
classpath "biz.aQute.bnd:biz.aQute.bnd.gradle:$bndVersion"
35+
classpath "com.vanniktech:gradle-maven-publish-plugin:$vanniktechPublishPlugin"
3736
}
3837
}
3938

4039
group = "io.reactivex.rxjava3"
4140
ext.githubProjectName = "rxjava"
4241

43-
version = project.properties["release.version"]
44-
4542
def releaseTag = System.getenv("BUILD_TAG");
4643
if (releaseTag != null && !releaseTag.isEmpty()) {
4744
if (releaseTag.startsWith("v")) {
4845
releaseTag = releaseTag.substring(1);
4946
}
50-
version = releaseTag;
51-
project.properties.put("release.version", releaseTag);
47+
project.setProperty("VERSION_NAME" , releaseTag);
5248

5349
println("Releasing with version " + version);
5450
}
5551

52+
version = project.properties["VERSION_NAME"]
53+
5654
description = "RxJava: Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM."
5755

5856
apply plugin: "java-library"
@@ -62,7 +60,6 @@ apply plugin: "ru.vyarus.animalsniffer"
6260
apply plugin: "maven"
6361
apply plugin: "me.champeau.gradle.jmh"
6462
apply plugin: "com.github.hierynomus.license"
65-
apply plugin: "com.jfrog.bintray"
6663
apply plugin: "com.jfrog.artifactory"
6764
apply plugin: "eclipse"
6865

@@ -116,21 +113,7 @@ animalsniffer {
116113
annotation = "io.reactivex.rxjava3.internal.util.SuppressAnimalSniffer"
117114
}
118115

119-
task sourcesJar(type: Jar, dependsOn: classes) {
120-
classifier = "sources"
121-
from sourceSets.main.allSource
122-
}
123-
124-
task javadocJar(type: Jar, dependsOn: javadoc) {
125-
classifier = "javadoc"
126-
from javadoc.destinationDir
127-
}
128-
129-
artifacts {
130-
archives jar
131-
archives sourcesJar
132-
archives javadocJar
133-
}
116+
apply plugin: 'maven'
134117

135118
apply plugin: 'biz.aQute.bnd.builder'
136119

@@ -154,61 +137,6 @@ license {
154137
excludes(["**/*.md", "**/*.txt"])
155138
}
156139

157-
apply plugin: "maven-publish"
158-
159-
install {
160-
repositories.mavenInstaller.pom.project {
161-
name "RxJava"
162-
description "Reactive Extensions for Java"
163-
url "https://github.com/ReactiveX/RxJava"
164-
licenses {
165-
license {
166-
name "The Apache Software License, Version 2.0"
167-
url "http://www.apache.org/licenses/LICENSE-2.0.txt"
168-
distribution "repo"
169-
}
170-
}
171-
developers {
172-
developer {
173-
id "akarnokd"
174-
name "David Karnok"
175-
176-
}
177-
}
178-
scm {
179-
connection "scm:git:[email protected]:ReactiveX/RxJava.git"
180-
url "scm:git:[email protected]:ReactiveX/RxJava.git"
181-
developerConnection "scm:git:[email protected]:ReactiveX/RxJava.git"
182-
}
183-
issueManagement {
184-
system "github"
185-
url "https://github.com/ReactiveX/RxJava/issues"
186-
}
187-
}
188-
}
189-
190-
publishing {
191-
publications {
192-
mavenJava(MavenPublication) {
193-
from components.java
194-
artifact (sourcesJar) {
195-
classifier = "sources"
196-
}
197-
}
198-
}
199-
}
200-
201-
// Reactive-Streams as compile dependency
202-
publishing.publications.all {
203-
pom.withXml {
204-
asNode().dependencies."*".findAll() {
205-
it.scope.text() == "runtime" && project.configurations.compile.allDependencies.find { dep ->
206-
dep.name == it.artifactId.text()
207-
}
208-
}.each { it.scope*.value = "compile"}
209-
}
210-
}
211-
212140
jmh {
213141
jmhVersion = jmhLibVersion
214142
humanOutputFile = null
@@ -312,12 +240,28 @@ checkstyle {
312240
toolVersion = checkstyleVersion
313241
}
314242

243+
apply from: file("gradle/javadoc_cleanup.gradle")
244+
245+
def fixPom() {
246+
// Reactive-Streams as compile dependency
247+
publishing.publications.all {
248+
pom.withXml {
249+
asNode().dependencies."*".findAll() {
250+
it.scope.text() == "runtime" && project.configurations.compile.allDependencies.find { dep ->
251+
dep.name == it.artifactId.text()
252+
}
253+
}.each { it.scope*.value = "compile"}
254+
}
255+
}
256+
}
257+
315258
if (rootProject.hasProperty("releaseMode")) {
316259

317260
if ("branch".equals(rootProject.releaseMode)) {
318261
// From https://github.com/ReactiveX/RxAndroid/blob/2.x/rxandroid/build.gradle#L94
319262

320263
println("ReleaseMode: " + rootProject.releaseMode);
264+
321265
artifactory {
322266
contextUrl = "https://oss.jfrog.org"
323267

@@ -332,48 +276,23 @@ if (rootProject.hasProperty("releaseMode")) {
332276
defaults {
333277
publishConfigs("archives")
334278
}
279+
280+
fixPom()
335281
}
336282
}
337283

338284
build.finalizedBy(artifactoryPublish)
339285
}
340286

341-
if ("full".equals(rootProject.releaseMode)) {
342-
// based on https://github.com/bintray/gradle-bintray-plugin
343-
def rver = version;
344-
345-
println("ReleaseMode: " + rootProject.releaseMode + " version " + rver);
346-
347-
bintray {
348-
user = rootProject.bintrayUser
349-
key = rootProject.bintrayKey
350-
configurations = ["archives"]
351-
publish = true
352-
override = true // Allows re-running the GHA upon release hangs
353-
pkg {
354-
repo = "RxJava"
355-
name = "RxJava"
356-
userOrg = "reactivex"
357-
labels = ["rxjava", "reactivex"]
358-
licenses = ["Apache-2.0"]
359-
vcsUrl = "https://github.com/ReactiveX/RxJava.git"
360-
version {
361-
name = rver
362-
gpg {
363-
sign = true
364-
}
365-
mavenCentralSync {
366-
sync = true
367-
user = rootProject.sonatypeUsername
368-
password = rootProject.sonatypePassword
369-
close = "1"
370-
}
371-
}
372-
}
287+
if ("full".equals(rootProject.releaseMode)) {
288+
apply plugin: "com.vanniktech.maven.publish"
289+
290+
fixPom()
291+
292+
signing {
293+
if (project.hasProperty('SIGNING_PRIVATE_KEY') && project.hasProperty('SIGNING_PASSWORD')) {
294+
useInMemoryPgpKeys(project.getProperty('SIGNING_PRIVATE_KEY'), project.getProperty('SIGNING_PASSWORD'))
373295
}
374-
375-
build.finalizedBy(bintrayUpload)
376-
}
296+
}
297+
}
377298
}
378-
379-
apply from: file("gradle/javadoc_cleanup.gradle")

Diff for: gradle.properties

+23-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,24 @@
11
release.scope=patch
2-
release.version=3.0.0-SNAPSHOT
2+
VERSION_NAME=3.0.0-SNAPSHOT
3+
4+
GROUP=io.reactivex.rxjava3
5+
POM_ARTIFACT_ID=rxjava
6+
POM_NAME=RxJava
7+
POM_PACKAGING=jar
8+
9+
POM_DESCRIPTION=Reactive Extensions for Java
10+
POM_INCEPTION_YEAR=2013
11+
12+
POM_URL=https://github.com/akarnokd/RxJavaExtensions
13+
POM_SCM_URL=https://github.com/ReactiveX/RxJava
14+
POM_SCM_CONNECTION=scm:git:git://github.com/ReactiveX/RxJava.git
15+
POM_SCM_DEV_CONNECTION=scm:git:ssh://[email protected]/ReactiveX/RxJava.git
16+
17+
POM_LICENCE_NAME=The Apache Software License, Version 2.0
18+
POM_LICENCE_URL=https://www.apache.org/licenses/LICENSE-2.0.txt
19+
POM_LICENCE_DIST=repo
20+
21+
POM_DEVELOPER_ID=akarnokd
22+
POM_DEVELOPER_NAME=David Karnok
23+
POM_DEVELOPER_URL=https://github.com/akarnokd/
24+
POM_DEVELOPER_EMAIL[email protected]

Diff for: gradle/javadoc_cleanup.gradle

-1
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,4 @@ def fixJavadocFile(file) {
5757
file.setText(fileContents, 'UTF-8');
5858
}
5959

60-
javadocJar.dependsOn javadocCleanup
6160
build.dependsOn javadocCleanup

0 commit comments

Comments
 (0)