Skip to content

Commit

Permalink
build(manual_release): change version structure
Browse files Browse the repository at this point in the history
  • Loading branch information
JaDogg committed Apr 14, 2024
1 parent e6ee439 commit ee7f261
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions compiler/scripts/manual_release.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,44 @@
import datetime
import os
import subprocess

FILE_PATH = os.path.dirname(os.path.realpath(__file__))
LIBS_PATH = os.path.join(FILE_PATH, '../libs')

LIBS_FILE = os.path.join(LIBS_PATH, 'libs.yaka')
RELEASE_FILE = os.path.join(FILE_PATH, 'release.ini')

def execute(args: list):
proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf-8",
universal_newlines=True, env=dict(os.environ))
try:
so, se = proc.communicate(timeout=6)
except subprocess.TimeoutExpired:
proc.kill()
proc.communicate()
return ""
return so + se

def main():
current_date = datetime.datetime.now().strftime('%Y%m%d')
# update return "version" in libs.yaka to alpha-yyyymmdd
current_commit_hash = execute(['git', 'rev-parse', 'HEAD']).strip()[:7].lower()
# A pre-release version -- vP20210101.abcdefg
new_version = 'P' + current_date + '.' + current_commit_hash
# update return "version" in libs.yaka
with open(LIBS_FILE, 'r', encoding="utf-8") as f:
lines = f.read().splitlines(keepends=False)
for i, line in enumerate(lines):
if 'return "' in line:
lines[i] = ' return "nightly-' + current_date + '"'
lines[i] = ' return "' + new_version + '"'
break
with open(LIBS_FILE, 'w', encoding="utf-8") as f:
f.write('\n'.join(lines) + '\n')
# update version="version" in release.ini to alpha-yyyymmdd
# update version="version" in release.ini
with open(RELEASE_FILE, 'r', encoding="utf-8") as f:
lines = f.read().splitlines(keepends=False)
for i, line in enumerate(lines):
if 'version=' in line:
lines[i] = 'version=nightly-' + current_date
lines[i] = 'version=' + new_version
break
with open(RELEASE_FILE, 'w', encoding="utf-8") as f:
f.write('\n'.join(lines) + '\n')
Expand Down

0 comments on commit ee7f261

Please sign in to comment.