Skip to content

Commit b730681

Browse files
committed
Update publish.js to support GitHub CI artifact
1 parent f3cb4ed commit b730681

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

scripts/publish.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,26 +17,28 @@ if (!semver.satisfies(process.versions.node, '>= 10.12.0')) {
1717

1818
commander
1919
.requiredOption('-T, --tag <tag>', 'NPM published tag')
20-
.arguments('<dist_tar_file>')
20+
.arguments('<artifact_zip_file>')
2121
.option('--dry-run', 'Dry run mode for npm publish')
2222
.parse(process.argv);
2323

24-
const distTarFile = verifyFile(commander.args[0], '<dist_tar_file>');
24+
const artifactZipFile = verifyFile(commander.args[0], '<artifact_zip_file>');
2525
const rootDir = path.dirname(__dirname);
2626
const workDir = path.join(rootDir, 'build', 'publish');
2727
const distDir = path.join(rootDir, 'dist');
28-
if (!fs.existsSync(workDir)) {
29-
fs.mkdirSync(workDir, {recursive: true});
28+
if (fs.existsSync(workDir)) {
29+
rimraf.sync(workDir);
3030
}
31+
fs.mkdirSync(workDir, {recursive: true});
32+
33+
child_process.execFileSync('unzip', [artifactZipFile, '-d', workDir]);
3134

3235
// Publish standard package
3336
console.log('\n\n========== Publish standard package ==========');
3437
createPatchedContext(rootDir, '', () => {
3538
if (fs.existsSync(distDir)) {
3639
rimraf.sync(distDir);
3740
}
38-
child_process.execFileSync('tar', ['-xf', distTarFile, '-C', workDir]);
39-
fs.renameSync(path.join(workDir, 'dist'), distDir);
41+
fs.renameSync(path.join(workDir, 'archive', 'dist'), distDir);
4042
const publishArgs = ['publish', '--tag', commander.tag];
4143
if (commander.dryRun) {
4244
publishArgs.push('--dry-run');
@@ -47,14 +49,13 @@ createPatchedContext(rootDir, '', () => {
4749
// Publish unstripped package
4850
// 1. Add suffix in version, e.g. 245459.0.0-unstripped
4951
// 2. Add suffix in tag, e.g. latest-unstripped
50-
// 3. Get unstripped distribution from dist.unstripped/ in CI dist.tgz
52+
// 3. Get unstripped distribution from dist.unstripped/ in CI archive.zip
5153
console.log('\n\n========== Publish unstripped package ==========');
5254
createPatchedContext(rootDir, 'unstripped', () => {
5355
if (fs.existsSync(distDir)) {
5456
rimraf.sync(distDir);
5557
}
56-
child_process.execFileSync('tar', ['-xf', distTarFile, '-C', workDir]);
57-
fs.renameSync(path.join(workDir, 'dist.unstripped'), distDir);
58+
fs.renameSync(path.join(workDir, 'archive', 'dist.unstripped'), distDir);
5859
const publishArgs = ['publish', '--tag', `${commander.tag}-unstripped`];
5960
if (commander.dryRun) {
6061
publishArgs.push('--dry-run');

0 commit comments

Comments
 (0)