Release-it with GitHub Actions

Overview

Release-it is a tool that helps automate a project's release process. It can be used to create releases, update changelogs, and publish releases to various platforms.

This document will explore how to use the release-it GitHub Action workflow that I've created to automate a project's release process.

The Problem

I'm about to start a new project, and I want to try and implement an automated versioning and release process. I've tried different implementations of this in the past, but it didn't really work out as I wanted it to.

Semantic-release was one of the tools, but there was a lot of configuration and setup involved. I wanted something simpler and easier to use.

I have used release-it in the past, and I liked how simple it was to use. I decided to use it again, but this time I wanted to automate the process using GitHub Actions while having a bit more control over versioning. I want the ability to set when to do a major, minor, or patch release.

The Solution

I created a GitHub Action workflow that uses the release-it package to automate the release process. The workflow is simple and easy to use. It only requires a few configurations to get started.

  • Self-contained: The workflow is self-contained and doesn't require the release-it package to be installed in the project. This makes it easier to use in different projects, perhaps projects that don't even use npm.

  • Simple: It requires minimal configuration and can be set up quickly. All you need is the GitHub Action workflow file and a release-it configuration file.

  • Bump based on PR labels: The workflow can be configured to bump the version based on the labels of the PRs merged into the main branch. This gives more control over when to do a major, minor, or patch release. Make sure to have major, minor, and patch labels in the PR before merging; it defaults to patch if no labels are found.

  • Cached NPM packages: The workflow caches the NPM packages to speed up the build process.

How to Use

To use the release-it GitHub Action workflow, you need to add the workflow file to your project and create a release-it configuration file.

1

Add the workflow file

Create a .github/workflows/release.yml with the following content:

  • Note: Make sure to update your repository settings to allow GitHub Actions read and write access to the repository. Settings > Actions > General > Workflow permissions > Read and write permissions.
2

Create the Release-it configuration file

Create a .release-it.json file in the root of your project with the following content:

3

Have one of the following labels in your PR.

  • release: major

  • release: minor

  • release: patch

4

Merge

Merge when you’re ready!

Updated on