Manage your versioning and changelogs using Changesets

Think ThrooThink Throo
2 min read

In this article, an overview of Changesets and its usage in t3-env are provided.

What is changesets?

This is the official definition provided in changesets repository Readme.

The changesets workflow is designed to help when people are making changes, all the way through to publishing. It lets contributors declare how their changes should be released, then we automate updating package versions, and changelogs, and publishing new versions of packages based on the provided information.

Changesets has a focus on solving these problems for multi-package repositories, and keeps packages that rely on each other within the multi-package repository up-to-date, as well as making it easy to make changes to groups of packages.

How does Changesets do it?

A changeset is an intent to release a set of packages at particular semver bump types with a summary of the changes made.

The @changesets/cli package allows you to write changeset files as you make changes, then combine any number of changesets into a release, that flattens the bump-types into a single release per package, handles internal dependencies in a multi-package-repository, and updates changelogs, as well as release all updated packages from a mono-repository with one command.

Using Changesets:

This intro guide explains the basics.

The overall tool after initialization should lead to a loop that looks like:

  1. Changesets added along with each change

  2. The version command is run when a release is ready, and the changes are verified

  3. The publish command is run afterwards.

Basic steps to configure changesets in your project

  1. Install changesets and initialize
npm install @changesets/cli && npx changeset init

2. Add changesets

npx changeset

When you run this command, you are prompted with questions about:

  • Packages you want to release

  • Semver bump type for each package

  • Summary of entire changeset.

3. Versioning

npx changeset version

4. Publishing

npx changeset publish

Read this commands documentation to learn more about these commands such as init, version, publish etc.,

About us:

At Thinkthroo, we study large open source projects and provide architectural guides. We have developed reusable Components, built with tailwind, that you can use in your project. We offer Next.js, React and Node development services.

Book a meeting with us to discuss your project.

References:

  1. https://github.com/changesets/changesets

  2. https://github.com/t3-oss/t3-env/tree/main/.changeset

  3. https://github.com/changesets/changesets/blob/main/docs/common-questions.md

  4. https://changesets-docs.vercel.app/

0
Subscribe to my newsletter

Read articles from Think Throo directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Think Throo
Think Throo