Socket
Book a DemoInstallSign in
Socket

@mlaursen/release-script

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mlaursen/release-script

The release script I normally use for packages I publish to npm

latest
Source
npmnpm
Version
0.0.6
Version published
Maintainers
1
Created
Source

@mlaursen/release-script

This is the normal npm release script I use. This requires:

  • changesets to handle bumping versions and generating changelogs.
  • A Github release token
    • The token only needs repository access
    • This is normally stored as GITHUB_TOKEN in an .env.local file that should not be committed

Installation

The release script relies on changesets to handle bumping versions and generating changelogs.

pnpm install --save-dev @mlaursen/release-script \
  @changesets/cli \
  tsx

Setup the .changeset dir if needed:

pnpm changeset init
git add .changeset
git add -u
git commit -m "build: setup changesets"

Usage

Create a scripts/release.ts file with:

import { release } from "@mlaursen/release-script";

await release({
  repo: "{{REPO_NAME}}", // i.e. eslint-config

  // if the repo is not under `mlaursen` for some reason
  // owner: "mlaursen",

  // If there is a custom clean command for releases. `clean` is the default
  // cleanCommand: "clean",

  // If there is a custom build command for releases. `build` is the default
  // buildCommand: "build",

  // An optional flag if the build step should be skipped. `!buildCommand` by default
  // skipBuild: process.argv.includes("--skip-build"),

  // This is useful for monorepos where only a single Github release needs to
  // be created. Defaults to `JSON.parse(await readFile("package.json)).name`
  // mainPackage: "{{PACKAGE_NAME}}",

  // If the version message needs to be customized. The following is the default
  // versionMessage: "build(version): version package",

  // An optional `.env` file path that includes the `GITLAB_TOKEN` environment
  // variable.
  // envPath: ".env.local",

  // An optional async function to get the next release tag name. The default
  // is shown below:
  // getTagName: async () => {
  //   const latestTag = await (
  //     await import("@react-md/release-script")
  //   ).getLatestTag();
  //   let tagName =
  //     mainPackage && /@\d/.test(latestTag)
  //       ? latestTag.replace(/.+(@\d)/, `${mainPackage}$1`)
  //       : latestTag;
  //
  //   return tagName;
  // },
});

Next, update package.json to include the release script:

   "scripts": {
     "prepare": "husky",
     "typecheck": "tsc --noEmit",
     "check-format": "prettier --check .",
     "format": "prettier --write .",
     "clean": "rm -rf dist",
     "build": "tsc -p tsconfig.json",
+    "release": "tsx index.ts"
   },

Finally, run the release script whenever a new release should go out:

pnpm release

Alpha Releases

Use the changesets api to enter the pre-release flow:

pnpm changeset enter pre

Once ready to do a real release:

pnpm changeset exit pre

Keywords

release

FAQs

Package last updated on 01 Nov 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts