Skip to content

Commit 34f64f6

Browse files
Andaristbluwy
andauthored
Fixed an issue with GitHub releases not being created for successfully published packages when some packages failed to be published (#535)
* Fixed an issue with GitHub releases not being created for successfully published packages when some packages failed to be published * Format --------- Co-authored-by: Bjorn Lu <bjornlu.dev@gmail.com>
1 parent 1d54b9e commit 34f64f6

3 files changed

Lines changed: 23 additions & 1 deletion

File tree

.changeset/cold-melons-love.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@changesets/action": patch
3+
---
4+
5+
Fixed an issue with GitHub releases not being created for successfully published packages when _some_ packages failed to be published to the registry.

src/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,19 @@ const getOptionalInput = (name: string) => core.getInput(name) || undefined;
136136
JSON.stringify(result.publishedPackages),
137137
);
138138
}
139+
140+
if (result.exitCode !== 0) {
141+
core.error(
142+
`Publish command exited with code ${result.exitCode}${
143+
result.published
144+
? `, but some packages were published: ${result.publishedPackages
145+
.map((p) => `${p.name}@${p.version}`)
146+
.join(", ")}`
147+
: ""
148+
}`,
149+
);
150+
process.exit(result.exitCode);
151+
}
139152
return;
140153
}
141154
case hasChangesets && !hasNonEmptyChangesets:

src/run.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,11 @@ type PublishResult =
7373
| {
7474
published: true;
7575
publishedPackages: PublishedPackage[];
76+
exitCode: number;
7677
}
7778
| {
7879
published: false;
80+
exitCode: number;
7981
};
8082

8183
export async function runPublish({
@@ -88,6 +90,7 @@ export async function runPublish({
8890
}: PublishOptions): Promise<PublishResult> {
8991
let changesetPublishOutput = await getExecOutput(script, undefined, {
9092
cwd,
93+
ignoreReturnCode: true,
9194
env: { ...process.env, GITHUB_TOKEN: githubToken },
9295
});
9396

@@ -155,10 +158,11 @@ export async function runPublish({
155158
name: pkg.packageJson.name,
156159
version: pkg.packageJson.version,
157160
})),
161+
exitCode: changesetPublishOutput.exitCode,
158162
};
159163
}
160164

161-
return { published: false };
165+
return { published: false, exitCode: changesetPublishOutput.exitCode };
162166
}
163167

164168
const requireChangesetsCliPkgJson = (cwd: string) => {

0 commit comments

Comments
 (0)