-
Notifications
You must be signed in to change notification settings - Fork 116
Replace nexus publishing plugin with direct call to central sonatype uploading URL #3723
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
Conversation
…loading URL This replaces the usage of the nexus publishing plugin with direct calls to the sonatype central publishing API. It makes the following modifications: 1. Each published project will write to a central staging repo if we have enabled central publishing. 1. A new task, `createMavenCentralBundle`, will go through and scoop up all of the relevant files from the staging repo to produce the final bundle 1. An additional task, `publishMavenCentralBundle`, will upload the bundle to the central publishing API (see: https://central.sonatype.com/api-doc and https://central.sonatype.org/publish/publish-portal-api/#uploading-a-deployment-bundle) 1. The release action now calls the new `publishMavenCentralBundle` task This should allow us to retire our usage of the legacy API.
e0efeb3 to
d681a33
Compare
ScottDugas
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mostly comments to future proof and prevent unlikely and surprising failures
| connection.setDoOutput(true) | ||
| connection.setRequestProperty('Authorization', "Bearer ${encodedCredentials}") | ||
|
|
||
| def boundary = "----GradleBoundary${System.currentTimeMillis()}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that we are uploading a zip, would it be worthwhile to add a uuid other this to help ensure that the zip file itself doesn't have this sequence of bytes? (at least if I understand multipart correctly)
Or would it be worthwhile to validate on our end that the string we use for the boundary is not in the file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I could see that. It may be overkill, and that is sort of what the current time millis is for. I think a UUID is probably safe enough, though we could do a search for it, I suppose
| destinationDirectory = layout.buildDirectory.dir('distributions') | ||
|
|
||
| from(stagingRepo) { | ||
| include "${rootProject.group.replaceAll('.', '/')}/**/${project.version}/*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means if a sub-project publishes to the staging repo, but doesn't put the results in org/foundationdb we just won't publish it, right? Probably ok, at least for the time being to not protect against that, I can't foresee us messing that up, and I think the only improvement would be to error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, though that's somewhat deliberate, as the bundle we produce is tagged with the group ID of the project, and I believe that central may actually reject our artifacts if it's in a different group
This updates the logic in the `publishMavenCentralBundle` task so that it no longer loads the full contents of the file into memory. It does this by maintaining a buffer and then writing the contents of the buffer into the stream, which allows us to avoid materializing the full element into memory. This is to try and fix a Java heap memory error that we saw previously (see: https://github.com/FoundationDB/fdb-record-layer/actions/runs/19108664941/job/54605649248). While I was here, I also updated the boundary for the HTTP multi-part form from the current time millis to a UUID, in response to a comment from the previous PR (FoundationDB#3723 (comment)).
This updates the logic in the `publishMavenCentralBundle` task so that it no longer loads the full contents of the file into memory. It does this by maintaining a buffer and then writing the contents of the buffer into the stream, which allows us to avoid materializing the full element into memory. This is to try and fix a Java heap memory error that we saw previously (see: https://github.com/FoundationDB/fdb-record-layer/actions/runs/19108664941/job/54605649248). While I was here, I also updated the boundary for the HTTP multi-part form from the current time millis to a UUID, in response to a comment from the previous PR (#3723 (comment)).
…onatype uploading URL (FoundationDB#3723)" This reverts commit da406a3.
This reverts #3723 and #3724 and returns us back to publishing via the nexus publishing API. The impetus for this is that the last approach got stuck in a publishing state after the upload (see: https://github.com/FoundationDB/fdb-record-layer/actions/runs/19117047380/job/54633288001, which succeeded, but for which we didn't get artifacts actually published despite the server upload succeeding). When we are in this mode, we expect the build to fail with a 400 error letting us know that we didn't upload anything. However, if we didn't `close` the staging repositories (which is the step that is failing), then legacy API would not be expected to upload anything to the central repo. So we need to continue to do that part even though we think it will fail.
This replaces the usage of the nexus publishing plugin with direct calls to the sonatype central publishing API. It makes the following modifications:
createMavenCentralBundle, will go through and scoop up all of the relevant files from the staging repo to produce the final bundlepublishMavenCentralBundle, will upload the bundle to the central publishing API (see: https://central.sonatype.com/api-doc and https://central.sonatype.org/publish/publish-portal-api/#uploading-a-deployment-bundle)publishMavenCentralBundletaskThis should allow us to retire our usage of the legacy API. Locally, I was able to validate that the bundle we get back from
createMavenCentralBundlehas the same layout as one generated by the JReleaser tool. Running the upload task, I was able to validate that I get an invalid token error, which is as good as I could get without giving it the proper credentials.This resolves #3709