A minimal Go module that demonstrates semantic-version-driven release automation.
The current version is baked into the binary at compile time via go:embed and is
automatically bumped on a schedule by a GitHub Actions workflow.
- Embedded version —
VERSION.txtis embedded into the module at build time, so every binary knows exactly which version it is. - Auto version bumping — a GitHub Actions workflow bumps the patch version every day (11:00 Beijing time), tags it, and pushes the release.
- Tiny version tool —
cmd/bumpreadsVERSION.txtand prints the next patch version, using the officialgolang.org/x/mod/semverpackage.
Install the command-line tool:
go install github.com/qq1u/modtest/cmd/modtest@latestmodtest
# 2026/09/21 22:40:20 Version: v0.0.1import "github.com/qq1u/modtest"
fmt.Println("current version:", modtest.Version)VERSION.txtholds the current version (e.g.v0.0.1).version.goembeds it with//go:embed VERSION.txtand exposes it as the exportedmodtest.Version.cmd/bumpparses the file, increments the patch number and prints the next version:
go run ./cmd/bump # reads VERSION.txt, prints e.g. v0.0.2The workflow in .github/workflows/bump.yml runs:
- Every day at 03:00 UTC (11:00 Beijing time), or
- Manually via the Run workflow button (Actions → Bump → Run workflow).
Each run:
- Computes the next version with
cmd/bump. - Checks the remote tags via
git ls-remoteand skips if the version was already published. - Builds the whole module (
go build ./...) — a failing build never gets released. - Writes the new version to
VERSION.txt, commits, tags (vX.Y.Z) and pushes.
Published versions are immediately usable with Go tooling:
go get github.com/qq1u/modtest@latest
go list -m -versions github.com/qq1u/modtest
go install github.com/qq1u/modtest/cmd/modtest@latestNote: after a tag is pushed, proxy.golang.org takes a few minutes to index it.
MIT — see LICENSE.