Skip to content

Commit a232201

Browse files
committed
style(ci): update release bundle script
1 parent c305aad commit a232201

File tree

1 file changed

+15
-29
lines changed

1 file changed

+15
-29
lines changed

scripts/bundle-release.cjs

Lines changed: 15 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,45 +18,24 @@ module.exports = async function({ github, glob, workspace, context }) {
1818
const cwd = `${workspace}`;
1919
const outfile = `${cwd}/pfe.min.js`;
2020

21-
await singleFileBuild({ outfile });
22-
23-
const params = {
24-
owner,
25-
release_id: release.id,
26-
repo
27-
};
21+
const params = { owner, release_id: release.id, repo };
2822

23+
// Create or fetch artifacts
24+
await singleFileBuild({ outfile });
2925
await copyFile(`${cwd}/core/pfe-styles/pfe.min.css`, `${cwd}/pfe.min.css`);
3026

3127
const globber = await glob.create('pfe.min.*');
32-
const files = await globber.glob();
33-
34-
// eslint-disable-next-line
35-
console.log('creating tarball for', files);
28+
const files = await globber.glob() ?? [];
3629

30+
console.log('Creating tarball for', files.join(', ')); // eslint-disable-line
3731
await tar.c({ gzip: true, file: 'pfe.min.tgz' }, files);
3832

39-
// upload the bundle to each release
40-
await github.rest.repos.uploadReleaseAsset({
41-
...params,
42-
name: 'pfe.min.tgz',
43-
data: await readFile(`${cwd}/pfe.min.tgz`),
44-
});
45-
46-
const { packageName } = tag.match(/^(?<packageName>@[-\w]+[/]{1}[-\w]+)@(.*)$/)?.groups ?? {};
47-
48-
if (!packageName) {
49-
// eslint-disable-next-line
50-
console.log(release);
51-
throw new Error('No Package found');
52-
}
33+
// download the tarball that was published to NPM
34+
const { stdout } = await execaCommand(`npm pack ${tag}`);
5335

54-
// make a tarball for the package
55-
// this was already published to npm in the changesets action
56-
const { stdout } = await execaCommand(`npm run pack -w ${packageName}`);
5736
const match = stdout.match(/^[\w-.]+\.tgz$/g);
5837

59-
// upload the package tarball to the release
38+
// Upload the NPM tarball to the release
6039
if (match) {
6140
const [name] = match;
6241
await github.rest.repos.uploadReleaseAsset({
@@ -65,4 +44,11 @@ module.exports = async function({ github, glob, workspace, context }) {
6544
data: await readFile(`${cwd}/${name}`),
6645
});
6746
}
47+
48+
// Upload the all-repo bundle to the release
49+
await github.rest.repos.uploadReleaseAsset({
50+
...params,
51+
name: 'pfe.min.tgz',
52+
data: await readFile(`${cwd}/pfe.min.tgz`),
53+
});
6854
};

0 commit comments

Comments
 (0)