diff --git a/.gitignore b/.gitignore index f0da6a113..07070a949 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +scripts/release/__pycache__ **/*.o **/*bin **/*.swp diff --git a/scripts/release.py b/scripts/release.py deleted file mode 100755 index 67e90f0ce..000000000 --- a/scripts/release.py +++ /dev/null @@ -1,517 +0,0 @@ -#!/usr/bin/env python - -# Release lvgl, lv_examples, lv_drivers. docs, blog and prepare the development of the next major, minoror bugfix release -# Usage: ./release,py bugfix | minor | major -# The option means what type of versin to prepare for development after release -# -# STEPS: -# - clone all 5 repos -# - get the version numnber from lvgl.h -# - set release branch (e.g. "release/v7") -# - prepare lvgl -# - run lv_conf_internal.py -# - run code formatter -# - clear LVGL_VERSION_INFO (set to "") -# - run Doxygen -# - update the version in lvgl's library.json, library.properties, lv_conf_template.h -# - update CHANGELOG.md -# - commit changes -# - prepare lv_examples -# - upadte the required LVGL version in lv_examples.h (LV_VERSION_CHECK) -# - update the version in lv_ex_conf_template.h -# - prepare lv_drivers -# - update the version in library.json, lv_drv_conf_template.h -# - prepare docs -# - update API XML -# - clear the versiopn info (should be plain vx.y.z) -# - tag all repos with the new version -# - merge to release branches -# - blog: add release post -# - push tags and commits -# - docs: run ./updade.py release/vX -# -# If --patch -# - merge master to dev branches -# - increment patch version by 1 and append "-dev". E.g. "vX.Y.(Z+1)-dev" -# - update version numbers in lvgl and docs -# - commit and push -# - docs: run ./updade.py latest dev -# -# Else (not --patch) -# - merge master to dev -# - merge the dev to master -# - increment version number like "vX.(Y+1).0-dev" -# - apply the new version in dev branches of lvgl, lv_examples, lv_drivers, docs -# - commit and push to dev branches -# - docs: run ./updade.py latest dev - -import re -import os, fnmatch -import os.path -from os import path -from datetime import date -import sys - -upstream_org_url = "https://github.com/lvgl/" -workdir = "./release_tmp" -proj_list = [ "lv_sim_eclipse_sdl", "lv_sim_emscripten"] - -ver_major = -1 -ver_minor = -1 -ver_patch = -1 - -dev_ver_major = -1 -dev_ver_minor = -1 -dev_ver_patch = -1 - -ver_str = "" -dev_ver_str = "" -release_br = "" -release_note = "" - -prepare_type = ['major', 'minor', 'bugfix'] - -dev_prepare = 'minor' - -def upstream(repo): - return upstream_org_url + repo + ".git" - -def cmd(c, exit_on_err = True): - print("\n" + c) - r = os.system(c) - if r: - print("### Error: " + str(r)) - if exit_on_err: exit(int(r)) - -def define_set(fn, name, value): - print("In " + fn + " set " + name + " to " + value) - - new_content = "" - s = r'^ *# *define +' + str(name).rstrip() + ' +' - - f = open(fn, "r") - for i in f.read().splitlines(): - r = re.search(s, i) - if r: - d = i.split("define") - i = d[0] + "define " + name + " " + value - new_content += i + '\n' - - f.close() - - f = open(fn, "w") - f.write(new_content) - f.close() - -def clone_repos(): - cmd("rm -fr " + workdir) - cmd("mkdir " + workdir) - os.chdir(workdir) - - cmd("git clone " + upstream("lvgl") + "; cd lvgl; git checkout master; git remote update origin --prune; ") - cmd("git clone " + upstream("lv_examples") + "; cd lv_examples; git checkout master; git remote update origin --prune; ") - cmd("git clone " + upstream("lv_drivers") + "; cd lv_drivers; git checkout master; git remote update origin --prune; ") - cmd("git clone --recurse-submodules " + upstream("docs") + "; cd docs; git checkout master; git remote update origin --prune; ") - cmd("git clone " + upstream("blog") + "; cd blog; git checkout master; git remote update origin --prune; ") - - for p in proj_list: - cmd("git clone " + upstream(p) + " --recurse-submodules ; cd " + p + "; git checkout master; git remote update origin --prune; ") - - -def get_lvgl_version(br): - print("Get LVGL's version") - - global ver_str, ver_major, ver_minor, ver_patch, release_br - - os.chdir("./lvgl") - - cmd("git checkout " + br) - - f = open("./lvgl.h", "r") - - lastNum = re.compile(r'(?:[^\d]*(\d+)[^\d]*)+') - for i in f.read().splitlines(): - r = re.search(r'^#define LVGL_VERSION_MAJOR ', i) - if r: - m = lastNum.search(i) - if m: ver_major = m.group(1) - - r = re.search(r'^#define LVGL_VERSION_MINOR ', i) - if r: - m = lastNum.search(i) - if m: ver_minor = m.group(1) - - r = re.search(r'^#define LVGL_VERSION_PATCH ', i) - if r: - m = lastNum.search(i) - if m: ver_patch = m.group(1) - - f.close() - - cmd("git checkout master") - - ver_str = "v" + str(ver_major) + "." + str(ver_minor) + "." + str(ver_patch) - print("New version:" + ver_str) - - release_br = "release/v" + ver_major - - os.chdir("../") - -def update_version(): - templ = fnmatch.filter(os.listdir('.'), '*templ*') - - if templ[0]: - print("Updating version in " + templ[0]) - cmd("sed -i -r 's/v[0-9]+\.[0-9]+\.[0-9]+/"+ ver_str +"/' " + templ[0]) - - if os.path.exists("library.json"): - print("Updating version in library.json") - cmd("sed -i -r 's/[0-9]+\.[0-9]+\.[0-9]+/"+ ver_str[1:] +"/' library.json") - - if path.exists("library.properties"): - print("Updating version in library.properties") - cmd("sed -i -r 's/version=[0-9]+\.[0-9]+\.[0-9]+/"+ "version=" + ver_str[1:] + "/' library.properties") - -def lvgl_prepare(): - print("Prepare lvgl") - - global ver_str, ver_major, ver_minor, ver_patch - - os.chdir("./lvgl") - define_set("./lvgl.h", "LVGL_VERSION_INFO", '\"\"') - - # Run some scripts - os.chdir("./scripts") - cmd("./code-format.sh") - cmd("./lv_conf_checker.py") - cmd("doxygen") - os.chdir("../") - - update_version() - - #update CHANGLELOG - new_content = "" - f = open("./CHANGELOG.md", "r") - - global release_note - release_note = "" - note_state = 0 - for i in f.read().splitlines(): - if note_state == 0: - r = re.search(r'^## ' + ver_str, i) - if r: - i = i.replace("planned on ", "") - note_state+=1 - - elif note_state == 1: - r = re.search(r'^## ', i) - if r: - note_state+=1 - else: - release_note += i + '\n' - - new_content += i + '\n' - - f.close() - - f = open("./CHANGELOG.md", "w") - f.write(new_content) - f.close() - - cmd('git commit -am "prepare to release ' + ver_str + '"') - - os.chdir("../") - - -def lv_examples_prepare(): - print("Prepare lv_examples") - global ver_str, ver_major, ver_minor, ver_patch - - os.chdir("./lv_examples") - - update_version() - - cmd("sed -i -r 's/LV_VERSION_CHECK\([0-9]+, *[0-9]+, *[0-9]+\)/"+ "LV_VERSION_CHECK(" + ver_major + ", " + ver_minor + ", " + ver_patch + ")/' lv_examples.h") - - cmd('git commit -am "prepare to release ' + ver_str + '"') - - os.chdir("../") - -def lv_drivers_prepare(): - print("Prepare lv_drivers") - global ver_str, ver_major, ver_minor, ver_patch - - os.chdir("./lv_drivers") - - update_version() - - cmd('git commit -am "prepare to release ' + ver_str + '"') - - os.chdir("../") - -def docs_prepare(): - print("Prepare docs") - global ver_str, ver_major, ver_minor, ver_patch - - os.chdir("./docs") - - cmd("git co latest --") - cmd("rm -rf xml"); - cmd("cp -r ../lvgl/docs/api_doc/xml ."); - cmd("git add xml"); - - cmd("sed -i -r \"s/'v[0-9]+\.[0-9]+\.[0-9]+.*'/\'" + ver_str + "'/\" conf.py") - - cmd('git commit -am "prepare to release ' + ver_str + '"') - - os.chdir("../") - -def blog_add_post(): - global ver_str, release_note - - os.chdir("./blog/_posts") - - post = "---\nlayout: post\ntitle: " + ver_str + " is released\nauthor: \"kisvegabor\"\ncover: /assets/release_cover.png\n---\n\n" - post += release_note - - today = date.today() - d = today.strftime("%Y-%m-%d") - - f = open(d + "-release_" + ver_str + ".md", "w") - f.write(post) - f.close() - - cmd("git add .") - cmd("git commit -am 'Add " + ver_str + " release post'") - - os.chdir("../../") - -def add_tags(): - global ver_str - tag_cmd = " git tag -a " + ver_str + " -m 'Release " + ver_str + "' " - cmd("cd lvgl; " + tag_cmd) - cmd("cd lv_examples; " + tag_cmd) - cmd("cd lv_drivers; " + tag_cmd) - cmd("cd docs; " + tag_cmd) - -def update_release_branches(): - global release_br - merge_cmd = " git checkout " + release_br + "; git pull origin " + release_br + "; git merge master -X ours; git push origin " + release_br + "; git checkout master" - cmd("cd lvgl; " + merge_cmd) - cmd("cd lv_examples; " + merge_cmd) - cmd("cd lv_drivers; " + merge_cmd) - - merge_cmd = " git checkout " + release_br + "; git pull origin " + release_br + "; git merge latest -X ours; git push origin " + release_br + "; git checkout latest" - cmd("cd docs; " + merge_cmd) - -def publish_master(): - - #Merge LVGL master to dev first to avoid "merge-to-dev.yml" running asynchronous - os.chdir("./lvgl") - cmd("git checkout dev") - cmd("git merge master -X ours") - cmd("git add .") - cmd("git commit -am 'Merge master'", False) - cmd("git push origin dev") - cmd("git checkout master") - os.chdir("../") - - pub_cmd = "git push origin master; git push origin " + ver_str - cmd("cd lvgl; " + pub_cmd) - cmd("cd lv_examples; " + pub_cmd) - cmd("cd lv_drivers; " + pub_cmd) - - pub_cmd = "git push origin master" - cmd("cd blog; " + pub_cmd) - -def merge_from_dev(): - merge_cmd = "git checkout master; git merge dev;" - cmd("cd lvgl; " + merge_cmd) - - merge_cmd = "git checkout latest -- ; git merge dev -X theirs --no-edit;" - cmd("cd docs; " + merge_cmd) - - -def lvgl_update_master_version(): - global ver_major, ver_minor, ver_patch, ver_str - - os.chdir("./lvgl") - - cmd("git checkout master") - define_set("./lvgl.h", "LVGL_VERSION_MAJOR", ver_major) - define_set("./lvgl.h", "LVGL_VERSION_MINOR", ver_minor) - define_set("./lvgl.h", "LVGL_VERSION_PATCH", ver_patch) - define_set("./lvgl.h", "LVGL_VERSION_INFO", "dev") - - templ = fnmatch.filter(os.listdir('.'), '*templ*') - if templ[0]: - print("Updating version in " + templ[0]) - cmd("sed -i -r 's/v[0-9]+\.[0-9]+\.[0-9]+.*/"+ ver_str +"/' " + templ[0]) - - - cmd("git commit -am 'Update version'") - - os.chdir("../") - -def docs_update_latest_version(): - global ver_str - - os.chdir("./docs") - cmd("git checkout latest --") - cmd("sed -i -r \"s/'v[0-9]+\.[0-9]+\.[0-9]+.*'/\'" + ver_str + "'/\" conf.py") - cmd("git commit -am 'Update version'") - cmd("git checkout master --") - - os.chdir("../") - - -def lvgl_update_dev_version(): - global ver_major, ver_minor, ver_patch, dev_ver_str - - os.chdir("./lvgl") - - cmd("git checkout dev") - define_set("./lvgl.h", "LVGL_VERSION_MAJOR", str(ver_major)) - define_set("./lvgl.h", "LVGL_VERSION_MINOR", str(ver_minor)) - define_set("./lvgl.h", "LVGL_VERSION_PATCH", str(ver_patch)) - define_set("./lvgl.h", "LVGL_VERSION_INFO", "\"dev\"") - - templ = fnmatch.filter(os.listdir('.'), '*templ*') - if templ[0]: - print("Updating version in " + templ[0]) - cmd("sed -i -r 's/v[0-9]+\.[0-9]+\.[0-9]+.*/"+ dev_ver_str +"/' " + templ[0]) - - - cmd("git commit -am 'Update dev version'") - cmd("git checkout master") - - os.chdir("../") - -def docs_update_dev_version(): - global dev_ver_str - - os.chdir("./docs") - cmd("git checkout dev --") - cmd("sed -i -r \"s/'v[0-9]+\.[0-9]+\.[0-9]+.*'/\'" + dev_ver_str + "'/\" conf.py") - cmd("git commit -am 'Update dev version'") - cmd("git checkout master --") - - os.chdir("../") - - -def publish_dev_and_master(): - pub_cmd = "git checkout dev; git push origin dev" - cmd("cd lvgl; " + pub_cmd) - pub_cmd = "git checkout master; git push origin master" - cmd("cd lvgl; " + pub_cmd) - -def projs_update(): - global proj_list, release_br, ver_str - for p in proj_list: - os.chdir("./" + p) - cmd('git checkout master') - print(p + ": upadte lvgl"); - cmd("cd lvgl; git co " + release_br + "; git pull origin " + release_br) - cmd("cp -f lvgl/lv_conf_template.h lv_conf.h") - cmd("sed -i -r 's/#if 0/#if 1/' lv_conf.h") # Enable lv_conf.h - d = {} - with open("confdef.txt") as f: - for line in f: - (key, val) = line.rstrip().split('\t') - d[key] = val - - for k,v in d.items(): - define_set("lv_conf.h", str(k), str(v)) - - if os.path.exists("lv_examples"): - print(p + ": upadte lv_examples"); - cmd("cd lv_examples; git co " + release_br + "; git pull origin " + release_br) - - if os.path.exists("lv_drivers"): - print(p + ": upadte lv_drivers"); - cmd("cd lv_drivers " + release_br + "; git pull origin " + release_br) - - msg = 'Update to ' + ver_str - cmd("git add .") - cmd('git commit -am "' + msg + '"') - cmd('git push origin master') - cmd("git tag -a " + ver_str + " -m '" + msg + "' " ) - cmd('git push origin ' + ver_str) - - os.chdir("../") - -def docs_update_all(): - cmd("cd docs; git checkout master; python 2.7 ./update.py master dev " + release_br) - -def cleanup(): - os.chdir("../") - cmd("rm -fr " + workdir) - -if __name__ == '__main__': - dev_prepare = 'minor' - if(len(sys.argv) != 2): - print("Missing argument. Usage ./release.py bugfix | minor | major") - print("Use minor by deafult") - else: - dev_prepare = sys.argv[1] - - if not (dev_prepare in prepare_type): - print("Invalid argument. Usage ./release.py bugfix | minor | major") - exit(1) - - clone_repos() - get_lvgl_version("dev") - dev_ver_major = ver_major - dev_ver_minor = ver_minor - dev_ver_patch = ver_patch - dev_ver_str = ver_str - - get_lvgl_version("master") - - lvgl_prepare() - lv_examples_prepare() - lv_drivers_prepare() - docs_prepare() - blog_add_post() - add_tags() - update_release_branches() - publish_master() - - projs_update() - dev_ver_major = "7" - dev_ver_minor = "7" - dev_ver_patch = "0" - dev_ver_str = "v7.7.0" - - if dev_prepare == 'bugfix': - ver_patch = str(int(ver_patch) + 1) - ver_str = "v" + ver_major + "." + ver_minor + "." + ver_patch + "-dev" - - print("Prepare bugfix version " + ver_str) - - lvgl_update_master_version() - docs_update_latest_version() - - else: - merge_from_dev() - - if dev_prepare == 'minor': - ver_major = dev_ver_major - ver_minor = str(int(dev_ver_minor) + 1) - ver_patch = "0" - else: - ver_major = str(int(dev_ver_major) + 1) - ver_minor = "0" - ver_patch = "0" - - dev_ver_str = "v" + str(ver_major) + "." + str(ver_minor) + "." + str(ver_patch) + "-dev" - - print("Prepare minor version " + dev_ver_str) - - lvgl_update_dev_version() - docs_update_dev_version() - publish_dev_and_master() - - docs_update_all(); - cleanup() - diff --git a/scripts/release/__pycache__/com.cpython-36.pyc b/scripts/release/__pycache__/com.cpython-36.pyc new file mode 100644 index 000000000..a8d36f055 Binary files /dev/null and b/scripts/release/__pycache__/com.cpython-36.pyc differ diff --git a/scripts/release/__pycache__/dev.cpython-36.pyc b/scripts/release/__pycache__/dev.cpython-36.pyc new file mode 100644 index 000000000..3cae05ba8 Binary files /dev/null and b/scripts/release/__pycache__/dev.cpython-36.pyc differ diff --git a/scripts/release/__pycache__/proj.cpython-36.pyc b/scripts/release/__pycache__/proj.cpython-36.pyc new file mode 100644 index 000000000..16d4edc54 Binary files /dev/null and b/scripts/release/__pycache__/proj.cpython-36.pyc differ diff --git a/scripts/release/__pycache__/release.cpython-36.pyc b/scripts/release/__pycache__/release.cpython-36.pyc new file mode 100644 index 000000000..9f6263202 Binary files /dev/null and b/scripts/release/__pycache__/release.cpython-36.pyc differ diff --git a/scripts/release/com.py b/scripts/release/com.py new file mode 100755 index 000000000..d4abb2868 --- /dev/null +++ b/scripts/release/com.py @@ -0,0 +1,109 @@ +#!/usr/bin/env python + +import sys +import os.path +from os import path +import os, fnmatch +import re +import subprocess +import com + +def cmd(c, ask_on_err = True): + print("\n" + c) + r = os.system(c) + if r: + print("### Error: " + str(r)) + if exit_on_err: + input("Press Enter to continue exectution...") + +def define_set(fn, name, value): + print("In " + fn + " set " + name + " to " + value) + + new_content = "" + s = r'^ *# *define +' + str(name).rstrip() + ' +' + + f = open(fn, "r") + for i in f.read().splitlines(): + r = re.search(s, i) + if r: + d = i.split("define") + i = d[0] + "define " + name + " " + value + new_content += i + '\n' + + f.close() + + f = open(fn, "w") + f.write(new_content) + f.close() + +def ver_format(ver): + s = "v" + str(ver[0]) + "." + str(ver[1]) + "." + str(ver[2]) + if(ver[3] != ""): s = s + "-" + ver[3] + return s + +def get_lvgl_version(br): + print("Get LVGL's version") + + ver = [0, 0, 0, ""] + + os.chdir("./lvgl") + + com.cmd("git checkout " + br) + + f = open("./lvgl.h", "r") + + lastNum = re.compile(r'(?:[^\d]*(\d+)[^\d]*)+') + for i in f.read().splitlines(): + r = re.search(r'^#define LVGL_VERSION_MAJOR ', i) + if r: + m = lastNum.search(i) + if m: ver[0] = m.group(1) + + r = re.search(r'^#define LVGL_VERSION_MINOR ', i) + if r: + m = lastNum.search(i) + if m: ver[1] = m.group(1) + + r = re.search(r'^#define LVGL_VERSION_PATCH ', i) + if r: + m = lastNum.search(i) + if m: ver[2] = m.group(1) + + f.close() + + com.cmd("git checkout master") + + os.chdir("../") + return ver + +def push(c): + return + cmd(c) + +def update_version(ver): + ver_str = ver_format(ver) + ver_num = ver[0] + "." + ver[1] + "." + ver[2] + + templ = fnmatch.filter(os.listdir('.'), '*_templ*.h') + + if len(templ) > 0 and templ[0]: + print("Updating version in " + templ[0]) + cmd("sed -i -r 's/v[0-9]+\.[0-9]+\.[0-9]+/"+ "v" + ver_num + "/' " + templ[0]) + + if os.path.exists("library.json"): + print("Updating version in library.json") + cmd("sed -i -r 's/[0-9]+\.[0-9]+\.[0-9]+/"+ ver_num +"/' library.json") + + if path.exists("library.properties"): + print("Updating version in library.properties") + cmd("sed -i -r 's/version=[0-9]+\.[0-9]+\.[0-9]+/"+ "version=" + ver_num + "/' library.properties") + + if path.exists("conf.py"): + cmd("sed -i -r \"s/'v[0-9]+\.[0-9]+\.[0-9]+.*'/\'" + ver_str + "'/\" conf.py") + + if path.exists("lvgl.h"): + define_set("./lvgl.h", "LVGL_VERSION_MAJOR", str(ver[0])) + define_set("./lvgl.h", "LVGL_VERSION_MINOR", str(ver[1])) + define_set("./lvgl.h", "LVGL_VERSION_PATCH", str(ver[2])) + define_set("./lvgl.h", "LVGL_VERSION_INFO", "\"" + ver[3] + "\"") + diff --git a/scripts/release/dev.py b/scripts/release/dev.py new file mode 100755 index 000000000..42cfd6a5e --- /dev/null +++ b/scripts/release/dev.py @@ -0,0 +1,74 @@ +#!/usr/bin/env python + +import re +import os, fnmatch +import os.path +from os import path +from datetime import date +import com + +def lvgl_upadte_ver(ver, br): + os.chdir("./lvgl") + + com.cmd("git checkout " + br) + com.update_version(ver) + com.cmd("git commit -am 'Update " + br + " version'") + com.push("origin " + br) + com.cmd("git checkout master") + + os.chdir("../") + +def docs_update_ver(ver, br): + os.chdir("./docs") + com.cmd("git checkout " + br + " --") + com.update_version(ver) + com.cmd("git commit -am 'Update " + br + " version'") + com.push("origin " + br) + com.cmd("git checkout master --") + + os.chdir("../") + + +def merge_dev_to_master(): + os.chdir("./lvgl") + com.cmd("git checkout master") + com.cmd("git merge dev") + com.push("origin master") + os.chdir("../") + + os.chdir("./docs") + com.cmd("git checkout dev -- ") #'dev' sometimes is not recognized so switch to it first + com.cmd("git checkout latest --") + com.cmd("git merge dev -X theirs --no-edit;") + com.push("origin latest") + os.chdir("../") + + +def make(mode): + ver = com.get_lvgl_version("dev") + ver[3] = "dev" + if(mode == "bugfix"): + ver[2] = ver[2] + 1 + lvgl_update_ver(ver, "master") + docs_update_ver(ver, "latest") + else: + merge_dev_to_master() + if(mode == "major"): + ver[0] = str(int(ver[0]) + 1) + ver[1] = '0' + ver[2] = '0' + if(mode == "minor"): + ver[1] = str(int(ver[1]) + 1) + ver[2] = '0' + + lvgl_upadte_ver(ver, "dev") + docs_update_ver(ver, "dev") + + + +if __name__ == '__main__': + if(len(sys.argv) != 2): + print("Missing argument. Usage ./dev.py major | minor | bugfix") + print("E.g. ./dev.py minor") + else: + make(sys.argv[1]) diff --git a/scripts/release/main.py b/scripts/release/main.py new file mode 100755 index 000000000..8d329d471 --- /dev/null +++ b/scripts/release/main.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python + +import os.path +from os import path +from datetime import date +import sys +import com +import release +import dev +import proj + +upstream_org_url = "https://github.com/lvgl/" +workdir = "./release_tmp" +proj_list = [ "lv_sim_eclipse_sdl", "lv_sim_emscripten"] + +def upstream(repo): + return upstream_org_url + repo + ".git" + +def clone(repo): + com.cmd("git clone --recurse-submodules " + upstream(repo)) + os.chdir("./" + repo) + com.cmd("git checkout master") + com.cmd("git remote update origin --prune") + com.cmd("git pull origin --tags") + os.chdir("..") + +def clone_repos(): + com.cmd("rm -fr " + workdir) + com.cmd("mkdir " + workdir) + os.chdir(workdir) + clone("lvgl") + clone("lv_examples") + clone("lv_drivers") + clone("docs") + clone("blog") + + for p in proj_list: + clone(p) + +def cleanup(): + os.chdir("../") + com.cmd("rm -fr " + workdir) + +if __name__ == '__main__': + prepare_type = ['major', 'minor', 'bugfix'] + dev_prepare = 'minor' + +# if(len(sys.argv) != 2): +# print("Missing argument. Usage ./release.py bugfix | minor | major") +# print("Use minor by deafult") +# else: +# dev_prepare = sys.argv[1] + + if not (dev_prepare in prepare_type): + print("Invalid argument. Usage ./release.py bugfix | minor | major") + exit(1) + + clone_repos() + release.make() + for p in proj_list: + proj.make(p, True) + + dev.make(dev_prepare) + #cleanup() diff --git a/scripts/release/proj.py b/scripts/release/proj.py new file mode 100755 index 000000000..db02cd537 --- /dev/null +++ b/scripts/release/proj.py @@ -0,0 +1,64 @@ +#!/usr/bin/env python + +import sys +import os.path +from os import path +import re +import subprocess +import com + + +def make(repo_path, auto_push = False): + os.chdir("./" + repo_path) + com.cmd('git checkout master') + print("Upadte lvgl"); + os.chdir("./lvgl") + com.cmd("git checkout master") + com.cmd("git pull origin --tags") + + out = subprocess.Popen(['git', 'tag', '--sort=-creatordate'], + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT) + stdout,stderr = out.communicate() + + ver_str = stdout.decode("utf-8").split('\n')[0] + release_br = ver_str[1:] #trim "v" + release_br = release_br.split('.')[0] # get the first number + release_br = "release/v" + release_br + + com.cmd("git checkout " + release_br + "; git pull origin " + release_br) + + os.chdir("..") + + com.cmd("cp -f lvgl/lv_conf_template.h lv_conf.h") + com.cmd("sed -i -r 's/#if 0/#if 1/' lv_conf.h") # Enable lv_conf.h + with open("confdef.txt") as f: + for line in f: + (key, val) = line.rstrip().split('\t') + com.define_set("lv_conf.h", str(key), str(val)) + + + if os.path.exists("lv_examples"): + print("Upadte lv_examples"); + com.cmd("cd lv_examples; git co " + release_br + "; git pull origin " + release_br) + + if os.path.exists("lv_drivers"): + print("upadte lv_drivers"); + com.cmd("cd lv_drivers " + release_br + "; git pull origin " + release_br) + + msg = 'Update to ' + ver_str + com.cmd("git add .") + com.cmd('git commit -am "' + msg + '"') + com.cmd("git tag -a " + ver_str + " -m '" + msg + "' " ) + if auto_push: + com.push("origin --tags") + com.push("origin master") + + os.chdir("../") + +if __name__ == '__main__': + if(len(sys.argv) != 2): + print("Missing argument. Usage ./projs_update.py repo_path") + print("E.g. ./projs_update.py ./lv_sim_eclipse_sdl") + else: + make(sys.argv[1], sys.argv[2]) diff --git a/scripts/release/release.py b/scripts/release/release.py new file mode 100755 index 000000000..edcdf79e4 --- /dev/null +++ b/scripts/release/release.py @@ -0,0 +1,173 @@ +#!/usr/bin/env python + +import os.path +from os import path +from datetime import date +import sys +import com +import re + +def update_release_branch(release_br, master_br = "master"): + com.cmd("git checkout " + release_br) + com.cmd("git pull origin " + release_br) + com.cmd("git merge "+ master_br +" -X ours"); + com.push("origin " + release_br); + com.cmd("git checkout master"); + +def lvgl_release(ver): + print("Release lvgl") + + ver_str = com.ver_format(ver) + release_br = "release/v" + str(ver[0]) + + os.chdir("./lvgl") + com.define_set("./lvgl.h", "LVGL_VERSION_INFO", '\"\"') + + # Run some scripts + os.chdir("./scripts") + com.cmd("./code-format.sh") + com.cmd("./lv_conf_checker.py") + com.cmd("doxygen") + os.chdir("../") + + com.update_version(ver) + + #update CHANGLELOG + new_content = "" + f = open("./CHANGELOG.md", "r") + + release_note = "" + note_state = 0 + for i in f.read().splitlines(): + if note_state == 0: + r = re.search(r'^## ' + ver_str, i) + if r: + i = i.replace("planned on ", "") + note_state+=1 + + elif note_state == 1: + r = re.search(r'^## ', i) + if r: + note_state+=1 + else: + release_note += i + '\n' + + new_content += i + '\n' + + f.close() + + f = open("./CHANGELOG.md", "w") + f.write(new_content) + f.close() + + com.cmd('git commit -am "Release ' + ver_str + '"') + + com.cmd('git checkout dev') + com.cmd("git merge master -X ours") + com.cmd("git add .") + com.cmd("git commit -am 'Merge master'", False) + com.push('origin dev') + com.cmd('git checkout master') + com.cmd("git tag -a " + ver_str + " -m 'Release " + ver_str + "' ") + com.push('origin master') + com.push('origin --tags') + + update_release_branch(release_br) + + os.chdir("../") + + return release_note + + +def lv_examples_release(ver): + print("Release lv_examples") + + os.chdir("./lv_examples") + release_br = "release/v" + str(ver[0]) + ver_str = com.ver_format(ver) + + com.update_version(ver) + + com.cmd("sed -i -r 's/LV_VERSION_CHECK\([0-9]+, *[0-9]+, *[0-9]+\)/"+ "LV_VERSION_CHECK(" + str(ver[0]) + ", " + str(ver[1]) + ", " + str(ver[2]) + ")/' lv_examples.h") + + com.cmd('git commit -am "Release ' + ver_str + '"') + com.cmd("git tag -a " + ver_str + " -m 'Release " + ver_str + "' ") + com.push('origin master') + com.push('origin --tags') + + os.chdir("../") + +def lv_drivers_release(ver): + print("Release lv_drivers") + + os.chdir("./lv_drivers") + release_br = "release/v" + str(ver[0]) + ver_str = com.ver_format(ver) + + com.update_version(ver) + + com.cmd('git commit -am "Release ' + ver_str + '"') + com.cmd("git tag -a " + ver_str + " -m 'Release " + ver_str + "' ") + com.push('origin master') + com.push('origin --tags') + + update_release_branch(release_br) + + os.chdir("../") + +def docs_release(ver): + print("Release docs") + + os.chdir("./docs") + release_br = "release/v" + str(ver[0]) + ver_str = com.ver_format(ver) + + com.cmd("git co latest --") + com.cmd("rm -rf xml"); + com.cmd("cp -r ../lvgl/docs/api_doc/xml ."); + com.cmd("git add xml"); + + com.update_version(ver) + + com.cmd('git commit -am "Release ' + ver_str + '"') + com.cmd("git tag -a " + ver_str + " -m 'Release " + ver_str + "' ") + com.push('origin master') + com.push('origin --tags') + + update_release_branch(release_br, "latest") + + os.chdir("../") + +def blog_release(ver, release_note): + + os.chdir("./blog/_posts") + + ver_str = com.ver_format(ver) + + post = "---\nlayout: post\ntitle: " + ver_str + " is released\nauthor: \"kisvegabor\"\ncover: /assets/release_cover.png\n---\n\n" + post += release_note + + today = date.today() + d = today.strftime("%Y-%m-%d") + + f = open(d + "-release_" + ver_str + ".md", "w") + f.write(post) + f.close() + + com.cmd("git add .") + com.cmd("git commit -am 'Add " + ver_str + " release post'") + com.push('origin master') + + os.chdir("../../") + + +def make(): + ver = com.get_lvgl_version("master") + release_note = lvgl_release(ver) + lv_examples_release(ver) + lv_drivers_release(ver) + docs_release(ver) + blog_release(ver, release_note) + +if __name__ == '__main__': + make()