Add version update script

This commit is contained in:
calzoneman 2013-04-23 16:16:43 -05:00
parent 6b5466f5ae
commit 0d7da77715
3 changed files with 75 additions and 2 deletions

View File

@ -2,7 +2,7 @@
"author": "Calvin Montgomery", "author": "Calvin Montgomery",
"name": "CyTube", "name": "CyTube",
"description": "Online media synchronizer and chat", "description": "Online media synchronizer and chat",
"version": "1.2.4", "version": "1.2.5",
"repository": { "repository": {
"url": "http://github.com/calzoneman/sync" "url": "http://github.com/calzoneman/sync"
}, },

View File

@ -9,7 +9,7 @@ The above copyright notice and this permission notice shall be included in all c
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/ */
const VERSION = "1.2.4"; const VERSION = "1.2.5";
var fs = require("fs"); var fs = require("fs");
var Logger = require("./logger.js"); var Logger = require("./logger.js");

73
version.py Normal file
View File

@ -0,0 +1,73 @@
#!/usr/bin/python3
import re
import sys
PKGVER = re.compile(r'"version":(?:\s+)?"(\d)\.(\d)\.(\d)"')
SERVER = re.compile(r'VERSION(?:\s+)?=(?:\s+)"(\d)\.(\d)\.(\d)";')
OP = "patch"
if len(sys.argv) > 1 and sys.argv[1] in ["patch", "minor", "major"]:
OP = sys.argv[1]
pkgbuf = []
with open("package.json") as f:
for line in f:
m = PKGVER.search(line)
sb = []
if m:
sb.append(line[:m.start(1)])
if OP == "major":
sb.append(str(int(line[m.start(1):m.end(1)])+1))
else:
sb.append(line[m.start(1):m.end(1)])
sb.append(line[m.end(1):m.start(2)])
if OP == "minor":
sb.append(str(int(line[m.start(2):m.end(2)])+1))
elif OP == "major":
sb.append("0")
else:
sb.append(line[m.start(2):m.end(2)])
sb.append(line[m.end(2):m.start(3)])
if OP == "patch":
sb.append(str(int(line[m.start(3):m.end(3)])+1))
elif OP == "minor" or OP == "major":
sb.append("0")
sb.append(line[m.end(3):])
pkgbuf.append("".join(sb))
print("package.json: {} => {}".format(line, "".join(sb)))
else:
pkgbuf.append(line)
with open("package.json", "w") as f:
f.write("".join(pkgbuf))
serbuf = []
with open("server.js") as f:
for line in f:
m = SERVER.search(line)
sb = []
if m:
sb.append(line[:m.start(1)])
if OP == "major":
sb.append(str(int(line[m.start(1):m.end(1)])+1))
else:
sb.append(line[m.start(1):m.end(1)])
sb.append(line[m.end(1):m.start(2)])
if OP == "minor":
sb.append(str(int(line[m.start(2):m.end(2)])+1))
elif OP == "major":
sb.append("0")
else:
sb.append(line[m.start(2):m.end(2)])
sb.append(line[m.end(2):m.start(3)])
if OP == "patch":
sb.append(str(int(line[m.start(3):m.end(3)])+1))
elif OP == "minor" or OP == "major":
sb.append("0")
sb.append(line[m.end(3):])
serbuf.append("".join(sb))
print("server.js: {} => {}".format(line, "".join(sb)))
else:
serbuf.append(line)
with open("server.js", "w") as f:
f.write("".join(serbuf))