moolticute icon indicating copy to clipboard operation
moolticute copied to clipboard

Building from source release displays git as version number

Open Drakx opened this issue 1 year ago • 7 comments

Expected behaviour

Display the correct version number as release tag indicates under About Version: 1.03.0

Actual behaviour

Download https://github.com/mooltipass/moolticute/archive/refs/tags/v1.03.0.zip and build according to instructions. Start Moolticute Navigate to About Version: git

Moolticute Version

1.03.0 release

Operating System

Void Linux

Mooltipass Device

The Mooltipass Mini BLE

Drakx avatar May 21 '24 08:05 Drakx

oh that's a tough one... I'm not sure how we could go about checking if a given download zip file matches the contents of a given release

limpkin avatar May 21 '24 18:05 limpkin

@limpkin I wouldn't think that's a solution, rather there would be a version somewhere in the code, that when building would display whatever version was used when building. I've not gone through to check. It's not an issue that the version shows git more of an annoyance after building a release like the one listed.

Drakx avatar Jun 02 '24 10:06 Drakx

There is. src/version.h

#define APP_VERSION "git"

Update this line in this file to match the tagged version (I build from the repo directly, skipping the zip files) and build.

2024-06-06_08-13

schlomie avatar Jun 06 '24 15:06 schlomie

One way of addressing this is only setting APP_VERSION if it's not already defined. Then you could pass your own custom define at build time, setting it based on your current git HEAD.

Currently I use sed to search-replace this definition in the source before building, which is not the cleanest solution.

barathrm avatar Jul 07 '24 09:07 barathrm

Another way would be to use .gitattributes: https://semjonov.de/posts/2018-10/commit-hash-replacement-in-git-archives/#gitattributes

This allows git to automatically inject the current tag in given files, when the source is generated (for instance when downloading from github):

// in src/version.h
#define APP_VERSION "$Format:%(describe:tags)$"

Example outputs:

// when exactly on a tag
#define APP_VERSION "v1"
// previous tag: v1, 1 commit on top; current commit: d935e6a (with a "g" prefix, for "git")
#define APP_VERSION "v1-1-gd935e6a"

oliverpool avatar Jul 16 '24 10:07 oliverpool

One way of addressing this is only setting APP_VERSION if it's not already defined. Then you could pass your own custom define at build time, setting it based on your current git HEAD.

This would be very useful. It should be possible to do this using qmake DEFINES and CONFIG.

principis avatar Jul 29 '24 10:07 principis

it seems our build system does overwrite version.h, so I'm open to any idea... simply make a PR for review

limpkin avatar Jul 29 '24 18:07 limpkin