Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Publish to mavencentral #144

Merged
merged 9 commits into from
Apr 29, 2021
Merged

Publish to mavencentral #144

merged 9 commits into from
Apr 29, 2021

Conversation

JeroenMols
Copy link
Contributor

@JeroenMols JeroenMols commented Apr 14, 2021

⚠️ This code must still be tested before merging ⚠️

Open items to do:

  • Create Streem Sonatype account
  • Add SONATYPE_API_USER and SONATYPE_API_KEY as Github actions secrets
  • Create Streem PGP key and publish it on a public key server
  • Add SONATYPE_PGP_KEY_BASE64 as Github actions secret (export key using gpg --export-secret-key --armor | base64)
  • Look into how to support snapshots
  • Test upload to Maven Central

This PR converts all existing plumbing to upload to Maven Central instead of Bintray. Key changes are:

  1. Rename all Bintray/JCenter references to Sonatype/Maven Central
  2. Change maven URL
  3. Add artifact signing
  4. Update pom.xml so it contains all required attributes for Maven Central (see here https://central.sonatype.org/publish/requirements/#sufficient-metadata)

I've taken this as far as I can take it, for the next steps credentials/signing keys are needed so I'd like for someone else to take over.

Finally note that I was unable to test run publishToMavenCentralRepository as Gradle can't find the task. Not sure why, but the same was already happening for publishToBintrayRepository so I decided to ignore that.

Relates to #120

@@ -280,6 +280,8 @@ section below under "Usage" for more details.

### Generating Code

> TODO change to Sonatype link after migrating

Pbandk's code generator leverages `protoc`. Download the [latest
protoc](https://github.com/google/protobuf/releases/latest) and make sure `protoc` is on the `PATH`.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See placeholder above so we don't forget to update this link

# files yet. See https://github.com/gradle/gradle/issues/11412 for details.
# Open sonatype issue: https://issues.sonatype.org/browse/NEXUS-23603
systemProp.org.gradle.internal.publish.checksums.insecure=true
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked and this issue still seems to exist

@garyp
Copy link
Collaborator

garyp commented Apr 14, 2021

Thanks for starting this! I had your blog post about migrating to Maven Central up in my browser and was trying to find time to work on it 😄 I had already created a Sonatype account a few weeks ago and went through the process to get approved for artifacts under the pro.streem namespace. I've added the credentials as secrets in GitHub Actions.

Note that our account was provisioned on Sonatype's new infrastructure, so you'll need to use https://s01.oss.sonatype.org as the URL. https://central.sonatype.org/publish/publish-gradle/#metadata-definition-and-upload has details on the new URLs to use.

Also, the sync from Sonatype to Maven Central is not enabled yet. They said "Please comment on this ticket when you've released your first component(s), so we can activate the sync to Maven Central." So we'll need to do that after we publish a pbandk release.

Copy link
Collaborator

@garyp garyp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll try to get the PGP key created tomorrow and pull down your changes to test them out.

buildSrc/src/main/kotlin/addMavenCentralRepository.kt Outdated Show resolved Hide resolved
examples/browser-js/build.gradle.kts Show resolved Hide resolved
buildSrc/src/main/kotlin/configureMavenSigning.kt Outdated Show resolved Hide resolved
buildSrc/src/main/kotlin/configureMavenSigning.kt Outdated Show resolved Hide resolved
buildSrc/src/main/kotlin/configureMavenSigning.kt Outdated Show resolved Hide resolved
@JeroenMols
Copy link
Contributor Author

@garyp I've incorporated your suggestions and this PR is ready for a new rounds of review.

Two remarks:

  • I'm unavailable over the weekend, but feel free to make/push changes to this branch.
  • All this code is still untested 😅 , and I'm not sure if I properly migrated everything that used to be in PublishingExtension.addMavenCentralRepository(), so please take extra care reviewing that

@garyp
Copy link
Collaborator

garyp commented Apr 28, 2021

I have the PGP key generated and I've been trying to test this PR locally. But for some reason neither the signing nor publishing tasks are showing up. I'll keep poking at it...

@JeroenMols
Copy link
Contributor Author

Is this because I skip the configuration if no credentials/signing keys are present?

if (!sonatypeApiUser.isPresent || !sonatypeApiKey.isPresent) {

@JeroenMols
Copy link
Contributor Author

Also the publishToMavenCentralRepository task doesn't exist, I think that needs to be just publish or we should use your suggestion wrt the publications api

@garyp
Copy link
Collaborator

garyp commented Apr 28, 2021

Of course I figured it out 5 minutes after writing that. I was trying to use a property file that Gradle doesn't actually read. That's what I get for trying to do this while tired yesterday 😔 I can see both the signing and publishing tasks now (I updated it to use the publishing API). I'll do some more testing later this morning and push up my changes.

@JeroenMols
Copy link
Contributor Author

Thank you for driving this forward @garyp ! 🙏
Please let me know if I can help.


on:
push:
branches:
- master
- v[0-9]+.[0-9]+.x
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realized that we can get snapshot builds more or less for free by just running the "release" workflow for all pushes to the master branch. The nexus-publish gradle plugin automatically chooses whether to publish to the OSSRH snapshot or release repository based on whether the version name includes "-SNAPSHOT".


```
repositories {
jcenter()
// This repository is only needed if using a SNAPSHOT version of pbandk
maven { url "https://s01.oss.sonatype.org/content/repositories/snapshots/" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JeroenMols FYI, if you ever need to test the latest code on master, every commit to master should now publish artifacts at this maven URL.

@garyp garyp merged commit 8382344 into master Apr 29, 2021
@garyp garyp deleted the publish_to_mavencentral branch April 29, 2021 00:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants