Skip to content

Commit 5d8a712

Browse files
cortinicofacebook-github-bot
authored andcommitted
Configure CircleCI to publish artifacts to Maven Central (#34983)
Summary: Pull Request resolved: #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
1 parent 19715cf commit 5d8a712

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

.circleci/config.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1378,12 +1378,14 @@ jobs:
13781378
- checkout
13791379
- *attach_hermes_workspace
13801380
- run:
1381-
name: Copy HermesC binaries
1381+
name: Copy Hermes binaries
13821382
command: |
13831383
mkdir -p ./sdks/hermesc ./sdks/hermesc/osx-bin ./sdks/hermesc/win64-bin ./sdks/hermesc/linux64-bin
13841384
cp -r $HERMES_WS_DIR/osx-bin/* ./sdks/hermesc/osx-bin/.
13851385
cp -r $HERMES_WS_DIR/win64-bin/* ./sdks/hermesc/win64-bin/.
13861386
cp -r $HERMES_WS_DIR/linux64-bin/* ./sdks/hermesc/linux64-bin/.
1387+
mkdir -p ./ReactAndroid/external-artifacts/artifacts/
1388+
cp $HERMES_WS_DIR/hermes-runtime-darwin/hermes-runtime-darwin-debug-*.tar.gz ./ReactAndroid/external-artifacts/artifacts/hermes-ios.tar.gz
13871389
13881390
- run_yarn
13891391
- download_gradle_dependencies

scripts/publish-npm.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ const {
4040
} = require('./scm-utils');
4141
const {
4242
generateAndroidArtifacts,
43+
publishAndroidArtifactsToMaven,
4344
saveFilesToRestore,
4445
} = require('./release-utils');
4546
const fs = require('fs');
@@ -196,6 +197,10 @@ const isLatest = exitIfNotOnGit(
196197
'Not in git. We do not want to publish anything',
197198
);
198199

200+
// We first publish on Maven Central all the necessary artifacts.
201+
// NPM publishing is done just after.
202+
publishAndroidArtifactsToMaven(nightlyBuild);
203+
199204
const releaseBranch = `${major}.${minor}-stable`;
200205

201206
// Set the right tag for nightly and prerelease builds

scripts/release-utils.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,31 @@ function generateAndroidArtifacts(releaseVersion, tmpPublishingFolder) {
7676
});
7777
}
7878

79+
function publishAndroidArtifactsToMaven(isNightly) {
80+
// -------- Publish every artifact to Maven Central
81+
if (exec('./gradlew publishAllToSonatype -PisNightly=' + isNightly).code) {
82+
echo('Failed to publish artifacts to Sonatype (Maven Central)');
83+
exit(1);
84+
}
85+
86+
if (!isNightly) {
87+
// -------- For stable releases, we also need to close and release the staging repository.
88+
// TODO(ncor): Remove the --dry-run before RC0
89+
if (
90+
exec('./gradlew closeAndReleaseSonatypeStagingRepository --dry-run').code
91+
) {
92+
echo(
93+
'Failed to close and release the staging repository on Sonatype (Maven Central)',
94+
);
95+
exit(1);
96+
}
97+
}
98+
99+
echo('Published artifacts to Maven Central');
100+
}
101+
79102
module.exports = {
80103
generateAndroidArtifacts,
104+
publishAndroidArtifactsToMaven,
81105
saveFilesToRestore,
82106
};

0 commit comments

Comments
 (0)