Skip to content

Commit 88ada98

Browse files
authored
Release script auto-determine the latest Canary build if none specified (#14339)
* Release script auto-determine the latest Canary build if none specified
1 parent 4f964f0 commit 88ada98

File tree

3 files changed

+29
-25
lines changed

3 files changed

+29
-25
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env node
2+
3+
'use strict';
4+
5+
const http = require('request-promise-json');
6+
const {logPromise} = require('../utils');
7+
8+
const run = async () => {
9+
// https://circleci.com/docs/api/#recent-builds-for-a-project-branch
10+
const metadataURL = `https://circleci.com/api/v1.1/project/github/facebook/react/tree/master`;
11+
const metadata = await http.get(metadataURL, true);
12+
const build = metadata.find(
13+
entry => entry.branch === 'master' && entry.status === 'success'
14+
).build_num;
15+
16+
return build;
17+
};
18+
19+
module.exports = async params => {
20+
return logPromise(
21+
run(params),
22+
'Determining latest Circle CI for the master branch'
23+
);
24+
};

scripts/release/prepare-canary-commands/parse-params.js

-25
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
'use strict';
44

55
const commandLineArgs = require('command-line-args');
6-
const commandLineUsage = require('command-line-usage');
76

87
const paramDefinitions = [
98
{
@@ -17,29 +16,5 @@ const paramDefinitions = [
1716
module.exports = () => {
1817
const params = commandLineArgs(paramDefinitions);
1918

20-
if (!params.build) {
21-
const usage = commandLineUsage([
22-
{
23-
content:
24-
'Prepare a Circle CI build to be published to NPM as a canary.',
25-
},
26-
{
27-
header: 'Options',
28-
optionList: paramDefinitions,
29-
},
30-
{
31-
header: 'Examples',
32-
content: [
33-
{
34-
desc: 'Example:',
35-
example: '$ ./prepare-canary.js [bold]{--build=}[underline]{12639}',
36-
},
37-
],
38-
},
39-
]);
40-
console.log(usage);
41-
process.exit(1);
42-
}
43-
4419
return params;
4520
};

scripts/release/prepare-canary.js

+5
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const {getPublicPackages, handleError} = require('./utils');
77

88
const checkEnvironmentVariables = require('./prepare-canary-commands/check-environment-variables');
99
const downloadBuildArtifacts = require('./prepare-canary-commands/download-build-artifacts');
10+
const getLatestMasterBuildNumber = require('./prepare-canary-commands/get-latest-master-build-number');
1011
const parseParams = require('./prepare-canary-commands/parse-params');
1112
const printPrereleaseSummary = require('./shared-commands/print-prerelease-summary');
1213

@@ -16,6 +17,10 @@ const run = async () => {
1617
params.cwd = join(__dirname, '..', '..');
1718
params.packages = await getPublicPackages();
1819

20+
if (!params.build) {
21+
params.build = await getLatestMasterBuildNumber();
22+
}
23+
1924
await checkEnvironmentVariables(params);
2025
await downloadBuildArtifacts(params);
2126
await printPrereleaseSummary(params);

0 commit comments

Comments
 (0)