aboutsummaryrefslogtreecommitdiff
path: root/misc/update_version.py
diff options
context:
space:
mode:
authorEd Maste <emaste@FreeBSD.org>2021-10-01 23:46:00 +0000
committerEd Maste <emaste@FreeBSD.org>2021-10-01 23:46:00 +0000
commit5b2defbd2a1aa991bd0a2855eef8e15107572747 (patch)
tree0e8b33a28f1fb7396bf8b6fcef974fa82de59e9d /misc/update_version.py
Vendor import of libcbor 0.8.0vendor/libcbor/0.8.0
Diffstat (limited to 'misc/update_version.py')
-rwxr-xr-xmisc/update_version.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/misc/update_version.py b/misc/update_version.py
new file mode 100755
index 000000000000..eb330215d375
--- /dev/null
+++ b/misc/update_version.py
@@ -0,0 +1,38 @@
+import sys, re
+from datetime import date
+
+version = sys.argv[1]
+release_date = date.today().strftime('%Y-%m-%d')
+major, minor, patch = version.split('.')
+
+
+def replace(file_path, pattern, replacement):
+ updated = re.sub(pattern, replacement, open(file_path).read())
+ with open(file_path, 'w') as f:
+ f.write(updated)
+
+# Update changelog
+SEP = '---------------------'
+NEXT = f'Next\n{SEP}'
+changelog_header = f'{NEXT}\n\n{version} ({release_date})\n{SEP}'
+replace('CHANGELOG.md', NEXT, changelog_header)
+
+# Update Doxyfile
+DOXY_VERSION = 'PROJECT_NUMBER = '
+replace('Doxyfile', DOXY_VERSION + '.*', DOXY_VERSION + version)
+
+# Update CMakeLists.txt
+replace('CMakeLists.txt',
+ '''SET\\(CBOR_VERSION_MAJOR "0"\\)
+SET\\(CBOR_VERSION_MINOR "7"\\)
+SET\\(CBOR_VERSION_PATCH "0"\\)''',
+ f'''SET(CBOR_VERSION_MAJOR "{major}")
+SET(CBOR_VERSION_MINOR "{minor}")
+SET(CBOR_VERSION_PATCH "{patch}")''')
+
+# Update Sphinx
+replace('doc/source/conf.py',
+ """version = '.*'
+release = '.*'""",
+ f"""version = '{major}.{minor}'
+release = '{major}.{minor}.{patch}'""")