Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building from source release displays git as version number #1225

Open
Drakx opened this issue May 21, 2024 · 7 comments
Open

Building from source release displays git as version number #1225

Drakx opened this issue May 21, 2024 · 7 comments

Comments

@Drakx
Copy link
Contributor

Drakx commented May 21, 2024

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
Copy link
Collaborator

limpkin commented May 21, 2024

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
Copy link
Contributor Author

Drakx commented Jun 2, 2024

@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
Copy link

schlomie commented Jun 6, 2024

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
Copy link
Contributor

barathrm commented Jul 7, 2024

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
Copy link

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"

@principis
Copy link
Contributor

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.

@limpkin
Copy link
Collaborator

limpkin commented Jul 29, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants