From 76f70849578c664e9b14d96475e30e179edd7222 Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Thu, 27 Oct 2022 20:47:44 -0700 Subject: [PATCH] Gate the Maven Central publishing to 0.x version. (#35109) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/35109 This is just a safety check to make sure we don't accidentally publish a 1.x or a 1000.x version on Maven Central by mistake. Changelog: [Internal] [Changed] - Gate the Maven Central publishing to 0.x version. Reviewed By: mdvacca Differential Revision: D40767782 fbshipit-source-id: 58f2906c3b01bfd0fd388a300ba303b289633d4e --- scripts/publish-npm.js | 2 +- scripts/release-utils.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/publish-npm.js b/scripts/publish-npm.js index 2b4834e8de0361..25900e6bea89db 100755 --- a/scripts/publish-npm.js +++ b/scripts/publish-npm.js @@ -203,7 +203,7 @@ const isLatest = exitIfNotOnGit( // We first publish on Maven Central all the necessary artifacts. // NPM publishing is done just after. -publishAndroidArtifactsToMaven(nightlyBuild); +publishAndroidArtifactsToMaven(releaseVersion, nightlyBuild); const releaseBranch = `${major}.${minor}-stable`; diff --git a/scripts/release-utils.js b/scripts/release-utils.js index 57a091029f1aa2..0ade67ac98b3b3 100644 --- a/scripts/release-utils.js +++ b/scripts/release-utils.js @@ -69,7 +69,7 @@ function generateAndroidArtifacts(releaseVersion, tmpPublishingFolder) { }); } -function publishAndroidArtifactsToMaven(isNightly) { +function publishAndroidArtifactsToMaven(releaseVersion, isNightly) { // -------- Publish every artifact to Maven Central // The GPG key is base64 encoded on CircleCI let buff = Buffer.from(env.ORG_GRADLE_PROJECT_SIGNING_KEY_ENCODED, 'base64'); @@ -79,7 +79,9 @@ function publishAndroidArtifactsToMaven(isNightly) { exit(1); } - if (!isNightly) { + // 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) { echo(