Transactions/rollback tasks

I’m looking to create a task that runs a group of other tasks but performs a rollback on the entire group if any of the tasks fails.

For example, let’s say I have tasks createBranch, tagCommit, pushTags and publishArtifact. I’d like to be able to run one task, releaseNewVersion that runs these in order but let’s say if pushTags fails, it runs rollback tasks for createBranch and tagCommit.

What would be a good way to achieve this?