Skip to content

About

A Changesets changelog generator for GitHub repositories that links each entry to its pull request and commit and omits the contributor attribution.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

118 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

changelog-github-custom

CI npm version npm downloads License

A Changesets changelog generator for GitHub repositories. It is adapted from @changesets/changelog-github and keeps its summary front-matter and link resolution, so each entry is linked to its pull request and commit. It never prints the Thanks @user! attribution, and a failed GitHub lookup writes the entry without links instead of aborting changeset version. See How it differs from @changesets/changelog-github for the full list.

This repository's own CHANGELOG.md is generated by this package.

Install

pnpm add -D changelog-github-custom
npm install --save-dev changelog-github-custom

Configuration

Point the changelog entry in .changeset/config.json at this package and pass the owner/repo slug of your GitHub repository:

{
  "changelog": ["changelog-github-custom", { "repo": "owner/repo" }]
}

repo is the only option and it is required. It must be a non-empty string. If the options object is missing, or repo is absent, empty or not a string, the generator throws before any GitHub call:

Please provide a repo to this changelog generator like this:
"changelog": ["changelog-github-custom", { "repo": "org/repo" }]

The slug is not checked for owner/repo shape. A malformed slug only shows up later, as a lookup warning on stderr and entries without links. Unknown keys are ignored. In particular the disableThanks and template options of @changesets/changelog-github have no effect.

The Options type is exported for anyone typing the configuration in TypeScript:

import type { Options } from 'changelog-github-custom';

This repository points its own .changeset/config.json at ../dist/esm/changelog-custom.js because it uses its local build. In your project use the package name as shown above.

GitHub token

PR and commit links are resolved through @changesets/get-github-info, which calls the GitHub API. Set GITHUB_TOKEN in the environment where changeset version runs, for example:

GITHUB_TOKEN=ghp_... pnpm changeset version

In GitHub Actions the workflow token works:

- run: pnpm changeset version
  env:
    GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Lookups are best-effort. Each changelog entry makes at most one GitHub API call. If that call throws, for example because GITHUB_TOKEN is missing, the repo slug is wrong or the rate limit is exhausted, the entry is still written without links, changeset version continues, and one line is written to stderr:

changelog-github-custom: GitHub lookup failed, writing entry without links: <reason>

If the call succeeds but GitHub reports no such PR or commit, the entry is also written without links. Nothing is written to stderr in that case.

Usage

Write changesets as usual with pnpm changeset. When changeset version runs, each changeset summary becomes one changelog entry. The release type (patch, minor or major) does not change the entry text.

Summary front-matter

A changeset summary can carry metadata lines. A metadata line is recognised on any line of the summary, not only the first ones. Keys are case-insensitive and the whitespace after the colon is flexible. Each recognised line is removed from the summary before it is written to the changelog.

Line Effect
PR: #123 (also pull: and pull request:; # is optional) Link the entry to pull request 123. Only the first matching line is used.
commit: <sha> Use this commit for the commit link instead of the one derived from the PR or the changeset. Only the first matching line is used. The value is not validated.
author: @user / user: @user (@ is optional) Removed. Every matching line is removed. This generator does not print attribution, so the value is discarded.

Always put the value on the same line as the key. The whitespace after the colon may span a line break, so a key with nothing after it can swallow the first word of the next line as its value.

Link resolution

The links in front of an entry are resolved in one of three ways:

  1. With a PR: line the generator looks up that pull request. The PR link and the commit link come from the response; the commit link is the PR's merge commit. The commit that added the changeset file is not used. If a commit: line is also present, the commit link is built locally as [`<first 7 characters>`](https://github.com/<repo>/commit/<value>) without an API call. If the PR lookup fails or the PR is not found, the entry is written without any links, and the commit: value is dropped too.
  2. Without a PR: line the generator looks up one commit: the commit: value if present, otherwise the commit that added the changeset file. The commit link comes from the response, and so does the PR link if GitHub reports a pull request for that commit.
  3. When there is no PR: line, no commit: line and no changeset commit, no API call is made and the entry has no links.

Example changeset:

---
'my-package': patch
---

PR: #123
author: @octocat

Fix a crash when the config file is empty.

The loader now treats an empty file the same as `{}`.

Example output

## 1.2.10

### Patch Changes

- [#123](https://github.com/owner/repo/pull/123) [`b4092b5`](https://github.com/owner/repo/commit/b4092b5b6247bcd64f318c3c8a2eebdb00655b09) - Fix a crash when the config file is empty.

  The loader now treats an empty file the same as `{}`.

- Updated dependencies [[`51da22a`](https://github.com/owner/repo/commit/51da22a453d0d6d8c4b79f5321aa7bdfa04c9d9c)]:
  - my-other-package@2.0.1

An entry is - <PR link> <commit link> - <first line>. The PR link comes first and either link may be absent. When neither link is available the - separator is omitted and the entry is - <first line>. Continuation lines are indented by two spaces. Trailing whitespace is removed from every line, and a blank line inside the summary becomes a line containing two spaces.

The Updated dependencies line lists one commit link per changeset that has a commit. The commit lookups run in parallel. If several changesets share a commit, it is looked up and listed once per changeset. Changesets without a commit, commits GitHub does not find and failed lookups are left out of the brackets. When nothing resolves the line reads - Updated dependencies []:. When no dependencies were updated the generator returns an empty string, after the repo check.

How it differs from @changesets/changelog-github

The source is adapted from @changesets/changelog-github. Front-matter parsing and link resolution match upstream 1.0.x. The output and configuration differ as follows:

Behavior @changesets/changelog-github changelog-github-custom
Attribution Prints Thanks @user! unless disableThanks is set Never printed. There is no disableThanks option.
template option Supported Not supported. The key is ignored.
repo option Falls back to GITHUB_REPOSITORY from the environment or a .env file Required. The generator throws without it.
GitHub lookup failure Aborts changeset version Writes the entry without links and warns on stderr.
GITHUB_SERVER_URL Honored, so GitHub Enterprise links work Not read. The commit: override link always points at https://github.com.
Bare #123 issue references Turned into links Left as plain text.
Unresolved dependency commit Shown as an unlinked short SHA Omitted from the brackets.

Requirements

  • Node.js 22.12 or later. This is the first Node release where require(esm) is enabled by default, so require() of the ESM entry works on every supported version.
  • The package is published as ESM only, with TypeScript declarations included. Changesets loads changelog modules with import(), so this works with any Changesets setup. require() also works on Node 22.12+.
  • The only runtime dependencies are @changesets/get-github-info and @changesets/types.

Development

Development uses Node 24 and pnpm 11.20.0, pinned in mise.toml and the packageManager field. pnpm setup installs the toolchain with mise when it is available, installs dependencies, runs pnpm verify and builds.

Command What it does
pnpm verify Full CI-equivalent set: audit, dependency check, typecheck, lint, format check, tests with coverage
pnpm quick-check Typecheck, lint and test. The pre-push hook runs this.
pnpm build Clean and build the ESM output into dist/
pnpm test Run the Vitest suite
pnpm changeset Add a changeset. Use pnpm changeset --empty for changes that do not touch the published code.

Commits follow Conventional Commits and are checked by commitlint. Every pull request needs a changeset. On push to main, CI versions the package from the pending changesets, tags the release, publishes to npm through OIDC trusted publishing with provenance, and attaches a CycloneDX SBOM to the GitHub release. AGENTS.md and .github/WORKFLOWS.md describe the tooling and the workflows in detail.

License

MIT

About

A Changesets changelog generator for GitHub repositories that links each entry to its pull request and commit and omits the contributor attribution.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages