Skip to content

Commit

Permalink
Handle duplicate publishing needlessly failing (#726)
Browse files Browse the repository at this point in the history
## Summary
<!-- Succinctly describe your change, providing context, what you've
changed, and why. -->

Fixes the release process failing if a package is already published on
npm; this should just continue as normal, as these may be released by
humans or other actions.

## Checklist
<!-- Tick these items off as you progress. -->
<!-- If an item isn't applicable, ideally please strikeout the item by
wrapping it in "~~"" and suffix it with "N/A My reason for skipping
this." -->
<!-- e.g. "- [ ] ~~Added tests~~ N/A Only touches docs" -->

- [ ] ~Added a [docs PR](https://github.com/inngest/website) that
references this PR~ N/A CI fix
- [ ] ~Added unit/integration tests~ N/A CI fix
- [x] Added changesets if applicable

## Related

- Clean-up following borked release in #725 - should ensure this doesn't
happen again
  • Loading branch information
jpwilliams authored Oct 22, 2024
1 parent 63d4834 commit ad6870c
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion scripts/release/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,40 @@ const exec = async (...args) => {
});

console.log("publishing", tag, "to dist tag:", distTag);
await exec(
const {
exitCode: publishExitCode,
stdout: publishStdout,
stderr: publishStderr,
} = await getExecOutput(
"npm",
["publish", "--tag", distTag, "--access", "public", "--provenance"],
{
cwd: distDir,
ignoreReturnCode: true,
}
);

if (publishExitCode !== 0) {
// It could be a non-zero code if the package was already published by
// another action or human. If this is the case, we should not fail the
// action.
const duplicatePublishMsg =
"cannot publish over the previously published versions";

if (
publishStdout.includes(duplicatePublishMsg) ||
publishStderr.includes(duplicatePublishMsg)
) {
console.log("npm publish failed but it's okay; it's already published");

return;
}

throw new Error(`npm publish exited with ${publishExitCode}`);
}

console.log("Publish successful");

// If this was a backport release, republish the "latest" tag at the actual latest version
if (branch !== "main" && distTag === "latest") {
console.log(
Expand Down

0 comments on commit ad6870c

Please sign in to comment.