vercel/release

repository·master·Indexed 25 days ago

https://github.com/vercel/release

A CLI tool for automating GitHub Releases by generating release notes from commit history. It supports SemVer release types (major, minor, patch), pre-releases, and commit-based change type automation. Users can implement custom release hooks via a release.js file or the --hook flag to modify changelog markdown and metadata.

Tokens
831
Snippets
4
Records
6
Agent score
36%

What's inside release

  1. Create a GitHub Release

    master

    Run the release command in your project directory to generate a release. You can specify a SemVer release type or create a pre-release.

    Standard Release Types:

    • major: Incompatible API changes.
    • minor: Backwards-compatible functionality additions.
    • patch: Backwards-compatible bug fixes.

    If no type is provided, a release will be created from the most recent commit and tag.

    Pre-releases:

    • Use release pre to create a pre-release (e.g., 3.0.0-canary.1).
    • Use release pre <suffix> to specify a custom suffix (e.g., release pre beta results in 3.0.0-beta.1).
  2. Automate change types in commit messages

    master

    To speed up the release process and avoid manual type selection, you can pre-define the change type or exclusion status directly in your commit title or description using parentheses.

    • Define type: Add (patch), (minor), or (major) to the message.
    • Exclude commit: Add (ignore) to the message to prevent the commit from appearing in the release notes.
    Error logging works now (patch)
    This is a commit message (ignore)
  3. Install the release CLI

    master

    You can install the release command line tool globally using either npm or Yarn to automatically generate GitHub Releases based on your commit history.

    npm install -g release

    Or using Yarn:

    yarn global add release
  4. Implement a custom release hook

    master

    You can customize the release notes (e.g., adding intro text, replacing data, or reordering changes) by creating a release.js file in your project root. This file must export an async function that accepts markdown (the release notes as a string) and metaData, and returns a String representing the final release.

    Available metaData properties:

    • changeTypes: The types of changes and their descriptions.
    • commits: A list of commits since the latest release.
    • groupedCommits: Commits grouped by their change types.
    • authors: GitHub usernames of the release collaborators.

    To use a hook file at a different location, use the --hook or -H flag with a path relative to the current working directory.

    module.exports = async (markdown, metaData) => {
    	// Use the available data to create a custom release
    	return markdown;
    };
  5. Use a custom release hook to filter changelogs

    master

    You can provide a custom JavaScript file to intercept and modify the changelog markdown and changes data during the release process.

    To use a custom hook, you must provide the path to a JavaScript file via the --hook flag. If no flag is provided, the tool looks for a release.js file in the current working directory (process.cwd()).

    Hook Requirements:

    • The file must exist.
    • The file must export a single async function.
    • The exported function receives two arguments: markdown (the current changelog content) and changes (the list of changes).
    • The function should return the modified markdown string.

    If the hook file does not export a function or the file is missing, the process will fail.