GitHub Action
Rollback Release
This action will rollback/delete a Github release. It is designed as a failsafe for workflows that do not complete, produce errors, fail to publish, or any other circumstance where removing a release is applicable.
For example, consider the lifecycle of a Javascript package being published to npm.
test-->build-->tag-->release-->publish
In the scenario where publishing fails, it may be desirable to rollback the release.
The following is an example .github/publish.yml
that will rollback a release when a publish fails.
Configuring the action is straightforward:
- name: Rollback Release
if: failure()
uses: author/action-rollback@stable
with:
# Using a known release ID
release_id: ${{ steps.create_release.id }}
# Using a tag name
tag: 'v1.0.1'
# If the release does not exist but the tag does, setting this to true will remove the tag.
delete_orphan_tag: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
It's a bit easier to understand in context of a complete workflow:
name: Publish
on:
push:
branches:
- master
jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Tag
id: autotagger
uses: butlerlogic/action-autotag@stable
with:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
- name: Release
id: create_release
if: steps.autotagger.outputs.tagname != ''
uses: actions/create-release@v1.0.0
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.autotagger.outputs.tagname }}
release_name: Version ${{ steps.autotagger.outputs.version }}
body: ${{ steps.autotagger.outputs.tagmessage }}
draft: false
prerelease: true
- name: Publish
id: publish_npm
if: steps.autotagger.outputs.tagname != ''
uses: author/action-publish@stable
env:
REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }}
- name: Rollback Release
if: failure() && steps.create_release.outputs.id != ''
uses: author/action-rollback@stable
with:
# Using a known release ID
id: ${{ steps.create_release.id }}
# Using a tag name
tag: ${{ steps.autotagger.outputs.tagname }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Only the id
or tag
need to be specified. If a publish fails, the release will be removed.
It's a way to clean up messy processes.
It may seem unnecessary at first. However; it is useful when a release is removed through other means, leaving an orphan tag.
Technically, this attribute could be used if you only need to rollback tags of any kind (regardless of whether a release exists).
This action was written and is primarily maintained by Corey Butler.
If you use this or find value in it, please consider contributing in one or more of the following ways:
- Click the "Sponsor" button at the top of the page.
- Star it!
- Tweet about it!
- Fix an issue.
- Add a feature (post a proposal in an issue first!).
Copyright © 2020 Author.io, Corey Butler, and Contributors.