Workbench/VSCode question: How to increment a build/version in my firmware?

I’d like to embed a version in my code. Basically, I would like some method of incrementing a number defined in my code every time I build, so that it can be accessed from the code.

I mainly use the local compile, but I do occasionally use the cloud compile. But I am willing to just have this increment locally. right now I am keeping track manually, but I this is unreliable.

I see that there are some extensions for this, but I am not sure if they will work, or if there is a preferred method.

Thanks!

Which extensions were you referring to exactly?
When building product these are included:

PRODUCT_ID(9999);
PRODUCT_VERSION(999);

I also include the following which I manually maintain and sometimes include as a Particle.variable()

const char* const firmware         =   "2.0.0";
const char* const softwarebuild    =   "999 18-12-20";
const char* const hardwarebuild    =   "Rev9";

I was thinking more of some parameter that is automatically incremented by the IDE, or the compiler in order to generate an automated version or build.

One example is this extension I found in the VSCode marketplace
sbg.auto-version-increment

Are you using git for version control with your project?

If so, it might make more sense to include the commit number/hash in your code.

I’ve made a basic demo for doing this using Python and neopo: