Files
react-native/scripts/release-utils.js
T
Nicola Corti 3d05bac587 Unbreak Nightly job by providing a GPG key as base64 encoded.
Summary:
It seems like CircleCI is not handling well env variables with \n in it.
I'm moving it over to a base64 encoded string and I'm extending the publish
scripts to base64 decode the key.

Changelog:
[Internal] [Changed] - Unbreak Nightly job by providing a GPG key as base64 encoded.

Reviewed By: cipolleschi

Differential Revision: D40426438

fbshipit-source-id: a60a7e7ad71580e81e675c84008d2712712e42a6
2022-10-17 04:07:37 -07:00

110 lines
3.0 KiB
JavaScript

/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @format
*/
'use strict';
const {exec, echo, exit, test, env} = require('shelljs');
const {saveFiles} = require('./scm-utils');
function saveFilesToRestore(tmpPublishingFolder) {
const filesToSaveAndRestore = [
'template/Gemfile',
'template/_ruby-version',
'template/package.json',
'.ruby-version',
'Gemfile.lock',
'Gemfile',
'package.json',
'ReactAndroid/gradle.properties',
'Libraries/Core/ReactNativeVersion.js',
'React/Base/RCTVersion.m',
'ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java',
'ReactCommon/cxxreact/ReactNativeVersion.h',
];
saveFiles(filesToSaveAndRestore, tmpPublishingFolder);
}
function generateAndroidArtifacts(releaseVersion, tmpPublishingFolder) {
// -------- Generating Android Artifacts
env.REACT_NATIVE_SKIP_PREFAB = true;
if (exec('./gradlew :ReactAndroid:installArchives').code) {
echo('Could not generate artifacts');
exit(1);
}
// -------- Generating the Hermes Engine Artifacts
env.REACT_NATIVE_HERMES_SKIP_PREFAB = true;
if (exec('./gradlew :ReactAndroid:hermes-engine:installArchives').code) {
echo('Could not generate artifacts');
exit(1);
}
echo('Generated artifacts for Maven');
let artifacts = [
'.module',
'.pom',
'-debug.aar',
'-release.aar',
'-debug-sources.jar',
'-release-sources.jar',
].map(suffix => {
return `react-native-${releaseVersion}${suffix}`;
});
artifacts.forEach(name => {
if (
!test(
'-e',
`./android/com/facebook/react/react-native/${releaseVersion}/${name}`,
)
) {
echo(
`Failing as expected file: \n\
android/com/facebook/react/react-native/${releaseVersion}/${name}\n\
was not correctly generated.`,
);
exit(1);
}
});
}
function publishAndroidArtifactsToMaven(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');
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);
}
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,
};