Skip to content

Commit

Permalink
build: script for doing a release
Browse files Browse the repository at this point in the history
  • Loading branch information
richardstephens committed Dec 5, 2020
1 parent d07ec4a commit ba7bbf0
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions release.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/usr/bin/env python3

import os
import sys
import hashlib
import subprocess

version = sys.argv[1]
print("Releasing version v" + version)
release_file = "rules_jooq_flyway_codegen-v" + version + ".tgz"
subprocess.run(["git", "tag" , "v"+version], check=True)

subprocess.run(["git", "archive", "--format=tar.gz", "-o", release_file, "HEAD"], check=True)
with open(release_file, "rb") as f:
bytes=f.read()
checksum = hashlib.sha256(bytes).hexdigest()

lines = []
with open("README.md", "r") as f:
lines = f.readlines()

with open("README-new.md", "w") as f:
for l in lines:
print(l)
if " sha256" in l:
f.write(" sha256 = \"" + checksum + "\",\n")
elif "urls = [\"https://github.com/richardstephens/rules_jooq_flyway_codegen" in l:
f.write(" urls = [\"https://github.com/richardstephens/rules_jooq_flyway_codegen/releases/download"
+"v"+version+"/"+release_file+"\"],\n")
else:
f.write(l)

os.unlink("README.md")
os.rename("README-new.md", "README.md")


0 comments on commit ba7bbf0

Please sign in to comment.