1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-21 06:53:01 +08:00
lvgl/scripts/release.py

264 lines
5.5 KiB
Python
Raw Normal View History

2020-02-26 23:31:16 +01:00
import re
import os
lastNum = re.compile(r'(?:[^\d]*(\d+)[^\d]*)+')
def title(t):
print("\n---------------------------------")
print(t)
print("---------------------------------")
def cmd(c):
print("\n" + c)
os.system(c)
def increment(s):
""" look for the last sequence of number(s) in a string and increment """
m = lastNum.search(s)
if m:
next = str(int(m.group(1))+1)
start, end = m.span(1)
s = s[:max(end-len(next), start)] + next + s[end:]
return s, str(next)
def lvgl_clone():
title("lvgl: Clone")
2020-06-01 20:23:07 +02:00
cmd("git clone https://github.com/lvgl/lvgl.git")
2020-02-26 23:31:16 +01:00
os.chdir("./lvgl")
cmd("git co master")
def lvgl_format():
title("lvgl: Run code formatter")
2020-06-16 13:42:34 +02:00
os.chdir("./scripts")
cmd("./code-formatter.sh")
cmd("git ci -am 'Run code formatter'")
os.chdir("..")
2020-02-26 23:31:16 +01:00
def lvgl_update_version():
title("lvgl: Update version number")
f = open("./lvgl.h", "r")
2020-02-26 23:31:16 +01:00
outbuf = ""
major_ver = -1
minor_ver = -1
patch_ver = -1
for i in f.read().splitlines():
r = re.search(r'^#define LVGL_VERSION_MAJOR ', i)
if r:
m = lastNum.search(i)
if m: major_ver = m.group(1)
r = re.search(r'^#define LVGL_VERSION_MINOR ', i)
if r:
m = lastNum.search(i)
if m: minor_ver = m.group(1)
r = re.search(r'^#define LVGL_VERSION_PATCH ', i)
if r:
2020-06-01 20:23:07 +02:00
m = lastNum.search(i)
if m: patch_ver = m.group(1)
2020-02-26 23:31:16 +01:00
r = re.search(r'^#define LVGL_VERSION_INFO ', i)
if r:
i = "#define LVGL_VERSION_INFO \"\""
outbuf += i + '\n'
f.close()
f = open("./lvgl.h", "w")
2020-02-26 23:31:16 +01:00
f.write(outbuf)
f.close()
s = "v" + str(major_ver) + "." + str(minor_ver) + "." + str(patch_ver)
print("New version:" + s)
return s
def lvgl_update_library_json(v):
title("lvgl: Update version number in library.json")
f = open("./library.json", "r")
outbuf = ""
for i in f.read().splitlines():
r = re.search(r'"version": ', i)
if r:
i = ' "version": "' + v + '",'
outbuf += i + '\n'
f.close()
f = open("./library.json", "w")
f.write(outbuf)
f.close()
def lvgl_update_lv_conf_templ(ver_str):
title("lvgl: Update version number in lv_conf_template.h")
cmd("sed -i -r 's/v[0-9]+\.[0-9]+\.[0-9]+/"+ ver_str +"/' lv_conf_template.h ")
2020-02-26 23:31:16 +01:00
def lvgl_commit_push(v):
title("lvgl: commit and push release")
cmd('git ci -am "Release ' + v + '"')
cmd('git tag -a ' + v + ' -m "Release ' + v +'"')
cmd('git push origin master')
cmd('git push origin ' + v)
def lvgl_merge_to_release_branch(v):
title("lvgl: merge to release branch")
cmd('git co release/v7')
cmd('git merge master')
cmd('git push origin release/v7')
2020-02-26 23:31:16 +01:00
def lvgl_update_api_docs():
title("lvgl: Update API with Doxygen")
cmd("cd scripts; doxygen");
os.chdir("../")
def examples_clone():
title("examples: Clone")
cmd("git clone https://github.com/lvgl/lv_examples.git")
os.chdir("./lv_examples")
cmd("git co master")
2020-02-26 23:31:16 +01:00
def examples_commit_push(v):
title("examples: commit and push release")
cmd('git ci -am "Release ' + v + '"')
cmd('git tag -a ' + v + ' -m "Release ' + v +'"')
cmd('git push origin master')
cmd('git push origin ' + v)
def examples_merge_to_release_branch(v):
title("examples: merge to release branch")
cmd('git co release/v7')
cmd('git merge master')
cmd('git push origin release/v7')
os.chdir("../")
def drivers_clone():
title("drivers: Clone")
cmd("git clone https://github.com/lvgl/lv_drivers.git")
os.chdir("./lv_drivers")
cmd("git co master")
def drivers_commit_push(v):
title("drivers: commit and push release")
cmd('git ci -am "Release ' + v + '"')
cmd('git tag -a ' + v + ' -m "Release ' + v +'"')
cmd('git push origin master')
cmd('git push origin ' + v)
def drivers_merge_to_release_branch(v):
title("drivers: merge to release branch")
cmd('git co release/v7')
cmd('git merge master')
cmd('git push origin release/v7')
os.chdir("../")
2020-02-26 23:31:16 +01:00
def docs_clone():
title("docs: Clone")
2020-06-01 20:23:07 +02:00
cmd("git clone --recursive https://github.com/lvgl/docs.git")
os.chdir("./docs/v7")
2020-02-26 23:31:16 +01:00
cmd("git co master")
def docs_get_api():
title("docs: Get API files")
cmd("rm -rf xml");
cmd("cp -r ../../lvgl/docs/api_doc/xml .");
2020-02-26 23:31:16 +01:00
def docs_update_version(v):
title("docs: Update version number")
f = open("./conf.py", "r")
outbuf = ""
for i in f.read().splitlines():
r = re.search(r'^version = ', i)
if r:
i = "version = '" + v + "'"
r = re.search(r'^release = ', i)
if r:
i = "version = '" + v + "'"
outbuf += i + '\n'
f.close()
f = open("./conf.py", "w")
f.write(outbuf)
f.close()
def docs_update_trans():
title("docs: Update translations")
cmd("cd en && ./trans_push.py && ./trans_pull.py")
def docs_build():
title("docs: Build")
cmd("./build.py clean")
def docs_commit_push(v):
title("docs: Commit release")
cmd('git add .')
cmd('git ci -am "Release ' + v + '"')
cmd('git tag -a ' + v + ' -m "Release ' + v +'"')
cmd('git push origin master')
cmd('git push origin ' + v)
def clean_up():
title("Clean up repos")
os.chdir("../..")
cmd("rm -rf lvgl docs lv_examples lv_drivers")
2020-02-26 23:31:16 +01:00
lvgl_clone()
lvgl_format()
2020-02-26 23:31:16 +01:00
lvgl_update_api_docs()
ver_str = lvgl_update_version()
lvgl_update_library_json(ver_str)
lvgl_update_lv_conf_templ(ver_str)
2020-02-26 23:31:16 +01:00
lvgl_commit_push(ver_str)
lvgl_merge_to_release_branch(ver_str)
examples_clone()
examples_commit_push(ver_str)
examples_merge_to_release_branch(ver_str)
drivers_clone()
drivers_commit_push(ver_str)
drivers_merge_to_release_branch(ver_str)
2020-02-26 23:31:16 +01:00
docs_clone()
docs_get_api()
docs_update_version(ver_str)
2020-06-01 20:23:07 +02:00
#docs_update_trans() # Zanata is not working now
2020-02-26 23:31:16 +01:00
docs_build()
docs_commit_push(ver_str)
clean_up()