There are roughly two schools of though on build numbers. One is that they must be unique to each release, i.e mirror pretty much a version number, the other one that they must be unique to every commit. I guess you could also make them literally unique to every actual build, i.e each time you compile, which adds even more complexity to insure this stays true across all devs on a given project.
The one bonus I often add is a test in the build script for any local changes to the code base. If so, I add a postfix to the build number like -dev or -dirty to indicate that that build does not comform exactly to the commit. That system has the advantage to work across repo branches too, you don’t have to worry about build number collisions when merging.
A newer server operated by the Mastodon gGmbH non-profit