diff --git a/.changeset/cold-melons-love.md b/.changeset/cold-melons-love.md new file mode 100644 index 00000000..aa845163 --- /dev/null +++ b/.changeset/cold-melons-love.md @@ -0,0 +1,5 @@ +--- +"@changesets/action": patch +--- + +Fixed an issue with GitHub releases not being created for successfully published packages when _some_ packages failed to be published to the registry. diff --git a/src/index.ts b/src/index.ts index 1b0f63ab..e83eacbf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -111,6 +111,19 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined; JSON.stringify(result.publishedPackages) ); } + + if (result.exitCode !== 0) { + core.error( + `Publish command exited with code ${result.exitCode}${ + result.published + ? `, but some packages were published: ${result.publishedPackages + .map((p) => `${p.name}@${p.version}`) + .join(", ")}` + : "" + }` + ); + process.exit(result.exitCode); + } return; } case hasChangesets && !hasNonEmptyChangesets: diff --git a/src/run.ts b/src/run.ts index 18ec1da4..8db7572f 100644 --- a/src/run.ts +++ b/src/run.ts @@ -72,9 +72,11 @@ type PublishResult = | { published: true; publishedPackages: PublishedPackage[]; + exitCode: number; } | { published: false; + exitCode: number; }; export async function runPublish({ @@ -89,7 +91,7 @@ export async function runPublish({ let changesetPublishOutput = await getExecOutput( publishCommand, publishArgs, - { cwd } + { cwd, ignoreReturnCode: true } ); let { packages, tool } = await getPackages(cwd); @@ -156,10 +158,11 @@ export async function runPublish({ name: pkg.packageJson.name, version: pkg.packageJson.version, })), + exitCode: changesetPublishOutput.exitCode, }; } - return { published: false }; + return { published: false, exitCode: changesetPublishOutput.exitCode }; } const requireChangesetsCliPkgJson = (cwd: string) => {