Skip to content

Commit f0988ff

Browse files
committed
Auto-update version script
Former-commit-id: 3369f34
1 parent 1cfe753 commit f0988ff

7 files changed

+2807
-7
lines changed

CITATION.cff

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
12
cff-version: 1.2.0
23
message: "If you use LibRapid in a paper, please consider citing it as below."
34
authors:
45
- family-names: "Davis"
56
given-names: "Toby"
67
title: "LibRapid: Optimised Mathematics for C++"
7-
version: 0.5.0
8-
date-released: "2022-08-11"
8+
version: 0.6.2
9+
date-released: "2023-01-08"
910
type: software
1011
url: "https://github.com/LibRapid/librapid"
1112
license: MIT
1213
license-url: "https://github.com/LibRapid/librapid/blob/master/LICENSE.md"
13-
repository-code: "https://github.com/LibRapid/librapid"
14+
repository-code: "https://github.com/LibRapid/librapid"

Doxyfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ PROJECT_NAME = "LibRapid"
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = v0.6.1
41+
PROJECT_NUMBER = v0.6.2
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a
@@ -2700,7 +2700,7 @@ GENERATE_LEGEND = YES
27002700

27012701
DOT_CLEANUP = YES
27022702

2703-
# CUSTOM CSS
2703+
# CUSTOM CSS
27042704
GENERATE_TREEVIEW = YES # required!
27052705
DISABLE_INDEX = NO
27062706
FULL_SIDEBAR = NO

LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021-2022 Toby Davis
3+
Copyright (c) 2021-2023 Toby Davis
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

scripts/setVersion.py

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
"""
2+
3+
This script accepts a version number in the form X.Y.Z, where X, Y, and Z are integers.
4+
It will then update all LibRapid version numbers to the specified version.
5+
6+
"""
7+
8+
import regex
9+
import argparse
10+
from datetime import datetime
11+
12+
# Extract current version number
13+
currentMajorVersion = None
14+
currentMinorVersion = None
15+
currentPatchVersion = None
16+
17+
try:
18+
with open("../version.txt", "r") as versionFile:
19+
text = versionFile.read()
20+
currentMajorVersion = regex.search("MAJOR [0-9]+", text).group().split()[1]
21+
currentMinorVersion = regex.search("MINOR [0-9]+", text).group().split()[1]
22+
currentPatchVersion = regex.search("PATCH [0-9]+", text).group().split()[1]
23+
print(f"Current Version: v{currentMajorVersion}.{currentMinorVersion}.{currentPatchVersion}")
24+
except Exception as e:
25+
print("[ ERROR ] Failed to read version.txt")
26+
print(e)
27+
exit(1)
28+
29+
argParser = argparse.ArgumentParser()
30+
argParser.add_argument("-v", "--version", type=str, help="Full Version")
31+
argParser.add_argument("-M", "--major", type=int, help="Major Version")
32+
argParser.add_argument("-m", "--minor", type=int, help="Minor Version")
33+
argParser.add_argument("-p", "--patch", type=int, help="Patch Version")
34+
35+
args = argParser.parse_args()
36+
37+
if args.version and any([args.major, args.minor, args.patch]):
38+
print("[ ERROR ] -v and -M options cannot be used together")
39+
exit(1)
40+
41+
newMajorVersion = args.major if args.major else currentMajorVersion
42+
newMinorVersion = args.minor if args.minor else currentMinorVersion
43+
newPatchVersion = args.patch if args.patch else currentPatchVersion
44+
print(f"New Version: v{newMajorVersion}.{newMinorVersion}.{newPatchVersion}\n\n")
45+
46+
# Write to version.txt
47+
with open("../version.txt", "w") as versionFile:
48+
versionFile.write(f"MAJOR {newMajorVersion}\n")
49+
versionFile.write(f"MINOR {newMinorVersion}\n")
50+
versionFile.write(f"PATCH {newPatchVersion}\n")
51+
print("Written to version.txt")
52+
53+
# Write to Doxyfile
54+
template = None
55+
with open("tmp/doxyTemplate", "r") as templateFile:
56+
template = templateFile.read()
57+
print("Loaded Doxyfile template")
58+
59+
with open("../Doxyfile", "w") as doxyfile:
60+
versionString = f"PROJECT_NUMBER = v{newMajorVersion}.{newMinorVersion}.{newPatchVersion}"
61+
template = template.replace("$${{ INSERT_VERSION_NUMBER_HERE }}$$", versionString)
62+
doxyfile.write(template)
63+
print("Written to Doxyfile")
64+
65+
# Write to CITATION.cff
66+
with open("tmp/citationTemplate.cff", "r") as templateFile:
67+
template = templateFile.read()
68+
print("Loaded CITATION.cff template")
69+
70+
with open("../CITATION.cff", "w") as citationFile:
71+
versionString = f"version: {newMajorVersion}.{newMinorVersion}.{newPatchVersion}"
72+
dateString = f"date-released: \"{datetime.now().strftime('%Y-%m-%d')}\""
73+
template = template.replace("$${{ INSERT_VERSION_NUMBER_HERE }}$$", versionString)
74+
template = template.replace("$${{ INSERT_DATE_HERE }}$$", dateString)
75+
citationFile.write(template)
76+
print("Written to CITATION.cff")

scripts/tmp/citationTemplate.cff

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
cff-version: 1.2.0
3+
message: "If you use LibRapid in a paper, please consider citing it as below."
4+
authors:
5+
- family-names: "Davis"
6+
given-names: "Toby"
7+
title: "LibRapid: Optimised Mathematics for C++"
8+
$${{ INSERT_VERSION_NUMBER_HERE }}$$
9+
$${{ INSERT_DATE_HERE }}$$
10+
type: software
11+
url: "https://github.com/LibRapid/librapid"
12+
license: MIT
13+
license-url: "https://github.com/LibRapid/librapid/blob/master/LICENSE.md"
14+
repository-code: "https://github.com/LibRapid/librapid"

0 commit comments

Comments
 (0)