Skip to content

chore(make): split version.mk into vendorable core#5656

Merged
norman-abramovitz merged 1 commit into
cloudfoundry:developfrom
nabramovitz:norm/chore/version-mk-reuse
Jul 19, 2026
Merged

chore(make): split version.mk into vendorable core#5656
norman-abramovitz merged 1 commit into
cloudfoundry:developfrom
nabramovitz:norm/chore/version-mk-reuse

Conversation

@nabramovitz

Copy link
Copy Markdown
Contributor

version.mk previously mixed reusable semver/build-metadata logic with
Stratos-specific configuration, which blocked dropping the file into
other repos (one already carries an unused verbatim copy for exactly
this reason).

The file is now a generic, vendorable core:

  • Version source is a VERSION_CMD hook. The default resolves the
    nearest git tag, strips a leading v, and increments the patch
    number ("the next release") — the behavior several candidate consumer
    repos already implement inline. Stratos overrides it with its
    package.json read.
  • Semver parts (SEMVER_MAJOR/MINOR/PATCH/PRERELEASE/BUILDMETA) are
    individually overridable (?=), and SEMVER_VERSION is reassembled
    from them, preserving any leading v byte-for-byte. This also fixes
    a latent parse bug: 1.2.3+meta (build metadata without prerelease)
    previously corrupted the patch field.
  • Unresolvable or malformed versions soft-fail to 0.0.0-unknown and
    leave a SEMVER_VALID flag empty, so a repo that wants a hard error
    can test the flag with one line.
  • BUILD_DATE is canonical zulu; new BUILD_DATE_SEMVER is the same
    instant in a colon-free form legal inside semver build-metadata
    identifiers; new BUILD_DATE_TZ carries builder-local time, or a
    forced zone via BUILD_TZ.
  • dump.version gains a dump.version.extra hook so the including
    Makefile can append its own lines.
  • The _HIDE prefix convention and the lazy-vs-immediate evaluation
    notes (bump/build chaining) survive. A repo preferring plain variable
    names sets _HIDE := (empty) before the include.

Stratos-specific pieces move to a version block in the Makefile:
the package.json VERSION_CMD, node/tsc/bun tool-version stamps, the
jetstream GO_LDFLAGS symbol map, the build-info.ts path with the
stamp.frontend recipe, and the GO_LDFLAGS dump line.

Verification: make dump version, make -n stamp frontend, and
make -n build backend outputs differ from the pre-change baseline
only by timestamps, the new fields, and BUILD_VCS_ID_DATE now being
zulu. The core was exercised as-is from two external repos (a BOSH
release repo and a cf CLI plugin repo): next-patch tag resolution
(4.0.1→4.0.2, 2.2.0→2.2.1), plain-name mode, per-part overrides,
meta-only versions, and the no-git soft fallback all behave. Full
check gate passes (frontend 3135 tests, backend suites green).

Closes #5652

version.mk is now a generic, repo-agnostic library that other repos can
vendor unchanged: semver parse/reassembly from overridable parts, a
VERSION_CMD source hook defaulting to nearest-tag-plus-one (next
release), soft 0.0.0-unknown fallback with a testable SEMVER_VALID
flag, zulu BUILD_DATE plus a semver-buildmeta-safe compact form and a
BUILD_TZ-controlled local/forced-zone variant, and a dump recipe with a
dump.version.extra extension hook.

Stratos specifics move to a version block in the Makefile: the
package.json VERSION_CMD, node/tsc/bun tool stamps, jetstream
GO_LDFLAGS symbol map, build-info.ts path and stamp.frontend recipe,
and the GO_LDFLAGS dump line.

Validated against the intended consumers: byte-identical semver output
for Stratos (dump/stamp/build differ only by timestamp and the zulu
BUILD_VCS_ID_DATE), and the core resolves next-patch versions from
tags in cfc-toolbelt-boshrelease (4.0.1->4.0.2) and
cfc-cf-targets-plugin (2.2.0->2.2.1) with plain names via _HIDE=,
part overrides, meta-only versions, and no-git soft fallback.

Closes cloudfoundry#5652

@norman-abramovitz norman-abramovitz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@norman-abramovitz
norman-abramovitz merged commit 2e91199 into cloudfoundry:develop Jul 19, 2026
22 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refine version.mk for reuse in other repos

2 participants