DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’»

DEV Community πŸ‘©β€πŸ’»πŸ‘¨β€πŸ’» is a community of 967,611 amazing developers

We're a place where coders share, stay up-to-date and grow their careers.

Create account Log in
Cover image for Atomic Release: An all-or-nothing strategy to releaseΒ code.
Elad Chen
Elad Chen

Posted on

Atomic Release: An all-or-nothing strategy to releaseΒ code.

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

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

See GithubNpmPackageStrategy 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.

Top comments (0)

Take a look at this:

Settings

Go to your customization settings to nudge your home feed to show content more relevant to your developer experience level. πŸ›