Skip to content

Commit

Permalink
move publishing away from bintray (gone) and directly to sonatype
Browse files Browse the repository at this point in the history
  • Loading branch information
sjamesr committed Jan 9, 2025
1 parent 2757238 commit 5727892
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 55 deletions.
21 changes: 17 additions & 4 deletions RELEASING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,37 @@ $ gpg --keyserver keys.openpgp.org --send-keys 90ABCDEF
gpg: sending key 1234567890ABCDEF to hkp://keys.openpgp.org
```

## Gradle properties

Add the following properties to `$HOME/gradle.properties`:

```
signing.gnupg.executable=gpg
signing.gnupg.useLegacyGpg=true
signing.gnupg.keyName=ABCDEF01
# Not to be confused with your Sonatype login username and password
ossrhUsername=yourSonatypeToken
ossrhPassword=yourSonatypeTokenPassword
```

# Making the release

In a shell, change into the RE2/J source code root directory (the one
containing `build.gradle`). Then:

* edit `build.gradle` and set `version` to the name of the next release
(e.g. "1.8").
(e.g. "1.9").
* change the download instructions in `README.md` to reflect the new version
number
* `git commit` the version name change
* `git tag re2j-<versionName>`, e.g. `git tag re2j-1.8`
* `git tag re2j-<versionName>`, e.g. `git tag re2j-1.9`
* `git push --tags`

Now you're ready to build and push the release.

```
./gradlew -Psonatype.username='sonatypeUsername' -Psonatype.password='sonatypeApiKey' \
clean bintrayUpload
./gradlew clean uploadArchives
```

Once successful, the new version needs to be published:
Expand Down
98 changes: 47 additions & 51 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
plugins {
id 'java-library'
id 'wrapper'
id 'maven-publish'
id 'maven'
id 'io.github.gradle-nexus.publish-plugin' version '1.1.0'
id 'com.github.sherter.google-java-format' version '0.3.2'
id 'net.ltgt.errorprone' version '2.0.2'
Expand All @@ -24,7 +24,8 @@ cobertura.coverageFormats = ['html', 'xml']

// The name of the release we're working on. See RELEASING.md for details.
group = "com.google.re2j"
version = "1.7"
archivesBaseName = "re2j"
version = "1.8"

wrapper {
gradleVersion '5.2'
Expand Down Expand Up @@ -93,56 +94,60 @@ dependencies {
testRuntime "org.slf4j:slf4j-api:1.7.10"
}

task sourceJar(type: Jar) {
baseName 'sources'

from sourceSets.main.allJava
from sourceSets.gwt.allSource
task javadocJar(type: Jar) {
classifier = 'javadoc'
from javadoc
}

task javadocJar(type: Jar, dependsOn: javadoc) {
baseName 'javadoc'

from javadoc.destinationDir
task sourcesJar(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}

def appendMavenCentralMetadata(Node node) {
node.appendNode('name', 'RE2/J')
node.appendNode('description', 'Linear time regular expressions for Java')
node.appendNode('url', 'http://github.com/google/re2j')

def license = node.appendNode('licenses').appendNode('license')
license.appendNode('name', 'Go License')
license.appendNode('url', 'https://golang.org/LICENSE')
license.appendNode('distribution', 'repo')

node.appendNode('scm').appendNode('url', 'https://github.com/google/re2j.git')

def developerInfo = node.appendNode('developers').appendNode('developer')
developerInfo.appendNode('id', 'dev')
developerInfo.appendNode('name', 'The RE2/J Contributors')
developerInfo.appendNode('email', '[email protected]')
artifacts {
archives javadocJar, sourcesJar
}

publishing {
publications {
mavenJava(MavenPublication) {
from components.java
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

artifact sourceJar {
classifier 'sources'
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: findProperty('ossrhUsername') ?: '',
password: findProperty('ossrhPassword') ?: '')
}

artifact javadocJar {
classifier 'javadoc'
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") {
authentication(userName: findProperty('ossrhUsername') ?: '',
password: findProperty('ossrhPassword') ?: '')
}

groupId 'com.google.re2j'
artifactId 're2j'
version project.version

pom.withXml {
appendMavenCentralMetadata(asNode())
pom.project {
name 'RE2/J'
packaging 'jar'
description 'Linear time regular expressions for Java'
url 'http://github.com/google/re2j'

scm {
url 'https://github.com/google/re2j.git'
}

licenses {
license {
name 'Go License'
url 'https://golang.org/LICENSE'
distribution 'repo'
}
}

developers {
developer {
id 'dev'
name 'The RE2/J Contributors'
email '[email protected]'
}
}
}
}
}
Expand All @@ -151,16 +156,7 @@ publishing {
signing {
useGpgCmd()

sign publishing.publications.mavenJava
}

nexusPublishing {
repositories {
sonatype {
username = findProperty('sonatype.username')
password = findProperty('sonatype.password')
}
}
sign configurations.archives
}

// If Java formatter checks fail, tell the user how to fix them.
Expand Down

0 comments on commit 5727892

Please sign in to comment.