Created
February 5, 2018 10:05
-
-
Save Headline/76eca45276fc17a623f79ad824c7741f to your computer and use it in GitHub Desktop.
Used for replacing version numbers in c# source files (replaces $$version$ w/ APPVEYOR_BUILD_VERSION)
This file contains 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
import os | |
import os.path | |
def get_clean_path(array): | |
somestr = "" | |
for x in range(0, len(array) - 1): | |
somestr += array[x] + "\\" | |
return somestr | |
def do_version_replace(current): | |
oldlist = 0; | |
with open(current) as f: | |
oldlist = f.readlines(); | |
for i, line in enumerate(oldlist): | |
if "$$version$" in line: | |
print("Replacing...") | |
oldlist[i] = line.replace("$$version$", os.getenv('APPVEYOR_BUILD_VERSION', "XX.XX.XX")) | |
with open(current, 'w') as f: | |
f.writelines(oldlist) | |
path = get_clean_path(os.path.realpath(__file__).split("\\")) | |
for dirpath, dirnames, filenames in os.walk(path): | |
for filename in filenames: | |
current = dirpath + "\\" + filename | |
if filename.endswith(".cs"): | |
print("Versioning: " + current) | |
do_version_replace(current) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment