Skip to content

Commit

Permalink
Invoke closeAndReleaseSonatypeStagingRepository in the publish gradle…
Browse files Browse the repository at this point in the history
… invocation (#35272)

Summary:
This PR ports back into main the changes required to properly close the SonaType repository on Maven

## Changelog

[General] [Fixed] - Close the Maven repository properly

Pull Request resolved: #35272

Test Plan: We tested these changed in 0.71-stable branch when releasing 0.71.0-RC.0

Reviewed By: christophpurrer

Differential Revision: D41154965

Pulled By: cipolleschi

fbshipit-source-id: 74dd46e8fabf3baef544342282829c70d92f671f
  • Loading branch information
cortinico authored and facebook-github-bot committed Nov 10, 2022
1 parent 37fbc16 commit 90b6735
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions scripts/release-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,24 +52,30 @@ function generateAndroidArtifacts(releaseVersion, tmpPublishingFolder) {

function publishAndroidArtifactsToMaven(releaseVersion, isNightly) {
// -------- Publish every artifact to Maven Central
// The GPG key is base64 encoded on CircleCI
// The GPG key is base64 encoded on CircleCI and then decoded here
let buff = Buffer.from(env.ORG_GRADLE_PROJECT_SIGNING_KEY_ENCODED, 'base64');
env.ORG_GRADLE_PROJECT_SIGNING_KEY = buff.toString('ascii');
if (exec('./gradlew publishAllToSonatype -PisNightly=' + isNightly).code) {
echo('Failed to publish artifacts to Sonatype (Maven Central)');
exit(1);
}

// We want to gate ourselves against accidentally publishing a 1.x or a 1000.x on
// maven central which will break the semver for our artifacts.
if (!isNightly && releaseVersion.startsWith('0.')) {
// -------- For stable releases, we also need to close and release the staging repository.
if (exec('./gradlew closeAndReleaseSonatypeStagingRepository').code) {
if (
exec(
'./gradlew publishAllToSonatype closeAndReleaseSonatypeStagingRepository',
).code
) {
echo(
'Failed to close and release the staging repository on Sonatype (Maven Central)',
);
exit(1);
}
} else {
// -------- For nightly releases, we only need to publish the snapshot to Sonatype snapshot repo.
if (exec('./gradlew publishAllToSonatype -PisNightly=' + isNightly).code) {
echo('Failed to publish artifacts to Sonatype (Maven Central)');
exit(1);
}
}

echo('Published artifacts to Maven Central');
Expand Down

0 comments on commit 90b6735

Please # to comment.