Skip to content

Commit 755c6c0

Browse files
committed
fix(ci): bundle on release create
1 parent 1b6d5a2 commit 755c6c0

File tree

2 files changed

+27
-19
lines changed

2 files changed

+27
-19
lines changed

.github/workflows/bundle.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
release:
55
types:
66
- published
7+
- created
8+
- prereleased
9+
- released
710

811
jobs:
912
release:
@@ -27,5 +30,6 @@ jobs:
2730
with:
2831
github-token: ${{secrets.GITHUB_TOKEN}}
2932
script: |
33+
console.log(context.payload.action);
3034
const bundle = require('./scripts/bundle-release.cjs');
3135
await bundle({ context, github, glob, workspace: '${{ github.workspace }}' });

scripts/bundle-release.cjs

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,24 @@ module.exports = async function({ github, glob, workspace, context }) {
2020

2121
const params = { owner, release_id: release.id, repo };
2222

23-
// Create or fetch artifacts
24-
await singleFileBuild({ outfile });
25-
await copyFile(`${cwd}/core/pfe-styles/pfe.min.css`, `${cwd}/pfe.min.css`);
23+
if (!release.assets.some(x => x.name === 'pfe.min.tgz')) {
24+
// Create or fetch artifacts
25+
await singleFileBuild({ outfile });
26+
await copyFile(`${cwd}/core/pfe-styles/pfe.min.css`, `${cwd}/pfe.min.css`);
2627

27-
const globber = await glob.create('pfe.min.*');
28-
const files = await globber.glob() ?? [];
28+
const globber = await glob.create('pfe.min.*');
29+
const files = await globber.glob() ?? [];
2930

30-
console.log('Creating tarball for', files.join(', ')); // eslint-disable-line
31-
await tar.c({ gzip: true, file: 'pfe.min.tgz' }, files);
31+
console.log('Creating tarball for', files.join(', ')); // eslint-disable-line
32+
await tar.c({ gzip: true, file: 'pfe.min.tgz' }, files);
33+
34+
// Upload the all-repo bundle to the release
35+
await github.rest.repos.uploadReleaseAsset({
36+
...params,
37+
name: 'pfe.min.tgz',
38+
data: await readFile(`${cwd}/pfe.min.tgz`),
39+
});
40+
}
3241

3342
// download the tarball that was published to NPM
3443
const { stdout } = await execaCommand(`npm pack ${tag}`);
@@ -38,17 +47,12 @@ module.exports = async function({ github, glob, workspace, context }) {
3847
// Upload the NPM tarball to the release
3948
if (match) {
4049
const [name] = match;
41-
await github.rest.repos.uploadReleaseAsset({
42-
...params,
43-
name,
44-
data: await readFile(`${cwd}/${name}`),
45-
});
50+
if (!release.assets.some(x => x.name === name)) {
51+
await github.rest.repos.uploadReleaseAsset({
52+
...params,
53+
name,
54+
data: await readFile(`${cwd}/${name}`),
55+
});
56+
}
4657
}
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-
});
5458
};

0 commit comments

Comments
 (0)