Last active
April 5, 2025 04:40
-
-
Save vurdalakov/cc120a5ab0579e92f42c7711d982dbbe to your computer and use it in GitHub Desktop.
Automatically increment version number in Arduino IDE
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
echo ----------------------------------------------- increment.bat script ----------------------------------------------- | |
rem ======================================================================================== | |
rem == This script automatically increments build number in "version.h" file. | |
rem == Instructions and more information: | |
rem == http://codeblog.vurdalakov.net/2017/04/autoincrement-build-number-in-arduino-ide.html | |
rem ======================================================================================== | |
setlocal | |
set output=%1 | |
echo output=%output% | |
set source=%2 | |
echo source=%source% | |
set filename=%source%\version.h | |
echo filename=%filename% | |
for /f "delims=" %%x in (%filename%) do set define=%%x | |
echo %define% | |
for /f "tokens=1-3 delims= " %%a in ("%define%") do ( | |
set macro=%%b | |
set version=%%c | |
) | |
echo macro=%macro% | |
set version=%version:~1,-1% | |
echo version=%version% | |
for /f "tokens=1-3 delims=. " %%a in ("%version%") do ( | |
set version=%%a.%%b | |
set build=%%c | |
) | |
echo build=%build% | |
set /a build=%build%+1 | |
echo build=%build% | |
set version=%version%.%build% | |
echo version=%version% | |
set line=#define %macro% "%version%" | |
echo %line% | |
echo filename=%filename% | |
echo %line% > %filename% | |
type %filename% | |
set filename=%output%\sketch\version.h | |
echo filename=%filename% | |
echo %line% > %filename% | |
type %filename% | |
set curdir=%cd% | |
cd %source% | |
rem == Uncomment following line to commit updated version.h file to Git repository | |
rem == Uncomment second line to tag commit | |
rem git commit -am "Version %version%" | |
rem git tag %version% | |
cd %curdir% | |
echo ----------------------------------------------- increment.bat script ----------------------------------------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ESP8266 platform | |
# ------------------------------ | |
# For more info: | |
# https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5---3rd-party-Hardware-specification | |
name=ESP8266 Modules | |
version=2.2.0 | |
recipe.hooks.sketch.prebuild.0.pattern=C:\Users\vurdalakov\arduino\increment.bat {build.path} {build.source.path} {build.project_name} | |
compiler.warning_flags=-w | |
compiler.warning_flags.none=-w | |
compiler.warning_flags.default= | |
compiler.warning_flags.more=-Wall | |
compiler.warning_flags.all=-Wall -Wextra | |
... ... ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define SKETCH_VERSION "1.0.324" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
i added between line 47 and 48 the following:
if not exist %filename% (set line=#define SKETCH_VERSION "0.0.1")
as result the system will create the correct SKETCH_VERSION file with correct content. so you will have automatically have version increments avialable in all your projects