Atomic Release: An all-or-nothing strategy to release code.
Tags: semanticversion, javascript, automation, versionmanagement
Published: 2021-11-01 17:25:30

---
title: Atomic Release: An all-or-nothing strategy to release code.
published: true
description: An introduction to atomic-release
tags: semanticversion,javascript,automation, versionmanagement
cover_image: https://cdn-images-1.medium.com/max/800/1*0wxueK9g7tTQqs7nEiWmww.gif
---

Have you ever encountered a failure during a release process?
Did you have to "undo" steps taken before starting again?
If the answer to the above questions is yes, then keep reading.

---

**The problem**
A release process usually involves a series of automatic steps that must be performed to complete successfully, but what happens when a step fails?

If you want to start the release process with a clean slate
you have to determine which steps succeeded and "undo" whatever action they took… 😖

In other words, automated releases are rarely written to handle a failure, which means they leave a mess behind when a step fails halfway through.

![solution](https://cdn-images-1.medium.com/max/800/1*p7tJ7FMUu3B7muy3pbNLqQ.gif)

**The solution**
Realising the above problem, I figured it can be solved
using the "Command" design pattern, and so atomic-release came into existence.

Today I'm happy to announce the first release of atomic-release
an NPM package that aims to help create automated releases using the command pattern.

The package is more of an SDK than a general-purpose solution, it has 2 core concepts and a reference implementation for releasing NPM packages.

Highlights:

* TypeScript friendly.
* APIs are loosely coupled. Use just what you need.
* Can be used to automate the release of any project type.

## Core concept #1 - "Strategy"
An abstract class that decides whether a release should be made, and
the commands to execute during a release.

## Core concept #2 - "Command"
An abstract class with two methods, "do" which performs an action, and "undo" which undoes actions taken by the "do" method.

There are several pre-written commands available in the SDK.
See the commands docs for more details.

**You can also write your own commands! Here are a few random ideas:**

* **Slack**: A command that notifies a slack channel of a successful release.

* **Jira**: A command that comments on issues mentioned in the commits included in the release.

* … Anything you can think of

**GithubNpmPackageStrategy*
This strategy was created to illustrate an implementation of the SDK.

The strategy automates the release process end-to-end, it uses conventional commits to bump semantic versions, and generate change-logs.

Here's a demo showcasing a failure during a release and the undo taken:

![demo](https://cdn-images-1.medium.com/max/800/1*bxpNSdn7OflgbjVsTLeMeg.gif)

See [GithubNpmPackageStrategy](https://github.com/abstracter-io/atomic-release/blob/main/docs/strategies/github-npm-package-strategy.md) for more details.

> Fun fact:
> The package itself is released using GithubNpmPackageStrategy 🤯

---

If you are interested in learning more, head over to the official repository.

As always, If you have any questions or feedback, please leave a comment below.