Release your first package
In this tutorial, you set up unirelman in a small npm package, record a bug fix, and release it: the version in package.json goes from 1.0.0 to 1.0.1, a changelog is written, and the release is committed and tagged.
Everything runs locally: publishing to npm stays off.
Prerequisites
Section titled “Prerequisites”Create the project
Section titled “Create the project”-
Create a folder with a Git repository:
Terminal window mkdir my-packagecd my-packagegit init -b main -
Create a
package.jsonat version1.0.0:package.json {"name": "my-package","version": "1.0.0","type": "module"} -
Create a
.gitignorethat excludes the installed dependencies:.gitignore node_modules -
Install the unirelman CLI and the plugins this tutorial uses:
Terminal window npm i -D @unirelman/cli @unirelman/core @unirelman/plugin-changesets @unirelman/plugin-changelog @unirelman/plugin-npm @unirelman/plugin-git @unirelman/plugin-semverTerminal window pnpm add -D @unirelman/cli @unirelman/core @unirelman/plugin-changesets @unirelman/plugin-changelog @unirelman/plugin-npm @unirelman/plugin-git @unirelman/plugin-semverTerminal window yarn add -D @unirelman/cli @unirelman/core @unirelman/plugin-changesets @unirelman/plugin-changelog @unirelman/plugin-npm @unirelman/plugin-git @unirelman/plugin-semverTerminal window bun add -d @unirelman/cli @unirelman/core @unirelman/plugin-changesets @unirelman/plugin-changelog @unirelman/plugin-npm @unirelman/plugin-git @unirelman/plugin-semver
Configure unirelman
Section titled “Configure unirelman”Create unirelman.config.ts at the root of the project:
import { defineConfig } from "@unirelman/cli";import { createChangelogPlugin } from "@unirelman/plugin-changelog";import { createChangesetsPlugin } from "@unirelman/plugin-changesets";import { createGitPlugin } from "@unirelman/plugin-git";import { createNpmPlugin } from "@unirelman/plugin-npm";import { createSemverPlugin } from "@unirelman/plugin-semver";
export default defineConfig({ scopes: { "my-package": "./", }, plugins: [ createChangesetsPlugin(), createChangelogPlugin(), createNpmPlugin({ publish: false }), createGitPlugin(), createSemverPlugin(), ],});This configuration declares one scope, my-package, at the root of the project. Each plugin handles one part of the release:
- Changesets reads the changes you record.
- SemVer computes the next version from them.
- npm reads and writes the version in
package.json. Withpublish: false, it manages the version only. - Changelog writes
CHANGELOG.md. - Git commits the release and creates the tag.
Commit this initial state:
git add .git commit -m "chore: set up unirelman"Record a change
Section titled “Record a change”Describe a bug fix with a changeset:
npx unirelman changesets create --scopes my-package --level patch --message "fix a bug"pnpm unirelman changesets create --scopes my-package --level patch --message "fix a bug"yarn unirelman changesets create --scopes my-package --level patch --message "fix a bug"bunx unirelman changesets create --scopes my-package --level patch --message "fix a bug"Without options, the command prompts for the scopes, the level, and the message.
The command creates a file under .unirelman/changesets/:
Directory.unirelman/
Directorychangesets/
- 1767268800000-1f2e3d4c.md
- .gitignore
- package.json
- unirelman.config.ts
---scopes: my-packagelevel: patch---
fix a bugThe filename changes on every run. Commit the changeset like any other change of your project:
git add .git commit -m "fix: fix a bug"Preview the release
Section titled “Preview the release”Run the version pipeline as a dry run, which changes nothing:
npx unirelman version --dry-runpnpm unirelman version --dry-runyarn unirelman version --dry-runbunx unirelman version --dry-runThe summary shows the next version, my-package: 1.0.0 → 1.0.1. Add --verbose to see the files the release writes and deletes.
Release
Section titled “Release”-
Apply the next version:
Terminal window npx unirelman versionTerminal window pnpm unirelman versionTerminal window yarn unirelman versionTerminal window bunx unirelman versionunirelman:
- sets
"version": "1.0.1"inpackage.json, - writes
CHANGELOG.md, - deletes the changeset,
- commits these files with the message
chore(release): bump versions.
- sets
-
Publish the version:
Terminal window npx unirelman publishTerminal window pnpm unirelman publishTerminal window yarn unirelman publishTerminal window bunx unirelman publishThe Git plugin creates the tag
1.0.1on the release commit.
Check the result
Section titled “Check the result”The changelog contains the release:
# Changelog
## my-package - 1.0.1
### Patch changes
- fix a bugGit shows the release commit and its tag:
git log --oneline --decoratea0945d8 (HEAD -> main, tag: 1.0.1) chore(release): bump versions5d6e7f8 fix: fix a bug3c1b2a7 chore: set up unirelmanYou released your first version with unirelman.