mirror of
https://github.com/zebrajr/react.git
synced 2025-12-06 12:20:20 +01:00
* Migrate prepare-release-from-ci to new workflow I added a `--releaseChannel (-r)` argument to script. You must choose either "stable" or "experimental", because every build job now includes both channels. The prepare-release-from-npm script is unchanged since those releases are downloaded from npm, nt CI. (As a side note, I think we should start preparing semver releases using the prepare-release-from-ci script, too, and get rid of prepare-release-from-npm. I think that was a neat idea originally but because we already run `npm pack` before storing the artifacts in CI, there's really not much additional safety; the only safeguard it adds is the requirement that a "next" release must have already been published.) * Move validation to parse-params module
59 lines
1.7 KiB
JavaScript
59 lines
1.7 KiB
JavaScript
#!/usr/bin/env node
|
|
|
|
'use strict';
|
|
|
|
const {exec} = require('child-process-promise');
|
|
const {existsSync} = require('fs');
|
|
const {join} = require('path');
|
|
const {getArtifactsList, logPromise} = require('../utils');
|
|
const theme = require('../theme');
|
|
|
|
const run = async ({build, cwd, releaseChannel}) => {
|
|
const artifacts = await getArtifactsList(build);
|
|
const buildArtifacts = artifacts.find(entry =>
|
|
entry.path.endsWith('build2.tgz')
|
|
);
|
|
|
|
if (!buildArtifacts) {
|
|
console.log(
|
|
theme`{error The specified build (${build}) does not contain any build artifacts.}`
|
|
);
|
|
process.exit(1);
|
|
}
|
|
|
|
// Download and extract artifact
|
|
await exec(`rm -rf ./build2`, {cwd});
|
|
await exec(
|
|
`curl -L $(fwdproxy-config curl) ${buildArtifacts.url} | tar -xvz`,
|
|
{
|
|
cwd,
|
|
}
|
|
);
|
|
|
|
// Copy to staging directory
|
|
// TODO: Consider staging the release in a different directory from the CI
|
|
// build artifacts: `./build/node_modules` -> `./staged-releases`
|
|
if (!existsSync(join(cwd, 'build'))) {
|
|
await exec(`mkdir ./build`, {cwd});
|
|
} else {
|
|
await exec(`rm -rf ./build/node_modules`, {cwd});
|
|
}
|
|
let sourceDir;
|
|
if (releaseChannel === 'stable') {
|
|
sourceDir = 'oss-stable';
|
|
} else if (releaseChannel === 'experimental') {
|
|
sourceDir = 'oss-experimental';
|
|
} else {
|
|
console.error('Internal error: Invalid release channel: ' + releaseChannel);
|
|
process.exit(releaseChannel);
|
|
}
|
|
await exec(`cp -r ./build2/${sourceDir} ./build/node_modules`, {cwd});
|
|
};
|
|
|
|
module.exports = async ({build, cwd, releaseChannel}) => {
|
|
return logPromise(
|
|
run({build, cwd, releaseChannel}),
|
|
theme`Downloading artifacts from Circle CI for build {build ${build}}`
|
|
);
|
|
};
|