(artifact, opts)
| 85 | } |
| 86 | |
| 87 | async function processArtifact(artifact, opts) { |
| 88 | // Download and extract artifact |
| 89 | const cwd = join(__dirname, '..', '..', '..'); |
| 90 | const tmpDir = mkdtempSync(join(os.tmpdir(), 'react_')); |
| 91 | await exec(`rm -rf ./build`, {cwd}); |
| 92 | await exec( |
| 93 | `curl -L ${GITHUB_HEADERS} ${artifact.archive_download_url} > artifacts_combined.zip`, |
| 94 | { |
| 95 | cwd: tmpDir, |
| 96 | } |
| 97 | ); |
| 98 | |
| 99 | if (opts.noVerify === true) { |
| 100 | console.log(theme`{caution Skipping verification of build artifact.}`); |
| 101 | } else { |
| 102 | // Use https://cli.github.com/manual/gh_attestation_verify to verify artifact |
| 103 | if (executableIsAvailable('gh')) { |
| 104 | await exec( |
| 105 | `gh attestation verify artifacts_combined.zip --repo=${REPO}`, |
| 106 | { |
| 107 | cwd: tmpDir, |
| 108 | } |
| 109 | ); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | await exec( |
| 114 | `unzip ${tmpDir}/artifacts_combined.zip -d . && rm build2.tgz && tar -xvzf build.tgz && rm build.tgz`, |
| 115 | { |
| 116 | cwd, |
| 117 | } |
| 118 | ); |
| 119 | |
| 120 | // Copy to staging directory |
| 121 | // TODO: Consider staging the release in a different directory from the CI |
| 122 | // build artifacts: `./build/node_modules` -> `./staged-releases` |
| 123 | if (!existsSync(join(cwd, 'build'))) { |
| 124 | await exec(`mkdir ./build`, {cwd}); |
| 125 | } else { |
| 126 | await exec(`rm -rf ./build/node_modules`, {cwd}); |
| 127 | } |
| 128 | let sourceDir; |
| 129 | // TODO: Rename release channel to `next` |
| 130 | if (opts.releaseChannel === 'stable') { |
| 131 | sourceDir = 'oss-stable'; |
| 132 | } else if (opts.releaseChannel === 'experimental') { |
| 133 | sourceDir = 'oss-experimental'; |
| 134 | } else if (opts.releaseChannel === 'rc') { |
| 135 | sourceDir = 'oss-stable-rc'; |
| 136 | } else if (opts.releaseChannel === 'latest') { |
| 137 | sourceDir = 'oss-stable-semver'; |
| 138 | } else { |
| 139 | console.error( |
| 140 | 'Internal error: Invalid release channel: ' + opts.releaseChannel |
| 141 | ); |
| 142 | process.exit(opts.releaseChannel); |
| 143 | } |
| 144 | await exec(`cp -r ./build/${sourceDir} ./build/node_modules`, { |
no test coverage detected