mirror of
https://github.com/cycjimmy/semantic-release-action.git
synced 2025-11-07 02:36:55 +00:00
fix: improves result handling in windUpJob.task.js
Promise was checked before resolving, so the first early return never happened (Promises are truthy) and the subsequent `if (lastRelease.version)` check produced an error in some cases(`lastRelease` undefined, "Error: TypeError: Cannot read properties of undefined (reading 'version')"). Observed for semantic-release-action 4.2.2 and 5.0.0 with semantic_version > 24.2.6 (not observed with 24.2.6). The PR prevents reading properties of "undefined".
This commit is contained in:
parent
8e71605483
commit
4267eee560
1 changed files with 12 additions and 6 deletions
|
|
@ -7,23 +7,29 @@ const outputs = require('./outputs.json');
|
|||
* @returns {Promise<void>}
|
||||
*/
|
||||
module.exports = async (result) => {
|
||||
if (!result) {
|
||||
const resolved = await result;
|
||||
if (!resolved) {
|
||||
core.debug('No release published.');
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
const {lastRelease, commits, nextRelease, releases} = await result;
|
||||
const {
|
||||
lastRelease = {},
|
||||
commits = [],
|
||||
nextRelease = {},
|
||||
releases = [],
|
||||
} = resolved;
|
||||
|
||||
if (lastRelease.version) {
|
||||
if (lastRelease?.version) {
|
||||
core.debug(`The last release was "${lastRelease.version}".`);
|
||||
core.setOutput(outputs.last_release_version, lastRelease.version);
|
||||
core.setOutput(outputs.last_release_git_head, lastRelease.gitHead);
|
||||
core.setOutput(outputs.last_release_git_tag, lastRelease.gitTag);
|
||||
}
|
||||
|
||||
|
||||
if (!nextRelease) {
|
||||
core.debug('No release published.');
|
||||
return Promise.resolve();
|
||||
return;
|
||||
}
|
||||
|
||||
core.debug(`Published ${nextRelease.type} release version ${nextRelease.version} containing ${commits.length} commits.`);
|
||||
|
|
|
|||
Loading…
Reference in a new issue