Releasing basic projects
This tutorial will take you step by step through the process of:
- Documenting changes to a package
- Adding those changes to a changelog
- Updating version numbers
- Creating releases on GitHub
Prerequisites
- Git: The
git
CLI must be available in your terminal. It’s helpful if you know the basics of commits and tags. - A text editor: for editing Markdown and JSON files. Visual Studio Code is a good free choice.
- Familiarity with a command line terminal, like “Terminal” on macOS or “PowerShell” Windows
- A GitHub account (you can use an alternative, but the results will be different)
- Install Knope
Creating a project
Create a new directory for this tutorial and initialize a Git repository:
Now open the directory in your text editor and create two files:
This is simulating a JavaScript package—in a real package you’d have a lot more info in your package.json
file,
but version
is all that Knope needs.
This package is starting at version 1.0.0
,
as you make changes, the version will increase depending on the type of change.
Knope needs a GitHub repository to publish releases. You can create one with the GitHub CLI.
Little changes
Start by documenting a small change using a conventional commit.
You’ve just documented a bug fix using a commit message!
Knope can give a preview of the next release:
Example output from Knope
According to that output, Knope will:
- Set the version of the package in
package.json
to1.0.1
- Add a new section to
CHANGELOG.md
with the documented changes - Commit those changes to Git and push to the remote repo
- Create a new release on GitHub
Time to release it for real!
Creating a release
Running the release
workflow again without the --dry-run
option causes Knope to do everything it promised to.
Knope wants to create that GitHub release, but it needs access to GitHub! Go ahead and generate a token with the link it provided, then paste it into your terminal.
Now that the workflow has complete, the package.json
has the new version number:
The CHANGELOG.md
has the message from the commit:
And that same content is in a new GitHub release:
More complex changes
Conventional commits are great for simple changes, you just start your commit with fix:
or feat:
.
For changes that take more than a few words to describe, though, changesets are a better fit:
You’ll get a choice of the type of change.
The terms are from semantic versioning, so minor
is what you’ll want for a new feature:
After selecting minor
with the enter key, you can summarize the new feature:
This created a new Markdown file which you can fill in with more details:
You can also add a conventional commit into the same release:
A dry run will explain what Knope will do:
Example output from Knope
Uh oh, Knope is including the fix from the last version! That’s because Knope uses Git tags to figure out which conventional commits to include in a release. The release is on GitHub, but not in the local file system! You can fix that by pulling the tags:
Example output from Knope
Much better!
Now that Knope knows when 1.0.1
was, it can ignore the changes from that release.
Time to create this release for real:
This illustrates one of the big advantages to changesets, you can write as much Markdown content as you need to describe a change. There could be code snippets, screenshots, even collapsible sections!
Finishing up
You’ve done it! You documented both simple changes (with conventional commits) and complex changes (with changesets). Then, you released them by updating the changelog, bumping the version, and creating a GitHub release, all with a single command!
You already have the basic skills necessary to start speeding up your release processes, but you can take it a step further by releasing in GitHub Actions.