Skip to content

Commit 8f37942

Browse files
authored
Prepare semver (@latest) releases in CI (#21615)
Now that we track package versions in source, `@latest` builds should be fully reproducible for a given commit. We can prepare the packages in CI and store them as artifacts, the same way we do for `@next` and `@experimental`. Eventually this can replace the interactive script that we currently use to swap out the version numbers. The other nice thing about this approach is that we can run tests in CI to verify that the packages are releasable, instead of waiting until right before publish. I named the output directory `oss-stable-semver`, to distinguish from the `@next` prereleases that are located at `oss-stable`. I don't love this naming. I'd prefer to use the name of the corresponding npm dist tag. I'll do that in a follow-up, though, since the `oss-stable` name is referenced in a handful of places. Current naming (after this PR): - `oss-experimental` → `@experimental` - `oss-stable` → `@next` - `oss-stable-semver` → `@latest` Proposed naming (not yet implemented, requires more work): - `oss-experimental` → `@experimental` - `oss-next` → `@next` - `oss-latest` → `@latest`
1 parent 44cdfd6 commit 8f37942

File tree

1 file changed

+31
-5
lines changed

1 file changed

+31
-5
lines changed

scripts/rollup/build-all-release-channels.js

Lines changed: 31 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,29 @@ function processStable(buildDir) {
9898
updatePackageVersions(
9999
buildDir + '/node_modules',
100100
versionsMap,
101-
defaultVersionIfNotFound
101+
defaultVersionIfNotFound,
102+
true
102103
);
103104
fs.renameSync(buildDir + '/node_modules', buildDir + '/oss-stable');
105+
106+
// Identical to `oss-stable` but with real, semver versions. This is what
107+
// will get published to @latest.
108+
spawnSync('cp', [
109+
'-r',
110+
buildDir + '/oss-stable',
111+
buildDir + '/oss-stable-semver',
112+
]);
113+
const semverVersionsMap = new Map();
114+
for (const moduleName in stablePackages) {
115+
const version = stablePackages[moduleName];
116+
semverVersionsMap.set(moduleName, version);
117+
}
118+
updatePackageVersions(
119+
buildDir + '/oss-stable-semver',
120+
semverVersionsMap,
121+
defaultVersionIfNotFound,
122+
false
123+
);
104124
}
105125

106126
if (fs.existsSync(buildDir + '/facebook-www')) {
@@ -131,7 +151,8 @@ function processExperimental(buildDir, version) {
131151
updatePackageVersions(
132152
buildDir + '/node_modules',
133153
versionsMap,
134-
defaultVersionIfNotFound
154+
defaultVersionIfNotFound,
155+
true
135156
);
136157
fs.renameSync(buildDir + '/node_modules', buildDir + '/oss-experimental');
137158
}
@@ -179,7 +200,8 @@ function crossDeviceRenameSync(source, destination) {
179200
function updatePackageVersions(
180201
modulesDir,
181202
versionsMap,
182-
defaultVersionIfNotFound
203+
defaultVersionIfNotFound,
204+
pinToExactVersion
183205
) {
184206
for (const moduleName of fs.readdirSync(modulesDir)) {
185207
let version = versionsMap.get(moduleName);
@@ -199,14 +221,18 @@ function updatePackageVersions(
199221
if (packageInfo.dependencies) {
200222
for (const dep of Object.keys(packageInfo.dependencies)) {
201223
if (versionsMap.has(dep)) {
202-
packageInfo.dependencies[dep] = version;
224+
packageInfo.dependencies[dep] = pinToExactVersion
225+
? version
226+
: '^' + version;
203227
}
204228
}
205229
}
206230
if (packageInfo.peerDependencies) {
207231
for (const dep of Object.keys(packageInfo.peerDependencies)) {
208232
if (versionsMap.has(dep)) {
209-
packageInfo.peerDependencies[dep] = version;
233+
packageInfo.peerDependencies[dep] = pinToExactVersion
234+
? version
235+
: '^' + version;
210236
}
211237
}
212238
}

0 commit comments

Comments
 (0)