relnote docs · GitHub Action · CHANGELOG.md · Python packages · npm packages · Rust crates · Monorepo

Release notes for a Go module from git tags

The version a Go module publishes is the git tag. relnote turns the commits between two tags, such as v1.2.0..v1.3.0, into a GitHub Release body. For v2 and later, the module path in go.mod ends with /vN. No config file.

1. The module path lives in go.mod

module github.com/you/demo

go 1.22

go.mod names the module and the Go version. It has no version field for relnote to bump. The version other modules require is the tag you push (v1.2.0, v1.3.0). pkg.go.dev and the module proxy resolve that tag; the GitHub Release body is separate, and it is what this page writes.

Starting at major version 2, the module path must end with a major-version suffix that matches the tag (Go modules reference). v0 and v1 have no suffix.

module github.com/you/demo/v2

go 1.22

That file is the v2.0.0 module. When it sits in the repository root, or in a major-version subdirectory named v2, the tag is v2.0.0, not v2/v2.0.0. The suffix is part of the module path, not a tag prefix. A module in some other subdirectory (for example golang.org/x/tools/gopls) does use a prefix, gopls/v0.4.0. Pass --tag-prefix gopls/v and, if you want only that directory, --path gopls. See monorepo release notes.

2. Notes between two tags

Three commits since v1.2.0:

git log --oneline v1.2.0..HEAD
docs: note the /v2 module path
fix: return a sentinel error from Open
feat(api): add a context to Client.Do

Install relnote (pipx install git+https://github.com/loki-inu/relnote.git, brew install loki-inu/tap/relnote, or the single file). Before you tag, the next version from those commits is a minor bump, because one of them is a feat:

python3 -m relnote --next-version
v1.3.0

Tag that (git tag -a v1.3.0 -m v1.3.0) and print the notes for the range. --since is exclusive and --until is inclusive, same as git log v1.2.0..v1.3.0:

python3 -m relnote --since v1.2.0 --until v1.3.0
## What's changed

### Features

- **api:** add a context to Client.Do (`b97ce10`) — Ada Lovelace

### Fixes

- return a sentinel error from Open (`4ca3722`) — Ada Lovelace

### Other

- **docs:** note the /v2 module path (`cbfba98`) — Ada Lovelace

---

Range: `v1.2.0` → `v1.3.0`.

**Full changelog:** https://github.com/you/demo/compare/v1.2.0...v1.3.0

Output from a test repository built in relnote's CI (tests/test_go_module_docs.py); your hashes differ. Once HEAD is the new tag, the same text comes from no flags at all. The range starts at the previous tag and the compare link ends at v1.3.0, not at HEAD:

python3 -m relnote

To write a file and stay quiet:

python3 -m relnote --since v1.2.0 --until v1.3.0 --output notes.md --quiet

3. GitHub Actions on a tag push

Save as .github/workflows/release.yml. Pushing v1.3.0 checks out the full history, runs the action, and creates the GitHub Release. The notes output is the body. It is passed through env: because commit subjects can contain backticks:

name: Release
on:
  push:
    tags: ["v*"]
jobs:
  release:
    runs-on: ubuntu-latest
    permissions:
      contents: write
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      - id: relnote
        uses: loki-inu/relnote@v0.3.8
      - env:
          GH_TOKEN: ${{ github.token }}
          GH_REPO: ${{ github.repository }}
          NOTES: ${{ steps.relnote.outputs.notes }}
        run: |
          printf '%s\n' "$NOTES" > notes.md
          gh release create "$GITHUB_REF_NAME" --verify-tag --notes-file notes.md

fetch-depth: 0 is required. The default checkout is one commit with no tags, so relnote cannot find v1.2.0. On a tag push, HEAD is the new tag, and the action starts the range at the tag before it. The action's no-bots input defaults to true, so Dependabot and Renovate commits are left out; the CLI includes them unless you pass --no-bots. The sample above has neither, so the Release body matches it. More workflows (a draft Release, has-changes, changelog): GitHub Action guide.

4. Alongside GoReleaser

If you already publish with GoReleaser, it can take the notes from a file. The release docs say --release-notes=FILE skips GoReleaser's own changelog and uses that Markdown file instead:

python3 -m relnote --since v1.2.0 --until v1.3.0 --output notes.md --quiet
goreleaser release --clean --release-notes=notes.md

On a tag push, the same flag is the args input of goreleaser/goreleaser-action. Their example listens for every tag and checks out with fetch-depth: 0 (GoReleaser needs the history too). The workflow below listens for v*, which is the form Go module tags take, writes the action's notes to notes.md, and passes that path. Checkout and setup-go are the major versions in that guide:

name: goreleaser
on:
  push:
    tags: ["v*"]
permissions:
  contents: write
jobs:
  goreleaser:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v7
        with:
          fetch-depth: 0
      - name: Set up Go
        uses: actions/setup-go@v7
        with:
          go-version: stable
      - id: relnote
        uses: loki-inu/relnote@v0.3.8
      - name: Write notes
        env:
          NOTES: ${{ steps.relnote.outputs.notes }}
        run: printf '%s\n' "$NOTES" > notes.md
      - name: Run GoReleaser
        uses: goreleaser/goreleaser-action@v7
        with:
          distribution: goreleaser
          version: "~> v2"
          args: release --clean --release-notes=notes.md
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Two limits from those docs. If changelog.disable is true, GoReleaser ignores --release-notes and the release notes are empty. If a GitHub Release for the tag already has body text, GoReleaser keeps it unless release.mode is replace (the default is keep-existing). Use this workflow instead of the gh release create job above, not after it. The GoReleaser action does not install Go; the setup-go step does.

FAQ

Does relnote read go.mod?

No. It reads git tags and commits. go.mod keeps the module path and the go line. The version other modules require is the tag, such as v1.3.0.

What changes at v2?

Starting at major version 2, the module path must end with a major-version suffix that matches the tag, such as github.com/you/demo/v2 for the tag v2.0.0. v0 and v1 have no suffix. When the module is in the repository root, or in a major-version subdirectory named v2, the tag is v2.0.0, not v2/v2.0.0. A module in some other subdirectory uses a tag prefix such as gopls/v0.4.0; pass --tag-prefix, as on the monorepo page.

Why fetch-depth: 0?

The default checkout is one commit and has no tags, so relnote cannot find the previous release. On a tag push, HEAD is the new tag, and relnote starts the range at the tag before it.

How do I give the notes to GoReleaser?

goreleaser release --release-notes=notes.md uses that Markdown file and skips GoReleaser's own changelog. The same flag goes in the args input of goreleaser/goreleaser-action. If changelog.disable is true, GoReleaser ignores --release-notes and the release notes are empty. If a release for that tag already has body text, GoReleaser keeps it unless release.mode is replace (the default is keep-existing).

Does pkg.go.dev read the GitHub Release body?

No. The module proxy and pkg.go.dev resolve the version from the git tag. The Release body is for people reading the repository on GitHub.

How do I pick the next tag?

python3 -m relnote --next-version prints it from the commits since the previous tag: a breaking change bumps the major, a feat bumps the minor, and anything else bumps the patch. While the major is 0, a breaking change bumps the minor. v2.0.0 is the point where the module path gains /v2.