Skip to content

Commit aebe3a3

Browse files
committed
fix: catch cnpm sync error
1 parent 022499d commit aebe3a3

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

scripts/release/index.js

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,26 @@ async function run() {
4343
core.setOutput('release_version', nextRelease.version);
4444

4545
// cnpm sync
46-
const res = await request(`https://registry.npmmirror.com/-/package/${pkgInfo.name}/syncs`, { method: 'PUT' });
47-
const { id } = await res.body.json();
48-
const logUrl = `https://registry.npmmirror.com/-/package/${pkgInfo.name}/syncs/${id}/log`;
49-
core.setOutput('cnpm_sync_url', logUrl);
50-
core.info(`cnpm sync log url: ${logUrl}`);
46+
try {
47+
const res = await request(`https://registry.npmmirror.com/-/package/${pkgInfo.name}/syncs`, {
48+
method: 'PUT',
49+
timeout: 30000,
50+
});
51+
const { id } = await res.body.json();
52+
const logUrl = `https://registry.npmmirror.com/-/package/${pkgInfo.name}/syncs/${id}/log`;
53+
core.setOutput('cnpm_sync_url', logUrl);
54+
core.info(`cnpm sync log url: ${logUrl}`);
5155

52-
// write summary
53-
core.summary.addRaw(`## [${pkgInfo.name}](https://github.com/${process.env.GITHUB_REPOSITORY})\n`);
54-
core.summary.addRaw(`- Release: ${lastRelease?.version ?? ''} -> ${nextRelease.version}\n`);
55-
core.summary.addRaw(`- Registry: ${registry}\n`);
56-
core.summary.addRaw(`- CNPM Sync: ${logUrl}\n`);
57-
core.summary.addRaw(`- DryRun: ${process.env.DRYRUN}\n`);
56+
// write summary
57+
core.summary.addRaw(`## [${pkgInfo.name}](https://github.com/${process.env.GITHUB_REPOSITORY})\n`);
58+
core.summary.addRaw(`- Release: ${lastRelease?.version ?? ''} -> ${nextRelease.version}\n`);
59+
core.summary.addRaw(`- Registry: ${registry}\n`);
60+
core.summary.addRaw(`- CNPM Sync: ${logUrl}\n`);
61+
core.summary.addRaw(`- DryRun: ${process.env.DRYRUN}\n`);
62+
} catch (err) {
63+
core.info(`cnpm sync ${pkgInfo.name} fail, ${err.message}`);
64+
core.summary.addRaw(`- CNPM Sync ${pkgInfo.name} error: ${err.message}\n`);
65+
}
5866
core.summary.addRaw(nextRelease.notes);
5967
await core.summary.write();
6068
}

0 commit comments

Comments
 (0)