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

use version from git #264

Closed
wants to merge 2 commits into from

Conversation

ggrandou
Copy link

This patch automates the version string in the firmware by using the most recent available git tag.

python script is automatically called by platformio upon build which appends a GIT_VERSION define to build flags.

version string is built from the output of git describe --tags --always --dirty command

Some version examples:

  • 2023.8 when built on a tag
  • 2023.8-9-g103391f when built later than a tag
  • 2023.8-9-g103391f-dirty when built on a dirty tree

GIT_VERSION is gracefully ignored when the build is not run inside a git repository or if git fails for whatever reason.

For safety I have kept the original code if GIT_VERSION is not defined, but it could make sense to have a generic "unknown" version string or similar.

It has been tested on a linux platform. It should work on windows as well, but it's untested.

* Add a new build flag: -D GIT_VERSION=<string>
* gracefully ignored if not inside a git repository or if git returns an
  error
* version format:
   - 2023.8 when built on a tag
   - 2023.8-9-g103391f when built later than a tag
   - 2023.8-9-g103391f-dirty when built on a dirty tree
Copy link

@pzbitskiy pzbitskiy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried it and it works great

@ggrandou
Copy link
Author

ggrandou commented Aug 2, 2024

I tried it and it works great

on linux or on windows ?

@pzbitskiy
Copy link

Linux.

@gysmo38
Copy link
Owner

gysmo38 commented Aug 25, 2024

Thank you for your PR

@gysmo38 gysmo38 closed this Aug 25, 2024
@ggrandou
Copy link
Author

Hello,
@gysmo38 looks like you have forgotten to actually do the merge in your master branch ;)

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

Successfully merging this pull request may close these issues.

3 participants