diff --git a/.github/workflows/release_branch_updater.yml b/.github/workflows/release_branch_updater.yml index 403772331..e0a3ab86f 100644 --- a/.github/workflows/release_branch_updater.yml +++ b/.github/workflows/release_branch_updater.yml @@ -3,13 +3,14 @@ name: Port repo release update on: push: branches: + - master - 'release/v*' # on release branches workflow_dispatch: # allow manual triggering # https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#concurrency # Ensure that only one commit will be running tests at a time on each push concurrency: - group: ${{ github.ref }}-${{ github.workflow }} + group: ${{ github.workflow }} cancel-in-progress: true jobs: diff --git a/scripts/release_branch_updater.py b/scripts/release_branch_updater.py index 9731046bc..c9bd062d6 100644 --- a/scripts/release_branch_updater.py +++ b/scripts/release_branch_updater.py @@ -28,8 +28,10 @@ def main(): dry_run = args.dry_run oldest_major = args.oldest_major - lvgl_release_branches = get_release_branches(lvgl_path) + lvgl_release_branches, lvgl_default_branch = get_release_branches(lvgl_path) print(LOG, "LVGL release branches:", ", ".join(fmt_release(br) for br in lvgl_release_branches) or "(none)") + assert lvgl_default_branch is not None + print(LOG, "LVGL default branch:", lvgl_default_branch) if oldest_major is not None: lvgl_release_branches = [br for br in lvgl_release_branches if br[0] >= oldest_major] print(LOG, 'LVGL release branches after "oldest-major" filter:', @@ -47,8 +49,9 @@ def main(): subprocess.check_call(("git", "clone", url, port_clone_tmpdir)) - port_release_branches = get_release_branches(port_clone_tmpdir) + port_release_branches, port_default_branch = get_release_branches(port_clone_tmpdir) print(LOG, "port release branches:", ", ".join(fmt_release(br) for br in port_release_branches) or "(none)") + print(LOG, "port default branch:", port_default_branch if port_default_branch is not None else "(none)") # we want to # 1. create (if necessary) the port's release branch @@ -56,8 +59,16 @@ def main(): # 3. update the lv_conf.h based on the lv_conf.defaults # from oldest to newest release... - for lvgl_branch in lvgl_release_branches: - print(LOG, f"attempting to update release branch {fmt_release(lvgl_branch)} ...") + for lvgl_branch in lvgl_release_branches + [lvgl_default_branch]: + if isinstance(lvgl_branch, tuple): + port_branch = lvgl_branch + print(LOG, f"attempting to update release branch {fmt_release(port_branch)} ...") + else: + port_branch = port_default_branch + if port_branch is None: + print(LOG, "the port does not have a default branch to update. continuing to next.") + continue + print(LOG, f"attempting to update default branch {port_branch} ...") port_does_not_have_the_branch = False port_submodule_was_updated = False @@ -65,12 +76,12 @@ def main(): # if the branch does not exist in the port, create it from # the closest minor of the same major. - if lvgl_branch in port_release_branches: + if port_branch in port_release_branches: print(LOG, "... this port has a matching release branch.") subprocess.check_call(("git", "-C", port_clone_tmpdir, "branch", "--track", - fmt_release(lvgl_branch), - f"origin/{fmt_release(lvgl_branch)}")) - else: + fmt_release(port_branch), + f"origin/{fmt_release(port_branch)}")) + elif port_branch != port_default_branch: print(LOG, "... this port does not have this release branch minor ...") port_does_not_have_the_branch = True @@ -78,8 +89,8 @@ def main(): create_from = next(( br for br in reversed(port_release_branches) # reverse it to get the newest (largest) minor - if br[0] == lvgl_branch[0] # same major - and br[1] < lvgl_branch[1] # smaller minor because exact minor does not exist + if br[0] == port_branch[0] # same major + and br[1] < port_branch[1] # smaller minor because exact minor does not exist ), None) if create_from is None: # there are no branches in the port that are this major @@ -87,18 +98,18 @@ def main(): print(LOG, "... this port has no major from which to create the minor. one must be created manually. continuing to next.") continue - print(LOG, f"... creating the new branch {fmt_release(lvgl_branch)} " + print(LOG, f"... creating the new branch {fmt_release(port_branch)} " f"from {fmt_release(create_from)}") subprocess.check_call(("git", "-C", port_clone_tmpdir, "branch", - fmt_release(lvgl_branch), # new branch name + fmt_release(port_branch), # new branch name fmt_release(create_from))) # start point - port_release_branches.append(lvgl_branch) + port_release_branches.append(port_branch) port_release_branches.sort() # checkout the same release in both LVGL and the port subprocess.check_call(("git", "-C", lvgl_path, "checkout", f"origin/{fmt_release(lvgl_branch)}")) - subprocess.check_call(("git", "-C", port_clone_tmpdir, "checkout", fmt_release(lvgl_branch))) + subprocess.check_call(("git", "-C", port_clone_tmpdir, "checkout", fmt_release(port_branch))) # update the submodule in the port if it exists out = subprocess.check_output(("git", "-C", port_clone_tmpdir, "config", "--file", @@ -181,7 +192,7 @@ def main(): else: subprocess.check_call(("git", "-C", port_clone_tmpdir, "push", *(("-u", "origin") if port_does_not_have_the_branch else ()), - fmt_release(lvgl_branch), + fmt_release(port_branch), )) print(LOG, "the changes were pushed.") else: @@ -205,10 +216,16 @@ def get_release_branches(working_dir): release_versions.sort() - return release_versions + default_branch = None + if "refs/remotes/origin/master" in branches: + default_branch = "master" + elif "refs/remotes/origin/main" in branches: + default_branch = "main" + + return release_versions, default_branch def fmt_release(release_tuple): - return f"release/v{release_tuple[0]}.{release_tuple[1]}" + return f"release/v{release_tuple[0]}.{release_tuple[1]}" if isinstance(release_tuple, tuple) else release_tuple if __name__ == "__main__": main()