diff --git a/README.md b/README.md index 7a96260..d8f4e0c 100644 --- a/README.md +++ b/README.md @@ -47,5 +47,7 @@ In the `Version.h` file (which you'll need to include in order to access the inc ``` use variables as you desire. +Note: This script does not check for a successfull upload, in the case of an upload failure, please discard the increment manually. + ## License This program is licensed under MIT License diff --git a/version_increment.py b/version_increment.py index 1322af2..c37688e 100644 --- a/version_increment.py +++ b/version_increment.py @@ -19,10 +19,11 @@ import sys import datetime +import os ## DO NOT EDIT THIS FILE, edit version file if you want to start from a different version BUILD_NUMBER = 'version' -VERSION_FILE = 'include/Version.h' +VERSION_FILE = 'Version.h' version = '0.1.' ## Increment version during the upload stage only @@ -61,6 +62,12 @@ #define BUILD_TIMESTAMP "{}" #endif """.format(version + str(build_no), datetime.datetime.now(), version+str(build_no)) + + if (os.environ.get('PLATFORMIO_INCLUDE_DIR') != None): + VERSION_FILE = os.environ.get('PLATFORMIO_INCLUDE_DIR') + "/" + VERSION_FILE + elif os.path.exists("include"): + VERSION_FILE = "include/" + VERSION_FILE + with open(VERSION_FILE, 'w+') as f: f.write(hf) else: