Re:Proper use of Git tags
by CameronNemo on Monday May 23, 2022 @01:31PM
(#31482100)
The v prefix really helps us only run ci on version tags instead of random tags as well. If you are strict and always use semantic versions for tags, you can just keep doing what you are doing. But if you ever want to create some random tag later and don't want your automation to try to use it as a version number, the v prefix helps.
Re:Proper use of Git tags
by jonnycomputer on Monday May 23, 2022 @04:02PM
(#31484164)
How is the version information included in the software if you don't include it in the source? Do you have a deploy script that modifies source based on the git tag, or ?
Re:Proper use of Git tags
by WorldMaker on Monday May 23, 2022 @05:37PM
(#31485075)
I sometimes dump git describe to a JSON file rather than modifying a source file and let the build bundle it as an embedded resource. You can .gitignore the JSON file to keep it from accidentally getting checked in (and causing merge conflicts).
As also pointed out, many build tools that want or need version numbers often also have command line flags or can take environment variables instead of using source files.
Re:Proper use of Git tags
by jonnycomputer on Monday May 23, 2022 @07:51PM
(#31486295)
There seems a lot to like about that approach.
Re:Proper use of Git tags
by t0astbread on Monday May 23, 2022 @04:46PM
(#31484580)
Some languages and build systems also allow you to set constants from compiler flags (Go for example). Other systems make the entire build configuration an executable program (Gradle).
Re:Proper use of Git tags
by jonnycomputer on Monday May 23, 2022 @07:49PM
(#31486277)
I did not know that. I mostly use interpreted languages (Python, JavaScript, etc.)
Re:Proper use of Git tags
by formerly_proven on Tuesday May 24, 2022 @02:30AM
(#31488694)
For Python there are tools like setuptools_scm to completely automate the setup of this.
Re:Proper use of Git tags
by jonnycomputer on Tuesday May 24, 2022 @11:55AM
(#31493709)
Good to know.
The build process uses the tag.
In practice that's a tiny bit more complicated to do it really well, with the version as a dependency in the build process. When developing, you don't want to trigger a full rebuild if the version number changes, but you do have rebuilds to do when it does.
Also ties in with the author's recommendation to begin tags with "v". My experience is that excluding it is better. Then a simple "git describe" readily gives the version number in scripts with no sed or reprocessing.
I've seen many conventions with Git. It's interesting to hear some rationale, but a stretch to describe these suggestions as the "proper" way.