Skip to content

Commit

Permalink
Add script for renaming continuous releases to tagged released
Browse files Browse the repository at this point in the history
  • Loading branch information
mortbopet committed Jun 15, 2021
1 parent dab3ee3 commit 0ba8847
Showing 1 changed file with 53 additions and 0 deletions.
53 changes: 53 additions & 0 deletions prepareRelease.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import argparse
import os
import requests
from zipfile import ZipFile
import shutil

LINUX_APP = "https://github.com/mortbopet/Ripes/releases/download/continuous/Ripes-continuous-linux-x86_64.AppImage"
WIN_APP = "https://github.com/mortbopet/Ripes/releases/download/continuous/Ripes-continuous-win-x86_64.zip"
OSX_APP = "https://github.com/mortbopet/Ripes/releases/download/continuous/Ripes-continuous-mac-x86_64.zip"
APP_URLS = [LINUX_APP, WIN_APP, OSX_APP]


TMP_DIR = "ripes_release_tmp"

if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('-v', '--version',
help='Version number', required=True)
files = []

args = parser.parse_args()

def zip_extract_repl(file):
with ZipFile(file, 'r') as zip_obj:
temp_zipdir = file + 'tempzip'
zip_obj.extractall(temp_zipdir)
repl_version(temp_zipdir)
os.remove(file)
shutil.make_archive(file.replace('.zip', ""), 'zip', temp_zipdir)
shutil.rmtree(temp_zipdir)

def repl_version(folder):
def _repl(f):
newname = f.replace('continuous', args.version)
os.rename(f, newname)
if newname != f and newname.endswith(".zip"):
zip_extract_repl(newname)

for (dirpath, dirnames, filenames) in os.walk(folder):
for d in dirnames:
_repl(os.path.join(dirpath, d))
for f in filenames:
_repl(os.path.join(dirpath, f))

shutil.rmtree(TMP_DIR)
os.mkdir(TMP_DIR)
for url in APP_URLS:
r = requests.get(url, allow_redirects=True)
fn = os.path.join(TMP_DIR, url.split("/")[-1])
open(fn, 'wb').write(r.content)
files.append(fn)

repl_version(TMP_DIR)

0 comments on commit 0ba8847

Please sign in to comment.