Configure CircleCI to publish artifacts to Maven Central (#34983)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34983

This sets up our CircleCI logic to publish artifacts to Maven Central.
I will check if tomorrow's nightly successfully landed on Maven Central
Snapshot repository.

I've added a --dry-run to the the close and release step of the publishing
to avoid accidentally publishing to Maven Central. We'll remove this if
we decide to go with the Maven Central publishing.

Changelog:
[Internal] [Changed] - Configure CircleCI to publish artifacts to Maven Central

Reviewed By: jacdebug, huntie

Differential Revision: D40377691

fbshipit-source-id: 36a74074ea95097bb7268352e40f4d2670f3cd65
This commit is contained in:
Nicola Corti authored and Facebook GitHub Bot committed 2022-10-14 07:30:29 -07:00
1 parent 19715cf4fb
commit 5d8a712fd5
3 files changed
+32 -1

No files matched your search

+3 -1
View File
@@ -1378,12 +1378,14 @@ jobs:
- checkout
- *attach_hermes_workspace
- run:
name: Copy HermesC binaries
name: Copy Hermes binaries
command: |
mkdir -p ./sdks/hermesc ./sdks/hermesc/osx-bin ./sdks/hermesc/win64-bin ./sdks/hermesc/linux64-bin
cp -r $HERMES_WS_DIR/osx-bin/* ./sdks/hermesc/osx-bin/.
cp -r $HERMES_WS_DIR/win64-bin/* ./sdks/hermesc/win64-bin/.
cp -r $HERMES_WS_DIR/linux64-bin/* ./sdks/hermesc/linux64-bin/.
mkdir -p ./ReactAndroid/external-artifacts/artifacts/
cp $HERMES_WS_DIR/hermes-runtime-darwin/hermes-runtime-darwin-debug-*.tar.gz ./ReactAndroid/external-artifacts/artifacts/hermes-ios.tar.gz
- run_yarn
- download_gradle_dependencies
+5
View File
@@ -40,6 +40,7 @@ const {
} = require('./scm-utils');
const {
generateAndroidArtifacts,
publishAndroidArtifactsToMaven,
saveFilesToRestore,
} = require('./release-utils');
const fs = require('fs');
@@ -196,6 +197,10 @@ const isLatest = exitIfNotOnGit(
'Not in git. We do not want to publish anything',
);
// We first publish on Maven Central all the necessary artifacts.
// NPM publishing is done just after.
publishAndroidArtifactsToMaven(nightlyBuild);
const releaseBranch = `${major}.${minor}-stable`;
// Set the right tag for nightly and prerelease builds
+24
View File
@@ -76,7 +76,31 @@ function generateAndroidArtifacts(releaseVersion, tmpPublishingFolder) {
});
}
function publishAndroidArtifactsToMaven(isNightly) {
// -------- Publish every artifact to Maven Central
if (exec('./gradlew publishAllToSonatype -PisNightly=' + isNightly).code) {
echo('Failed to publish artifacts to Sonatype (Maven Central)');
exit(1);
}
if (!isNightly) {
// -------- For stable releases, we also need to close and release the staging repository.
// TODO(ncor): Remove the --dry-run before RC0
if (
exec('./gradlew closeAndReleaseSonatypeStagingRepository --dry-run').code
) {
echo(
'Failed to close and release the staging repository on Sonatype (Maven Central)',
);
exit(1);
}
}
echo('Published artifacts to Maven Central');
}
module.exports = {
generateAndroidArtifacts,
publishAndroidArtifactsToMaven,
saveFilesToRestore,
};