mooltipass / moolticute

Mooltipass crossplatform daemon/tools
GNU General Public License v3.0
141 stars 66 forks source link

Building from source release displays git as version number #1225

Open Drakx opened 1 month ago

Drakx commented 1 month ago

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

limpkin commented 1 month ago

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

Drakx commented 1 month ago

@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.

schlomie commented 1 month ago

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

barathrm commented 1 week ago

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.

oliverpool commented 23 hours ago

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"