Skip to content

version: support OCI labels, version file in tar files, app version report, and dashboard (other dashboard enhancements) - #505

Open
gmarzot wants to merge 7 commits into
mainfrom
feature/dynamic-version
Open

version: support OCI labels, version file in tar files, app version report, and dashboard (other dashboard enhancements)#505
gmarzot wants to merge 7 commits into
mainfrom
feature/dynamic-version

Conversation

@gmarzot

@gmarzot gmarzot commented Jul 24, 2026

Copy link
Copy Markdown
Contributor

The deployed relay still reports 0.1.0 after the v0.2.1 release — the version is the static CMake project version and nothing updates it.

This bakes git describe --tags into the image at publish time:

  • release commit → bare tag: v0.2.1
  • main/PR snapshotv0.2.1-14-g<sha> — identifies exactly what's deployed
  • local builds → unchanged (static project-version fallback; the docker build context has no .git, hence the build-arg approach)

Flows to the dashboard badge through the existing /info → json-exporter → moqx_build_info chain — zero dashboard changes. Publish checkout gains fetch-depth: 0 so describe can see tags.

Caveat: the Dockerfile path only runs in the main publish job, so the proof is the first post-merge publish — the badge should flip from v0.1.0 to v0.2.1-N-g… on the following deploy.


This change is Reviewable

@gmarzot gmarzot self-assigned this Jul 24, 2026

@michalhosna michalhosna 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.

Why is this docker-only? Shouldn't we be able to bake this to every binary? Even for local-dev builds this would be nice.

I.e. move this logic from docker to cmake?

@michalhosna made 2 comments.
Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on afrind, gmarzot, and mondain).


.github/workflows/ci-main.yml line 389 at r1 (raw file):

          # Leading "v" stripped — /info reports bare semver-style ("0.2.1",
          # "0.2.1-14-gabc1234"); display layers add their own "v".
          echo "describe=$(git describe --tags --always | sed 's/^v//')" >> "$GITHUB_OUTPUT"

This may resolve to snapshot-latest, it probably needs some logic to only care about v prefixed tags?

@michalhosna michalhosna 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.

@michalhosna made 1 comment.
Reviewable status: 0 of 3 files reviewed, 1 unresolved discussion (waiting on afrind, gmarzot, and mondain).


.github/workflows/ci-main.yml line 389 at r1 (raw file):

Previously, michalhosna (Michal Hošna) wrote…

This may resolve to snapshot-latest, it probably needs some logic to only care about v prefixed tags?

Something like this should work

git describe --tags --match 'v[0-9].*'

@mondain mondain 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.

@mondain reviewed 3 files and all commit messages.
Reviewable status: all files reviewed, 1 unresolved discussion (waiting on afrind and gmarzot).

@gmarzot

gmarzot commented Jul 26, 2026

Copy link
Copy Markdown
Contributor Author

Why is this docker-only? Shouldn't we be able to bake this to every binary? Even for local-dev builds this would be nice.

I.e. move this logic from docker to cmake?

yes - good idea. updates added.

gmarzot added a commit that referenced this pull request Jul 27, 2026
Addresses review on #505.

Why docker-only was wrong: the version was a docker --build-arg, so only
published images carried a real one — local builds, release tarballs and
the artifact tarball all reported the static project version (0.1.0).
Derivation now lives in cmake/MoqxVersion.cmake with an explicit
precedence chain:

  1. -DMOQX_VERSION_STRING   explicit (release workflow passes the tag)
  2. <src>/VERSION           stamped by CI; docker + source tarballs have
                             no .git, so this is how they resolve
  3. git describe            any clone, including local dev builds
  4. v${PROJECT_VERSION}     last resort

Tag filtering is load-bearing. The repo carries moving non-version tags
(snapshot-latest, build-*, archive/*); an unfiltered describe returns
"snapshot-latest" as the version of every image built from main —
demonstrated on 4969f8c, where naive describe gives snapshot-latest and
--match 'v[0-9]*' gives the sha. The v prefix is kept: the string is a
git identifier and round-trips into git checkout / gh release view.

Generalization payoff, all verified in a container build:
- moqx --version            -> moqx version v0.2.1-2-g59fe6a9b
- admin /info               -> {"service":"moqx","version":"v0.2.1-2-g59fe6a9b"}
- startup log banner        -> first line attributes the log stream to a build
- /usr/local/VERSION        -> identify an image without executing it
- install tree VERSION      -> release + snapshot tarballs carry the id

The version is now an interface target (moqx_version) carrying a
generated header, so any target can use it — not a private compile
definition on moqx_core.
@gmarzot

gmarzot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Both review points addressed in 73a1bf7.

"Why is this docker-only? Move the logic to cmake" — done. Derivation now lives in cmake/MoqxVersion.cmake with an explicit precedence chain:

  1. -DMOQX_VERSION_STRING — explicit (the release workflow passes the exact tag)
  2. <src>/VERSION — stamped by CI; the docker context and source tarballs have no .git, so this is how they resolve
  3. git describe — any clone, including local dev builds
  4. v${PROJECT_VERSION} — last resort

The build arg is now just an override, not the mechanism. Local builds get a real version with no CI involvement (and a -dirty suffix when the tree is modified).

"This may resolve to snapshot-latest" — correct, and it's a live bug, not a theoretical one. Demonstrated on the commit snapshot-latest currently points at:

git describe --tags 4969f8c5                  -> snapshot-latest    # version of every main image
git describe --tags --match 'v[0-9]*' 4969f8c5 -> 4969f8c5           # honest sha fallback

The tag moves to the newest main commit on every publish, so it would have overtaken v0.2.1 on the next one. Fixed with --match 'v[0-9]*' (keeping --always for the no-tag case) in both the cmake path and the CI stamp, with a comment explaining why it's load-bearing so it doesn't get "simplified" away later. Same hazard applies to the 21 build-* and 4 other snapshot-* tags.

One deliberate change of direction: the leading v is now kept rather than stripped. The string is a git identifier, so it round-trips into git checkout / gh release view.

Since the version is no longer welded to moqx_core as a private compile definition (it's an interface target carrying a generated header), it's usable anywhere — the generalization payoff, all verified in a real container build:

moqx --version   -> moqx version v0.2.1-2-g59fe6a9b
/info            -> {"service":"moqx","version":"v0.2.1-2-g59fe6a9b"}
cat /usr/local/VERSION -> v0.2.1-2-g59fe6a9b   # identify an image without running it

plus a startup log banner so a relay's log stream is attributable to a build, and VERSION shipped in the install tree so release/snapshot tarballs carry the identifier.

Verified locally end to end: full docker build with no build-arg (resolving purely through the stamped VERSION file), all four precedence levels exercised, and both workflow files YAML-validated.

@gmarzot

gmarzot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

@michalhosna good to go?

@michalhosna
michalhosna requested a review from mondain July 28, 2026 14:36

@michalhosna michalhosna 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.

@michalhosna made 4 comments.
Reviewable status: 0 of 9 files reviewed, 5 unresolved discussions (waiting on afrind, gmarzot, and mondain).


-- commits line 67 at r3:
What commit message will land on main? This doesn't seem reviable


cmake/MoqxVersion.cmake line 9 at r3 (raw file):

#
# Format is git-describe output with the "v" tag prefix retained, so the
# string round-trips into `git checkout` / `gh release view`:

Why does the PR comment, commit message and this comment talk about gh release view?

It seems to me everything this does is pure git, and gh is used only in the CI.


cmake/MoqxVersion.cmake line 31 at r3 (raw file):

#
# Only v-prefixed numeric tags are considered. The repo also carries moving
# tags (snapshot-latest, build-*, archive/*) that are NOT versions; an

Nit: I don't think remarks about what other tags currently exists (snapshot-latest, build-*, archive/*) really make sense.
If we start doing tags differently, this file becomes out-of-date.

Generally, could the comments (and git commit messages) be toned down? Its adding a lot of not-that-useful text to review.


docker/Dockerfile line 55 at r3 (raw file):

# executing it — inspecting a layer, or a foreign-arch image that cannot run
# here. `docker run --rm <image> moqx --version` reports the same string.
COPY --from=builder /install/VERSION /usr/local/VERSION

VERSION file can drift from the baked-in version.

Even just passing MOQX_VERSION_STRING build arg different from the VERSION file will make them drift.

Is /usr/local/VERSION something standard/commonly used? I cannot find a good outside reference.

Why not use standardized labels? See https://specs.opencontainers.org/image-spec/annotations/

For example

ARG MOQX_VERSION_STRING=""
LABEL org.opencontainers.image.version="$MOQX_VERSION_STRING" \
        org.opencontainers.image.source="https://github.com/openmoq/moqx"

but probably include a more complete set if we want to do this. FYI there's oficial action for gh https://github.com/docker/metadata-action

And then the whole VERSION file logic can be dropped

@michalhosna michalhosna 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.

@michalhosna made 1 comment.
Reviewable status: 0 of 9 files reviewed, 6 unresolved discussions (waiting on afrind, gmarzot, and mondain).


cmake/MoqxVersion.cmake line 53 at r3 (raw file):

  execute_process(
    COMMAND "${GIT_EXECUTABLE}" describe --tags --match "v[0-9]*" --always --dirty

--dirty is good, but FYI it doesn't catch untracked files, i.e. new files not yet in git.

@michalhosna michalhosna 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.

@michalhosna reviewed 10 files and all commit messages.
Reviewable status: all files reviewed, 6 unresolved discussions (waiting on afrind, gmarzot, and mondain).

@gmarzot gmarzot changed the title version: dashboard badge tracks releases via git describe version: support OCI labels, version file in tar files, app version report, and dashboard (other dashboard enhancements) Jul 29, 2026
@gmarzot

gmarzot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

-- commits line 67 at r3:

Previously, michalhosna (Michal Hošna) wrote…

What commit message will land on main? This doesn't seem reviable

with squash-merge the pr title is the merged commit message. this detail is retained for more complete history

@gmarzot

gmarzot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

cmake/MoqxVersion.cmake line 9 at r3 (raw file):

Previously, michalhosna (Michal Hošna) wrote…

Why does the PR comment, commit message and this comment talk about gh release view?

It seems to me everything this does is pure git, and gh is used only in the CI.

i think the point was the even though we tag w/ M.m.f the reported and and expected format in a number of cases has vM.m.f
in anycase I trimmed the comment

@gmarzot

gmarzot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

cmake/MoqxVersion.cmake line 53 at r3 (raw file):

Previously, michalhosna (Michal Hošna) wrote…

--dirty is good, but FYI it doesn't catch untracked files, i.e. new files not yet in git.

--porcelain appears to produce the more sensitive detection of "dirty" .. but may also produce dirty in cases where it is not really relevant .. but it is now the sensitive mode and will catch the untracked file case

@gmarzot

gmarzot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor Author

docker/Dockerfile line 55 at r3 (raw file):

Previously, michalhosna (Michal Hošna) wrote…

VERSION file can drift from the baked-in version.

Even just passing MOQX_VERSION_STRING build arg different from the VERSION file will make them drift.

Is /usr/local/VERSION something standard/commonly used? I cannot find a good outside reference.

Why not use standardized labels? See https://specs.opencontainers.org/image-spec/annotations/

For example

ARG MOQX_VERSION_STRING=""
LABEL org.opencontainers.image.version="$MOQX_VERSION_STRING" \
        org.opencontainers.image.source="https://github.com/openmoq/moqx"

but probably include a more complete set if we want to do this. FYI there's oficial action for gh https://github.com/docker/metadata-action

And then the whole VERSION file logic can be dropped

The other sources of version trump the file and the file is written/over-written by the true version. the VERSION file now is only relevant to tar files

@gmarzot gmarzot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@gmarzot made 1 comment and resolved 2 discussions.
Reviewable status: all files reviewed, 4 unresolved discussions (waiting on afrind, michalhosna, and mondain).


.github/workflows/ci-main.yml line 389 at r1 (raw file):

Previously, michalhosna (Michal Hošna) wrote…

Something like this should work

git describe --tags --match 'v[0-9].*'

Done.

gmarzot added 7 commits July 29, 2026 15:24
…eleases

The relay reported the static CMake project version (0.1.0) forever —
tags never touched it. Now the docker publish job computes
`git describe --tags` (bare tag on release commits, e.g. v0.2.1;
tag-distance-sha on snapshots, e.g. v0.2.1-14-g2ed29c8) and passes it
through a build arg into MOQX_VERSION. Local builds keep the static
fallback. The dashboard badge picks it up via the existing
/info -> json-exporter -> moqx_build_info chain, no dashboard changes.

Publish checkout needs fetch-depth 0 for describe to see tags.
NOTE: the Dockerfile path is only exercised by the main publish job —
watch the first post-merge publish.
Addresses review on #505.

Why docker-only was wrong: the version was a docker --build-arg, so only
published images carried a real one — local builds, release tarballs and
the artifact tarball all reported the static project version (0.1.0).
Derivation now lives in cmake/MoqxVersion.cmake with an explicit
precedence chain:

  1. -DMOQX_VERSION_STRING   explicit (release workflow passes the tag)
  2. <src>/VERSION           stamped by CI; docker + source tarballs have
                             no .git, so this is how they resolve
  3. git describe            any clone, including local dev builds
  4. v${PROJECT_VERSION}     last resort

Tag filtering is load-bearing. The repo carries moving non-version tags
(snapshot-latest, build-*, archive/*); an unfiltered describe returns
"snapshot-latest" as the version of every image built from main —
demonstrated on 4969f8c, where naive describe gives snapshot-latest and
--match 'v[0-9]*' gives the sha. The v prefix is kept: the string is a
git identifier and round-trips into git checkout / gh release view.

Generalization payoff, all verified in a container build:
- moqx --version            -> moqx version v0.2.1-2-g59fe6a9b
- admin /info               -> {"service":"moqx","version":"v0.2.1-2-g59fe6a9b"}
- startup log banner        -> first line attributes the log stream to a build
- /usr/local/VERSION        -> identify an image without executing it
- install tree VERSION      -> release + snapshot tarballs carry the id

The version is now an interface target (moqx_version) carrying a
generated header, so any target can use it — not a private compile
definition on moqx_core.
The VERSION file is gitignored, so a stamp left in a working tree (e.g.
after reproducing a CI build by hand) is invisible to git status and
silently pinned every later build to a dead version. git describe now
takes precedence whenever .git exists; the contexts that actually need
the file — docker build context, source tarballs — have no .git and are
unaffected.

Verified: clone+stale file -> git describe wins; -DMOQX_VERSION_STRING
still outranks both; a .git-less tree still reads the file.

Also ignore /_build, the directory docker/Dockerfile and
version-release.yml configure into — same hand-reproduced-CI scenario.
- describe --dirty only inspects tracked files; add a git status check so a
  tree with new files is not reported as a clean commit
- images carry org.opencontainers.image.* labels and take the version via
  build-arg; drop the in-image VERSION file and the optional-copy glob
- the VERSION file remains for tarballs, which have no label mechanism
- trim comments per review
Active Tracks gains media columns (type, codec, resolution, fps, bitrate,
data tx) as constant labels until metrics exist, plus QoS/QoE/status pills.
Latency reports p50 and p99 overlaid; loss/drops in violet, egress green;
wider rate windows to cut sampling noise. Banner collapses to a one-line
logo+version strip before going single-column.
Overview: echarts readouts for latency/loss/ingress/egress with logo-derived
trace colours, native pill cells for QoS/QoE/Status, LIVE vs DONE computed
from the time window, stable top-10 subscriptions graph, full-resolution
peak queries, placeholder media attributes derived from track names.
prometheus: scrape /info at 10s so the version badge tracks a redeploy.
@gmarzot
gmarzot force-pushed the feature/dynamic-version branch from 939c5e5 to 2a15a49 Compare July 29, 2026 19:24

@michalhosna michalhosna 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.

@michalhosna reviewed 2 files and all commit messages, made 1 comment, and resolved 4 discussions.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on afrind and mondain).


-- commits line 67 at r3:

Previously, gmarzot (Giovanni Marzot) wrote…

with squash-merge the pr tiotle is the merged commit message. this detail is retained for more complete history

I'd prefer to see more human readable/human curated PR descriptions and commit messages, this is challenging to read.

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.

3 participants