ArcherGu / mono-release

A tiny monorepo release tool

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Mono Release πŸŽ‰

npm npm GitHub Workflow Status

A tiny monorepo release tool.

Features

  • ➑️ Select a package to operate
  • πŸ€– Automatic version derivation
  • πŸ”– Semantic version by semver
  • βœ… Configure via file or command line
  • πŸ”’ Branch protection
  • πŸ›ž Rollback protection
  • πŸ“„ Changelog by conventional-changelog-cli
  • πŸ“¦ Unlimited package manager
  • πŸ“’ Also contains a publish command

Install

npm i mono-release -D
# Or Yarn
yarn add mono-release -D
# Or PNPM
pnpm add mono-release -D

Note: You may need to add -W flag to install it in a monorepo workspace.

Usage

Use directly:

npx mono-release
# Or
npx mor

Or through a script in package.json:

{
  "scripts": {
    "release": "mono-release"
  }
}

Publish

It also provides a command for publishing packages:

npx mono-release publish bar@0.0.1

The tag format must be: <pkg>@<version>.

Configuration

You can add a "mono-release" key to package.json to add configuration for it:

{
  "mono-release": {
    "packagesPath": "packages-path",
    "exclude": ["pkg-will-not-be-released"],
    "changelog": true,
    "dry": false,
    "push": true
  }
}

mono-release.config.ts ('.js' | '.cjs' | '.mjs' | '.json') is also available:

import { defineConfig } from 'mono-release'

export default defineConfig({
  packagesPath: 'packages-path',
  exclude: ['pkg-will-not-be-released'],
  changelog: true,
  dry: false,
  push: true
})

CLI Options

config

mono-release --config mono-release.config.ts

Use specified config file.

specified package

mono-release --specified-package pkg-name

Specified package which will be released, skip selector, ignore exclude.

changelog

mono-release --changelog
# Or disabled
mono-release --no-changelog

Whether to generate changelog.

Note: You need to install conventional-changelog-cli to generate changelog.

include

mono-release --include pkg1,pkg2,pkg3

Include packages, if specified, this tool will only work on specified packages, exclude will override include.

exclude

mono-release --exclude pkg1,pkg2,pkg3

Excludes specified packages (These packages will not appear in the list of options).

dry

mono-release --dry

Dry run. (default: false)

disable push

mono-release --disable-push
# Or disabled
mono-release --no-push

By default, this tool will push commit and tag to remote, use this option to disable it. (default: false)

commit check

mono-release --commit-check
# Or disabled
mono-release --no-commit-check

Whether to check commit before release. (default: true)

Warning: If disabled, you may lose all uncommited changes when rollback.

version type

mono-release --version-type alpha-minor

Default version type, if you specify it, will skip version select action. (default: undefined) Available values: next, alpha-minor, alpha-major, beta-minor, beta-major, minor, major.

ci

mono-release --ci

Run in CI mode, will skip all select actions, you must specify --specified-package.

ci msg suffix

mono-release --ci --ci-msg-suffix "[skip ci]"

Specify commit message suffix in CI mode, example: [skip ci].

before release

mono-release --before-release "npm run test"

You can specify command to be executed before release.

specified package manager

mono-release publish --use pnpm

Use specified package manager for publishing. (default: npm)

Note: Some packages may depend on other packages under the same monorepo, and publishing with a specific package manager can handle these relationships automatically. (eg, pnpm workspace protocol)

before publish

mono-release publish --before-publish "npm run test"

You can specify command to be executed before publish.

Note: The default cwd is the package directory when running before publish command

help

mono-release --help

Print help information.

version

mono-release --version

Print the version.

How it works

When you need release a package from monorepo project, you can run this tool to execute a command-line script, which you can select the package that needs to release and select a recommended version. It will automatically generate a commit message about this release, and push this commit. In addition, a tag about this version will also be pushed.

Much of the code for this tool references Vite's release scripts. You can observe the details of its release to understand more how it works

License

MIT License Β© 2022 Archer Gu

About

A tiny monorepo release tool

License:MIT License


Languages

Language:TypeScript 99.1%Language:JavaScript 0.9%