Closed nbelakovski closed 9 months ago
this will fail on windows or if we build from the github tarball maybe try this ? https://github.com/antoniovazquezblanco/cmake-gitversiondetect/blob/main/GitVersionDetect.cmake
It works on Windows, I specifically modified the code so that it would. Why would we build from the github tarball?
@nbelakovski, thank you for proposing this. Ping me when both you and @jschueller think it is ready.
it wont work on windows without bash support, why not call directly the git command from cmake instead ?
also it should work from the tarball, macports already uses it, and so will linux distro usually
I changed it to use git describe
so that it's not necessary to use a bash script. I had actually initially wanted to use it, but I think I didn't like the default output and so I wanted to make my own but long story short I'd rather keep things simple.
I also learned about export-subst
in this process, which lets you write a file in such a way that git archive
will substitute certain placeholders in the file with git information, and can even include the output of describe. This should solve the macports case.
I validated that the .git-archival.txt file is set up correctly by performing the following actions on my machine (I obtained the githash from going into the actions and looking at the output of the clone repository action):
$ curl -L https://api.github.com/repos/libprima/prima/tarball/9a0485ea -o myarchive.tgz
$ tar xzf myarchive.tgz
$ cd libprima-prima-9a0485e
$ cat .git-archival.txt
v0.7.2-162-g9a0485ea5
Note that the above commands will return a blank output on forked repos since they do not copy tags by default.
Hi @nbelakovski and @jschueller , is the PR ready? Thank you.
This lets us avoid having a hardcoded file in the repo and having to update it for a release. This way releases can be done simply by tagging the appropriate commit and rebuilding.
This will be useful for when we publish packages, since it lets us publish a package every time we run CI and not have it conflict with or overwrite the latest package.