forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathrelease-utils.js
More file actions
124 lines (107 loc) · 3.42 KB
/
release-utils.js
File metadata and controls
124 lines (107 loc) · 3.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/**
* 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, pushd, popd} = require('shelljs');
const {createHermesPrebuiltArtifactsTarball} = require('./hermes/hermes-utils');
function generateAndroidArtifacts(releaseVersion, tmpPublishingFolder) {
// -------- Generating Android Artifacts
echo('Generating Android artifacts inside /tmp/maven-local');
if (exec('./gradlew publishAllToMavenTempLocal').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-android-${releaseVersion}${suffix}`;
});
artifacts.forEach(name => {
if (
!test(
'-e',
`/tmp/maven-local/com/facebook/react/react-android/${releaseVersion}/${name}`,
)
) {
echo(
`Failing as expected file: \n\
/tmp/maven-local/com/facebook/react/react-android/${releaseVersion}/${name}\n\
was not correctly generated.`,
);
exit(1);
}
});
}
function publishAndroidArtifactsToMaven(releaseVersion, isNightly) {
// -------- Publish every artifact to Maven Central
// 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');
// 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 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');
}
function generateiOSArtifacts(
jsiFolder,
hermesCoreSourceFolder,
buildType,
releaseVersion,
targetFolder,
) {
pushd(`${hermesCoreSourceFolder}`);
//Need to generate hermesc
exec(
`${hermesCoreSourceFolder}/utils/build-hermesc-xcode.sh ${hermesCoreSourceFolder}/build_host_hermesc`,
);
//Generating iOS Artifacts
exec(
`JSI_PATH=${jsiFolder} BUILD_TYPE=${buildType} ${hermesCoreSourceFolder}/utils/build-mac-framework.sh`,
);
exec(
`JSI_PATH=${jsiFolder} BUILD_TYPE=${buildType} ${hermesCoreSourceFolder}/utils/build-ios-framework.sh`,
);
popd();
const tarballOutputPath = createHermesPrebuiltArtifactsTarball(
hermesCoreSourceFolder,
buildType,
releaseVersion,
targetFolder,
true, // this is excludeDebugSymbols, we keep it as the default
);
return tarballOutputPath;
}
module.exports = {
generateAndroidArtifacts,
generateiOSArtifacts,
publishAndroidArtifactsToMaven,
};