Make Python replace version file responsible for file writes
While the initial idea of having cmd/PS/bash actually write the changes to file, the integration with the AppVeyor YAML just made it really frustrating.
This commit is contained in:
+1
-1
@@ -26,7 +26,7 @@ clone_depth: 1
|
|||||||
|
|
||||||
init:
|
init:
|
||||||
- set TAG_NAME=%APPVEYOR_REPO_TAG_NAME%
|
- set TAG_NAME=%APPVEYOR_REPO_TAG_NAME%
|
||||||
- python ./build_scripts/append_to_version_file.py $(APPVEYOR_REPO_COMMIT) > ./build_scripts/compile_version_string.txt
|
- python ./build_scripts/append_to_version_file.py %APPVEYOR_REPO_COMMIT%
|
||||||
|
|
||||||
build_script:
|
build_script:
|
||||||
- python ./build_scripts/run-clang-format.py ./src -r --clang-format-executable "C:\Program Files\LLVM\bin\clang-format.exe" --color always
|
- python ./build_scripts/run-clang-format.py ./src -r --clang-format-executable "C:\Program Files\LLVM\bin\clang-format.exe" --color always
|
||||||
|
|||||||
@@ -1,14 +1,21 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
from sys import argv
|
from sys import argv
|
||||||
from os import path
|
from os import path, remove
|
||||||
|
|
||||||
|
current_path = path.dirname(path.realpath(__file__))
|
||||||
|
version_file_path = path.join(current_path, "compile_version_string.txt")
|
||||||
|
|
||||||
def get_version_string():
|
def get_version_string():
|
||||||
dir_path = path.dirname(path.realpath(__file__))
|
with open(version_file_path, "r") as file:
|
||||||
with open(path.join(dir_path, "compile_version_string.txt"), "r") as file:
|
|
||||||
contents = file.readline()
|
contents = file.readline()
|
||||||
return contents.strip('"')
|
return contents.strip('"')
|
||||||
|
|
||||||
|
def set_version_string(new_version_string):
|
||||||
|
remove(version_file_path)
|
||||||
|
with open(version_file_path, "w") as file:
|
||||||
|
file.write(new_version_string)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
current_version = get_version_string()
|
current_version = get_version_string()
|
||||||
new_version = current_version + "-" + argv[1]
|
new_version = current_version + "-" + argv[1]
|
||||||
print("\"" + new_version + "\"")
|
set_version_string(new_version)
|
||||||
Reference in New Issue
Block a user