semantic-release
semantic-release copied to clipboard
Revert next version Git tag if publishing fails
Current behavior
If semantic release fails anywhere between after it's determined the next version and actual publishing of the tarball to NPM, it still creates and pushes the next version tag in Git.
Expected behavior
Semantic release may continue tagging the next version at the moment of determining it but it:
- Must push that tag only after successful publishing to NPM;
- Must revert that tag if publishing failed at any point in time.
Environment
- semantic-release version: cycjimmy/semantic-release-action@v2
- CI environment: —
- Plugins used: no plugins
- semantic-release configuration: no relevant configuration, this happens all the time
- CI logs: no relevant logs
I report this issue from using the GitHub action but the actual issue resides in this package, the action is just a wrapper.
Agreed. Publishing is likely to be more error prone than pushing commits/tags. Right now semantic-release seems to have no way of handling a failed publish and it requires manual git operations and force pushes to correct.
I simply added this:
- name: revert semantic release
if: ${{ (failure() || cancelled()) && steps.semantic-release.outputs.new_release_published == 'true' }}
run: |
gh release delete v${{steps.semantic-release.outputs.new_release_version}} --yes --cleanup-tag
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
I created a discussion which pitches the idea of adding an option to semantic-release to push a git tag after the publish
step. Since this is a similar issue, the discussion would benefit from contributing an upvote or commenting on the idea when you have a chance.