in many cases we need to update the version info in source file manually before
release, however, we often forget to update them, because it’s a “concealed” bug
before release
we can use some scripts to automate the procedure to inject version info into
source file
java
step 1, define a version file, say, src/main/com/your/package/Version.java
step 2, define a build script to update the version info in Version.java
step 3, build the project with build tools: maven or ant
step 3.1, maven, update version in pom.xml, and then build
step 3.2, ant, update version info in build.xml as using maven if there is one
golang
step 1, define version and date variable in main.go
step 2, build with -x option
c++
step 1, use a macro to define version
step 2, build with -DVERSION "\"new version\""
python
just define a version.py
and invoke it anywhere which needs version info
other languages
for static language, inject version info into source file and build
for dynamic language, just define the version info in a separated file