7
7
import subprocess
8
8
import io
9
9
import os
10
+ import fileinput
11
+ if sys .version_info < (3 , 0 ):
12
+ sys .stdout .write ("Sorry, requires Python 3.x or better\n " )
13
+ sys .exit (1 )
10
14
15
+ def colored (r , g , b , text ):
16
+ return "\033 [38;2;{};{};{}m{} \033 [38;2;255;255;255m" .format (r , g , b , text )
11
17
12
18
def extractnumbers (s ):
13
19
return tuple (map (int ,re .findall ("(\d+)\.(\d+)\.(\d+)" ,str (s ))[0 ]))
@@ -22,17 +28,13 @@ def topaddedversionstring(major, minor, rev):
22
28
branchresult = pipe .communicate ()[0 ].decode ().strip ()
23
29
24
30
if (branchresult != "master" ):
25
- print ("release on master, you are on '" + branchresult + "'" )
26
- #sys.exit(-1)
27
-
31
+ print (colored (255 , 0 , 0 , "We recommend that you release on master, you are on '" + branchresult + "'" ))
28
32
29
33
ret = subprocess .call (["git" , "remote" , "update" ])
30
34
31
35
if (ret != 0 ):
32
36
sys .exit (ret )
33
37
34
-
35
-
36
38
pipe = subprocess .Popen (["git" , "log" , "HEAD.." , "--oneline" ], stdout = subprocess .PIPE , stderr = subprocess .STDOUT )
37
39
uptodateresult = pipe .communicate ()[0 ].decode ().strip ()
38
40
@@ -42,7 +44,7 @@ def topaddedversionstring(major, minor, rev):
42
44
43
45
pipe = subprocess .Popen (["git" , "rev-parse" , "--show-toplevel" ], stdout = subprocess .PIPE , stderr = subprocess .STDOUT )
44
46
maindir = pipe .communicate ()[0 ].decode ().strip ()
45
-
47
+ scriptlocation = os . path . dirname ( os . path . abspath ( __file__ ))
46
48
47
49
print ("repository: " + maindir )
48
50
@@ -79,7 +81,14 @@ def topaddedversionstring(major, minor, rev):
79
81
atleastminor = (currentv [0 ] != newversion [0 ]) or (currentv [1 ] != newversion [1 ])
80
82
81
83
if (atleastminor ):
82
- print ("This is more than a revision." )
84
+ print (colored (0 , 255 , 0 , "This is more than a revision." ))
85
+ releasefile = maindir + os .sep + "RELEASES.md"
86
+ releasedata = open (releasefile ).read ()
87
+ pattern = re .compile ("#\s+\d+\.\d+" )
88
+ m = pattern .search (releasedata )
89
+ if (m == None ):
90
+ print (colored (255 , 0 , 0 , "You are preparing a new minor release and you have not yet updated RELEASES.md." ))
91
+ sys .exit (- 1 )
83
92
84
93
versionfilerel = os .sep + "include" + os .sep + "simdjson" + os .sep + "simdjson_version.h"
85
94
versionfile = maindir + versionfilerel
@@ -114,10 +123,6 @@ def topaddedversionstring(major, minor, rev):
114
123
115
124
print (versionfile + " modified" )
116
125
117
- import fileinput
118
- import re
119
-
120
-
121
126
newmajorversionstring = str (newversion [0 ])
122
127
mewminorversionstring = str (newversion [1 ])
123
128
newrevversionstring = str (newversion [2 ])
@@ -140,24 +145,53 @@ def topaddedversionstring(major, minor, rev):
140
145
sonumber += 1
141
146
142
147
for line in fileinput .input (cmakefile , inplace = 1 , backup = '.bak' ):
143
- line = re .sub ('SIMDJSON_LIB_VERSION "\d+\.\d+\.\d+' ,'SIMDJSON_LIB_VERSION "' + newversionstring , line .rstrip ())
144
- line = re .sub ('SIMDJSON_LIB_SOVERSION "\d+' ,'SIMDJSON_LIB_SOVERSION "' + newmajorversionstring , line )
148
+ line = re .sub ('SIMDJSON_SEMANTIC_VERSION "\d+\.\d+\.\d+' ,'SIMDJSON_SEMANTIC_VERSION "' + newversionstring , line .rstrip ())
149
+ line = re .sub ('SIMDJSON_LIB_VERSION "\d+' ,'SIMDJSON_LIB_VERSION "' + str ( sonumber ) , line )
145
150
line = re .sub ('set\(PROJECT_VERSION_MAJOR \d+' ,'set(PROJECT_VERSION_MAJOR ' + newmajorversionstring , line )
146
151
line = re .sub ('set\(PROJECT_VERSION_MINOR \d+' ,'set(PROJECT_VERSION_MINOR ' + mewminorversionstring , line )
147
152
line = re .sub ('set\(PROJECT_VERSION_PATCH \d+' ,'set(PROJECT_VERSION_PATCH ' + newrevversionstring , line )
148
153
line = re .sub ('set\(SIMDJSON_LIB_SOVERSION \" \d+\" ' ,'set(SIMDJSON_LIB_SOVERSION \" ' + str (sonumber )+ '\" ' , line )
149
154
print (line )
150
155
151
-
152
156
print ("modified " + cmakefile + ", a backup was made" )
157
+
158
+
153
159
doxyfile = maindir + os .sep + "Doxyfile"
154
160
for line in fileinput .input (doxyfile , inplace = 1 , backup = '.bak' ):
155
161
line = re .sub ('PROJECT_NUMBER = "\d+\.\d+\.\d+' ,'PROJECT_NUMBER = "' + newversionstring , line .rstrip ())
156
162
print (line )
157
163
print ("modified " + doxyfile + ", a backup was made" )
158
164
159
- scriptlocation = os .path .dirname (os .path .abspath (__file__ ))
160
165
161
166
162
- print ("Please run the tests before issuing a release, do make test && make amalgamate_test \n " )
167
+ cp = subprocess .run (["bash" , "amalgamate.sh" ], stdout = subprocess .DEVNULL , cwd = maindir + os .sep + "singleheader" ) # doesn't capture output
168
+ if (cp .returncode != 0 ):
169
+ print ("Failed to run amalgamate" )
170
+
171
+ cp = subprocess .run (["doxygen" ], stdout = subprocess .DEVNULL , stderr = subprocess .DEVNULL , cwd = maindir ) # doesn't capture output
172
+ if (cp .returncode != 0 ):
173
+ print ("Failed to run doxygen" )
174
+
175
+ #ipe = subprocess.Popen(["doxygen"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=maindir)
176
+ #doxygenresult = pipe.communicate()[0].decode().strip()
177
+
178
+ pattern = re .compile ("https://simdjson.org/api/(\d+\.\d+\.\d+)/index.html" )
179
+ readmefile = maindir + os .sep + "README.md"
180
+ readmedata = open (readmefile ).read ()
181
+ m = pattern .search (readmedata )
182
+ if m == None :
183
+ print (colored (255 , 0 , 0 , 'I cannot find a link to the API documentation in your README?????' ))
184
+ else :
185
+ detectedreadme = m .group (1 )
186
+ print ("found a link to your API documentation in the README file: " + detectedreadme + " (" + toversionstring (* newversion )+ ")" )
187
+ if (atleastminor ):
188
+ if (detectedreadme != toversionstring (* newversion )):
189
+ print (colored (255 , 0 , 0 , "Consider updating the readme link to " + toversionstring (* newversion )))
190
+
191
+
192
+
193
+ print ("Please run the tests before issuing a release. \n " )
163
194
print ("to issue release, enter \n git commit -a && git push && git tag -a v" + toversionstring (* newversion )+ " -m \" version " + toversionstring (* newversion )+ "\" && git push --tags \n " )
195
+
196
+
197
+
0 commit comments