85
return artifact;
86
}
87
88
-async function processArtifact(artifact, commit, releaseChannel) {
88
+async function processArtifact(artifact, opts) {
89
// Download and extract artifact
90
const cwd = join(__dirname, '..', '..', '..');
91
const tmpDir = mkdtempSync(join(os.tmpdir(), 'react_'));
97
}
98
);
99
100
- // Use https://cli.github.com/manual/gh_attestation_verify to verify artifact
101
- if (executableIsAvailable('gh')) {
102
- await exec(
103
- `gh attestation verify artifacts_combined.zip --repo=${OWNER}/${REPO}`,
104
- {
105
- cwd: tmpDir,
106
- }
107
- );
100
+ if (opts.noVerify === true) {
101
+ console.log(theme`{caution Skipping verification of build artifact.}`);
102
+ } else {
103
+ // Use https://cli.github.com/manual/gh_attestation_verify to verify artifact
104
+ if (executableIsAvailable('gh')) {
105
+ await exec(
106
+ `gh attestation verify artifacts_combined.zip --repo=${OWNER}/${REPO}`,
107
+ {
108
+ cwd: tmpDir,
109
+ }
110
+ );
111
+ }
112
}
113
114
await exec(
128
}
129
let sourceDir;
130
// TODO: Rename release channel to `next`
127
- if (releaseChannel === 'stable') {
131
+ if (opts.releaseChannel === 'stable') {
132
sourceDir = 'oss-stable';
129
- } else if (releaseChannel === 'experimental') {
133
+ } else if (opts.releaseChannel === 'experimental') {
134
sourceDir = 'oss-experimental';
131
- } else if (releaseChannel === 'rc') {
135
+ } else if (opts.releaseChannel === 'rc') {
136
sourceDir = 'oss-stable-rc';
133
- } else if (releaseChannel === 'latest') {
137
+ } else if (opts.releaseChannel === 'latest') {
138
sourceDir = 'oss-stable-semver';
139
} else {
136
- console.error('Internal error: Invalid release channel: ' + releaseChannel);
137
- process.exit(releaseChannel);
140
+ console.error(
141
+ 'Internal error: Invalid release channel: ' + opts.releaseChannel
142
+ );
143
+ process.exit(opts.releaseChannel);
144
}
145
await exec(`cp -r ./build/${sourceDir} ./build/node_modules`, {
146
cwd,
151
/[\u0000-\u001F\u007F-\u009F]/g,
152
''
153
);
148
- if (buildSha !== commit) {
154
+ if (buildSha !== opts.commit) {
155
throw new Error(
150
- `Requested commit sha does not match downloaded artifact. Expected: ${commit}, got: ${buildSha}`
156
+ `Requested commit sha does not match downloaded artifact. Expected: ${opts.commit}, got: ${buildSha}`
157
);
158
}
159
}
160
155
-async function downloadArtifactsFromGitHub(commit, releaseChannel) {
161
+async function downloadArtifactsFromGitHub(opts) {
162
let workflowRun;
163
let retries = 0;
164
// wait up to 10 mins for build to finish: 10 * 60 * 1_000) / 30_000 = 20
165
while (retries < 20) {
160
- workflowRun = await getWorkflowRun(commit);
166
+ workflowRun = await getWorkflowRun(opts.commit);
167
if (typeof workflowRun.status === 'string') {
168
switch (workflowRun.status) {
169
case 'queued':
180
workflowRun.id,
181
'artifacts_combined'
182
);
177
- await processArtifact(artifact, commit, releaseChannel);
183
+ await processArtifact(artifact, opts);
184
return;
185
} else {
186
console.log(
213
process.exit(1);
214
}
215
210
-async function downloadBuildArtifacts(commit, releaseChannel) {
211
- const label = theme`commit {commit ${commit}})`;
216
+async function downloadBuildArtifacts(opts) {
217
+ const label = theme`commit {commit ${opts.commit}})`;
218
return logPromise(
213
- downloadArtifactsFromGitHub(commit, releaseChannel),
219
+ downloadArtifactsFromGitHub(opts),
220
theme`Downloading artifacts from GitHub for ${label}`
221
);
222
}