Skip to content

Commit 8adeb31

Browse files
Automate version bumps, avoid manual mistakes (#725)
1 parent b0a06ed commit 8adeb31

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

tools/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Publishing New Releases
2+
=======================
3+
4+
First, update the version number throughout the repo and push the change:
5+
6+
./tools/makever.py --version X.Y.Z
7+
git commit -a -m "Update version"
8+
git push
9+
10+
Then tag it
11+
12+
git tag X.Y.Z
13+
git push origin X.Y.Z
14+
15+
Then on the GH web interface make a new release from that tag.

tools/makever.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env python3
2+
import sys
3+
import struct
4+
import subprocess
5+
import re
6+
import os
7+
import os.path
8+
import argparse
9+
import time
10+
import shutil
11+
import json
12+
13+
def main():
14+
parser = argparse.ArgumentParser(description='Version updater')
15+
parser.add_argument('-v', '--version', action='store', required=True, help='Version in X.Y.Z form')
16+
args = parser.parse_args()
17+
18+
major, minor, sub = args.version.split(".")
19+
# Silly way to check for integer x.y.z
20+
major = int(major)
21+
minor = int(minor)
22+
sub = int(sub)
23+
24+
# library.properties
25+
with open("library.properties", "r") as fin:
26+
with open("library.properties.new", "w") as fout:
27+
for l in fin:
28+
if l.startswith("version="):
29+
l = "version=" + str(args.version) + "\n"
30+
fout.write(l);
31+
shutil.move("library.properties.new", "library.properties")
32+
33+
# package.json
34+
with open("library.json", "r") as fin:
35+
library = json.load(fin);
36+
library["version"] = str(args.version);
37+
with open("library.json.new", "w") as fout:
38+
json.dump(library, fout, indent = 4);
39+
shutil.move("library.json.new", "library.json")
40+
41+
main()

0 commit comments

Comments
 (0)