I have this in my OMake files: if $(test -e .git) GIT_COMMIT = 'Some "$(shell git rev-parse HEAD)"' export else GIT_COMMIT = 'None' export I also define VERSION manually, but ideally I should extract the version from my opam file. Given those, I use m4 as follows to generate an About module for most of my projects. m4 -D VERSION=$(VERSION) -D GIT_COMMIT=$(GIT_COMMIT) about.ml.m4 > about.ml $ cat about.ml.m4 (** General information about this project. *) (** Version: [VERSION] *) let version = "VERSION" (** Git commit if known: [GIT_COMMIT] *) let git_commit = GIT_COMMIT On Sat, Oct 17, 2015 at 3:22 AM, Gabriel Scherer wrote: > For reference, an ocamlbuild version would look like this: > > open Ocamlbuild_plugin > > let () = dispatch (function > | After_rules -> > rule "version file" > ~prod:"version.ml" > ~doc:"generate a file with version information: > Version.commit is the HEAD commit at the time of building, > Version.tag is the name of the last git tag" > (fun _env _build -> > let trim = "tr -d '\r\n'" in > let commit = run_and_read ("git rev-parse HEAD |" ^ trim) in > let tag = run_and_read ("git describe --abbrev=0 --tags |" ^ > trim) in > let code = Printf.sprintf > "let commit = %S\n\ > let tag = %S\n" > commit tag in > Echo ([code], "version.ml"); > ) > | _ -> () > );; > > On Fri, Oct 16, 2015 at 9:29 PM, Basile Starynkevitch > wrote: > > On 10/16/2015 08:24 PM, David CHEMOUIL wrote: > >> > >> Hi, > >> > >> I am looking for a self-contained, to the point, documentation or > tutorial > >> detailing steps, or even commands and scripts to run in order to > release and > >> publish an OCaml-programmed piece of software. > > > > > >> > >> So common tasks we'd like to automate are quite simple: adding the > commit > >> number and/or a build number in the OCaml source code (e.g. to display > it > >> when running the program), > > > > > > This is not specific to Ocaml. It is a matter of build process. > > > > Assuming a Linux system, you might have some rule in your Makefile > similar > > to the (untested) one below: > > > > ML_SOURCES=$(wildcard [a-z]*.ml) > > ML_INTERFACES=$(wildcard [a-z]*.mli) > > MD5SUM= md5sum > > > > _timestamp.ml: > > date +'let my_timestamp="%c";;' > _timestamp.tmp > > > > (echo -n 'let my_lastgitcommit ="' ; \ > > git log --format=oneline --abbrev=12 --abbrev-commit -q \ > > | head -1 | tr -d '\n\r\f\"' ; \ > > echo '";;') >> _timestamp.tmp > > (echo -n 'let my_checksum ="'; cat $(sort $(ML_SOURCES)) $(sort > > $(ML_INTERFACES))| $(MD5SUM) | cut -d' ' -f1 | tr -d '\n\r\f\"\\' ; echo > > '";') >> _timestamp.tmp > > mv _timestamp.tmp _timestamp.ml > > > > Cheers > > > > -- > > Basile STARYNKEVITCH http://starynkevitch.net/Basile/ > > email: basilestarynkevitchnet mobile: +33 6 8501 2359 > > 8, rue de la Faiencerie, 92340 Bourg La Reine, France > > *** opinions {are only mine, sont seulement les miennes} *** > > > > > > > > -- > > Caml-list mailing list. Subscription management and archives: > > https://sympa.inria.fr/sympa/arc/caml-list > > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > > Bug reports: http://caml.inria.fr/bin/caml-bugs > > -- > Caml-list mailing list. Subscription management and archives: > https://sympa.inria.fr/sympa/arc/caml-list > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > Bug reports: http://caml.inria.fr/bin/caml-bugs >