semantic-release icon indicating copy to clipboard operation
semantic-release copied to clipboard

Revert next version Git tag if publishing fails

Open kettanaito opened this issue 2 years ago • 3 comments

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.

kettanaito avatar Mar 01 '22 13:03 kettanaito

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.

frank-weindel avatar Mar 01 '22 22:03 frank-weindel

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 }}

ErezWeiss avatar Aug 29 '23 15:08 ErezWeiss

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.

levibostian avatar Oct 13 '23 12:10 levibostian