Skip to content

Commit

Permalink
Automate version bumps, avoid manual mistakes (#725)
Browse files Browse the repository at this point in the history
  • Loading branch information
earlephilhower authored Dec 31, 2024
1 parent b0a06ed commit 8adeb31
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tools/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Publishing New Releases
=======================

First, update the version number throughout the repo and push the change:

./tools/makever.py --version X.Y.Z
git commit -a -m "Update version"
git push

Then tag it

git tag X.Y.Z
git push origin X.Y.Z

Then on the GH web interface make a new release from that tag.
41 changes: 41 additions & 0 deletions tools/makever.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env python3
import sys
import struct
import subprocess
import re
import os
import os.path
import argparse
import time
import shutil
import json

def main():
parser = argparse.ArgumentParser(description='Version updater')
parser.add_argument('-v', '--version', action='store', required=True, help='Version in X.Y.Z form')
args = parser.parse_args()

major, minor, sub = args.version.split(".")
# Silly way to check for integer x.y.z
major = int(major)
minor = int(minor)
sub = int(sub)

# library.properties
with open("library.properties", "r") as fin:
with open("library.properties.new", "w") as fout:
for l in fin:
if l.startswith("version="):
l = "version=" + str(args.version) + "\n"
fout.write(l);
shutil.move("library.properties.new", "library.properties")

# package.json
with open("library.json", "r") as fin:
library = json.load(fin);
library["version"] = str(args.version);
with open("library.json.new", "w") as fout:
json.dump(library, fout, indent = 4);
shutil.move("library.json.new", "library.json")

main()

0 comments on commit 8adeb31

Please sign in to comment.