Release it like it's hot - step by step release flow set up for your apps and addons

When we get to the final step of releasing a piece of code we always find ourselves doing repetitive manual work. We probably have to have the release process documented somewhere and always make sure we follow all the steps in the right order. On the other hand, if more people are involved in this process, we need to make sure everyone follows the instructions and things won't blow on this critical step. Still, this is error-prone, since it's not something that can be enforced to the person in charge.

Happy pressing buttons

Ideal release flow

So how would the ideal release flow look like? How can we make it stress-free and empower others to do this? Wouldn't it be nice to do it with one command only, the same we're used to deploying? Wouldn't it be great to not having to leave the command line, to create a release on GitHub for example, or do anything else that might be related? Wouldn't it be cool to have a changelog generated automatically? Or to customize it the way we want? How about telling it to make us a coffee before the release and have it tell us how awesome we are every time it finishes it?

How do we do it?

Thanks to all the existing solutions out there we can have all of the above. We will handle the automatic versioning using Release It and generate the changelog using Lerna Changelog. But how do we get them working together, in the same command? Luckily, Release It is highly configurable and extendible through plugins. And thanks to Robert Jackson we can make use of release-it-lerna-changelog plugin.

To make use of these run the following command:

npm install release-it lerna-changelog release-it-lerna-changelog

We'll configure them next.

How does it look like?

I highly recommend reading through the documentation of these 3 packages and understand how they work and how you can best configure them for your use case. Once we install them we only have to set a command in package.json and configure the release-it package. We can configure that in package.json or in a separate file .release-it.json.

// package.json

"scripts": {
  ...
  "release": "release-it"
}
// .release-it.json

{
  "git": {
    "tagName": "v${version}",
    "commitMessage": "v${version}",
    "pushArgs": "--follow-tags --no-verify"
  },

  "npm": {
    "publish": false
  },

  "github": {
    "release": true
  },

  "plugins": {
    "release-it-lerna-changelog": {
      "infile": "CHANGELOG.md"
    }
  }
}

Important steps to follow

First of all and once again, make sure you read through the documentation of these packages and don't skip anything.

Important! Remember to get a GitHub personal access token and set it up for release-it and lerna-changelog to interact with your Github account. You can also find these instructions in the release-it and lerna-changelog documentation but I feel the need to also repeat it here. Make sure the token is available as environment variables:

For release-it

export GITHUB_TOKEN="your_github_token"

For lerna-changelog

export GITHUB_AUTH="your_github_token"

Replace your_github_token with your actual token generated on GitHub.

Now, all we have to do is go to our terminal, run npm run release and see the magic happening. Happy releasing!

Easy pressing buttons

Many thanks to my friend Maciej Kwaśniak for guiding me in the right direction with this setup and also to all the contributors to these projects, without whom none of this would have been possible.

Subscribe for more like this!

Drop your email below and I'll send you new stuff to your inbox!

No spam, ever. I respect your email privacy. Unsubscribe anytime.

Read more similar articles