Skip to content

Commit 7dab63c

Browse files
Update version incrementer script. README.md should contain the freshly released version, not dev version
1 parent 1c2ee6d commit 7dab63c

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

ci-scripts/incrementVersion.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
from getVersion import get_version
66

77

8-
def str_replace_in_file(file, search, replace):
8+
def replace_version_in_file(file, prefix, version, suffix):
99
r = file.open('r')
10-
updated_file_contents = r.read().replace(search, replace)
10+
lines = r.readlines()
1111
r.close()
1212
with open(file, 'w') as w:
13-
w.write(updated_file_contents)
13+
for line in lines:
14+
if line.startswith(prefix):
15+
line = prefix + version + suffix + "\n"
16+
w.write(line)
1417

1518

1619
def main():
@@ -30,12 +33,8 @@ def main():
3033
print("newVersion=" + new_version, file=out)
3134

3235
root_dir = Path(__file__).resolve().parent.parent
33-
str_replace_in_file(root_dir / "build.gradle.kts",
34-
"version = \"{}\"".format(old_version),
35-
"version = \"{}\"".format(new_version))
36-
str_replace_in_file(root_dir / "README.md",
37-
"id 'app.opendocument.conanandroidgradleplugin' version \"{}\" apply false".format(old_version),
38-
"id 'app.opendocument.conanandroidgradleplugin' version \"{}\" apply false".format(new_version))
36+
replace_version_in_file(root_dir / "README.md", " id 'app.opendocument.conanandroidgradleplugin' version \"", old_version, "\" apply false")
37+
replace_version_in_file(root_dir / "build.gradle.kts", "version = \"", new_version, "\"")
3938

4039

4140
if __name__ == "__main__":

0 commit comments

Comments
 (0)