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

256 lines
5.6 KiB
Python
Raw Normal View History

2020-07-07 10:00:38 +02:00
#!/usr/bin/env python
2020-02-26 23:31:16 +01:00
import re
import os
lastNum = re.compile(r'(?:[^\d]*(\d+)[^\d]*)+')
def title(t):
2020-07-07 10:00:38 +02:00
print("\n---------------------------------")
print(t)
print("---------------------------------")
2020-02-26 23:31:16 +01:00
def cmd(c):
2020-07-07 10:00:38 +02:00
print("\n" + c)
r = os.system(c)
2020-07-07 09:32:21 +02:00
if r:
2020-07-07 10:00:38 +02:00
print("### Error: " + str(r))
2020-02-26 23:31:16 +01:00
def lvgl_clone():
2020-07-07 10:00:38 +02:00
title("lvgl: Clone")
cmd("git clone https://github.com/lvgl/lvgl.git")
os.chdir("./lvgl")
cmd("git co master")
2020-02-26 23:31:16 +01:00
def lvgl_format():
title("lvgl: Run code formatter")
2020-06-16 13:42:34 +02:00
os.chdir("./scripts")
2020-06-16 13:55:42 +02:00
cmd("./code-format.sh")
2020-07-07 10:00:38 +02:00
os.system("git ci -am 'Run code formatter'")
2020-06-16 13:42:34 +02:00
os.chdir("..")
2020-02-26 23:31:16 +01:00
def lvgl_update_version():
2020-07-07 10:00:38 +02:00
title("lvgl: Update version number")
f = open("./lvgl.h", "r")
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:
m = lastNum.search(i)
if m: patch_ver = m.group(1)
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")
f.write(outbuf)
f.close()
2020-02-26 23:31:16 +01:00
2020-07-07 10:00:38 +02:00
s = "v" + str(major_ver) + "." + str(minor_ver) + "." + str(patch_ver)
print("New version:" + s)
return s
2020-02-26 23:31:16 +01:00
def lvgl_update_library_json(v):
2020-07-07 10:00:38 +02:00
title("lvgl: Update version number in library.json")
f = open("./library.json", "r")
2020-07-08 15:02:40 +02:00
vn = v[1:]
2020-07-07 10:00:38 +02:00
outbuf = ""
for i in f.read().splitlines():
r = re.search(r'"version": ', i)
if r:
2020-07-08 15:02:40 +02:00
i = ' "version": "' + vn + '",'
2020-07-07 10:00:38 +02:00
outbuf += i + '\n'
f.close()
f = open("./library.json", "w")
f.write(outbuf)
f.close()
2020-02-26 23:31:16 +01:00
def lvgl_update_lv_conf_templ(ver_str):
2020-07-07 10:00:38 +02:00
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):
2020-07-07 10:00:38 +02:00
title("lvgl: commit and push release")
2020-02-26 23:31:16 +01:00
2020-07-07 10:00:38 +02:00
os.system('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):
2020-07-07 10:00:38 +02:00
title("lvgl: 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 lvgl_update_api_docs():
2020-07-07 10:00:38 +02:00
title("lvgl: Update API with Doxygen")
2020-02-26 23:31:16 +01:00
2020-07-07 10:00:38 +02:00
cmd("cd scripts; doxygen");
def examples_clone():
2020-07-07 10:00:38 +02:00
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):
2020-07-07 10:00:38 +02:00
title("examples: commit and push release")
2020-07-07 10:00:38 +02:00
os.system('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):
2020-07-07 10:00:38 +02:00
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():
2020-07-07 10:00:38 +02:00
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):
2020-07-07 10:00:38 +02:00
title("drivers: commit and push release")
2020-07-07 10:00:38 +02:00
os.system('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):
2020-07-07 10:00:38 +02:00
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():
2020-07-07 10:00:38 +02:00
title("docs: Clone")
2020-07-21 13:38:04 +02:00
cmd("git clone --recursive https://github.com/lvgl/docs.git")
2020-07-07 10:00:38 +02:00
os.chdir("./docs")
2020-02-26 23:31:16 +01:00
def docs_get_api():
2020-07-07 10:00:38 +02:00
title("docs: Get API files")
cmd("git co latest --")
cmd("rm -rf xml");
cmd("cp -r ../lvgl/docs/api_doc/xml .");
cmd("git add xml");
cmd('git commit -m "update API"')
2020-02-26 23:31:16 +01:00
def docs_update_version(v):
2020-07-07 10:00:38 +02:00
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()
cmd("git add conf.py")
cmd('git ci -m "update conf.py to ' + v + '"')
2020-02-26 23:31:16 +01:00
2020-08-04 09:49:57 +02:00
def docs_merge_to_release_branch(v):
title("docs: merge to release branch")
cmd('git co release/v7 --')
cmd('git clean -fd .')
2020-08-04 09:57:29 +02:00
cmd('rm -f LVGL.pdf') #To avoide possible merge conflict
2020-08-04 09:49:57 +02:00
cmd('git merge latest')
cmd('git push origin release/v7')
2020-02-26 23:31:16 +01:00
def docs_build():
2020-07-07 10:00:38 +02:00
title("docs: Build")
cmd("git checkout master")
2020-08-04 09:49:57 +02:00
cmd("./update.py latest release/v7")
2020-07-07 10:00:38 +02:00
2020-02-26 23:31:16 +01:00
def clean_up():
2020-07-07 10:00:38 +02:00
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-08-04 10:06:57 +02:00
docs_merge_to_release_branch(v)
2020-02-26 23:31:16 +01:00
docs_build()
clean_up()