so I guess there should be some kind of preprocessing to replace that %%VERSION%% string with the correct value, taken from a “single source of truth”, but I cannot find either. What/where should be that single source of truth, and what should be that expansion mechanism?
One candidate for the source of truth is probably the version stanza in dune-project?
As for the mechanism, I saw something a bit different in some online projects, with dune files with
Thank you, I understand a bit better the mechanism. It seems that there are mainly two methods: the dune subst command and a rule stanza that generates a .ml file with the data of \"%{version:my_project}%\".
It seems that both end up using a version (or tag) set by git (and dune subst looks to be usable only when one releases a package). However, there is another solution to the question linked by @yawaramin, which proposes to use dune-buid-info (new links: Dune Libraries - Dune documentation and dune-build-info 3.22.0 · OCaml Package). It uses the version indicated in the version stanza of dune-project and looks like the preferred way.
In respect to how to do this with dune, I am aware of patch/bin/dune at main · hannesm/patch · GitHub (which I don’t know how it works, or how dune determines the version, but it seems to work nicely).
Reproducibility depends on the entire state of Opam, which is not captured by Git if we only look at the code of the application that we are building. In any case, this is just a demonstration how to easily include information from the environment at build time.
I never claimed that “not including the date will provide you with reproducibility”.
I codeveloped several years ago tooling to capture what influences reproducibility, take a look at orb GitHub - robur-coop/orb: check opam package reproductibility · GitHub if you’re interested. It includes environment variables, the opam swtich export --full --freeze, and system packages.
All I intended to say is that a timestamp doesn’t really give you any further information: it neither tells you which opam-repository commit you were at, or which OS / last package update; but actively harms reproducibility (see the previously linked PR to ocamlgraph) – thus I suggest to not include it, not even in “demonstration how to easily include information from the environment”.