/platformio_version_increment

Simple versioning Python script for PlatformIO

Primary LanguagePythonMIT LicenseMIT

PlatformIO Version Increment

Simple version increment script for PlatformIO.

PlatformIO does not have a tool to automatically increment the version number of an app when building it or when uploading it to a microcontroller so I decided to write a script to do it.

GitHub version License: MIT Maintenance DPsoftware

If you like PlatformIO Version Increment, give it a star, or fork it and contribute!

GitHub stars GitHub forks

Credits

  • Davide Perini

How To Use

  1. From the root of your project run
git submodule add https://github.com/sblantipodi/platformio_version_increment.git platformio_version_increment
  1. Add the following in your platformio.ini:
extra_scripts = 
   pre:platformio_version_increment/version_increment_pre.py
   post:platformio_version_increment/esp32_create_factory_bin_post.py // bundle all files in one factory firmware bin
   post:platformio_version_increment/version_increment_post.py
  1. Add #include "Version.h" to the top of your main source file (i.e. main.cpp).

  2. Build your software for your microcontroller. In the root of your project you will find two files:

  • version
  • include/Version.h

The version file will default to 0.1.0, but you can edit this with the version number you wish to start incrementing from.

Every completed upload will trigger a +1 on the patch number.

In the Version.h file (which you'll need to include in order to access the incrementing version and timestamp variables) you'll have this:

// AUTO GENERATED FILE, DO NOT EDIT THIS FILE
#ifndef VERSION
  #define VERSION "0.1.0"
#endif
#ifndef BUILD_TIMESTAMP
  #define BUILD_TIMESTAMP "2020-04-10 17:58:52.937616"
#endif

You now have auto-incrementing VERSION and BUILD_TIMESTAMP variables you can use in your program as you wish!

For example:

Serial.println("Project version: " + String(VERSION));
Serial.println("Build timestamp:" + String(BUILD_TIMESTAMP));

or

Serial.printf("Project version v%s, built %s\n",VERSION,BUILD_TIMESTAMP);

License

This program is licensed under MIT License

Thanks To

Thanks For
For the PyCharm IDE licenses.