From 3dee741bac7a58e664cc34d7af2fe4024977d96c Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 2 Jan 2023 09:01:21 +0100 Subject: [PATCH] litex_setup.py: Add --release argument to create a LiteX release with a specific tag. --- litex_setup.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/litex_setup.py b/litex_setup.py index ccc12c4c2..0923d475d 100755 --- a/litex_setup.py +++ b/litex_setup.py @@ -197,6 +197,11 @@ def git_checkout(sha1=None, tag=None): sha1_tag = subprocess.check_output(sha1_tag_cmd).decode("UTF-8")[:-1] os.system(f"git checkout {sha1_tag}") +def git_tag(tag=None): + assert tag is not None + os.system(f"git tag {tag}") + os.system(f"git push --tags") + # Git repositories initialization ------------------------------------------------------------------ def litex_setup_init_repos(config="standard", tag=None, dev_mode=False): @@ -309,6 +314,23 @@ def litex_setup_freeze_repos(config="standard"): r += "}\n" print(r) +# Git repositories release ------------------------------------------------------------------------- + +def litex_setup_release_repos(tag): + print_status(f"Making release {tag}...", underline=True) + confirm = input("Please confirm by pressing Y:") + if confirm.upper() == "Y": + for name in install_configs["full"]: + if name in ["migen"]: + continue + repo = git_repos[name] + os.chdir(os.path.join(current_path, name)) + # Tag Repo. + print_status(f"Tagging {name} Git repository as {tag}...") + git_tag(tag=tag) + else: + print_status(f"Not confirmed, exiting.") + # GCC toolchains install --------------------------------------------------------------------------- # RISC-V toolchain. @@ -389,13 +411,14 @@ def main(): parser.add_argument("--user", action="store_true", help="Install in User-Mode.") parser.add_argument("--config", default="standard", help="Install config (minimal, standard, full).") parser.add_argument("--tag", default=None, help="Use version from release tag.") - parser.add_argument("--freeze", action="store_true", help="Freeze and display current config.") # GCC toolchains. parser.add_argument("--gcc", default=None, help="Install GCC Toolchain (riscv, powerpc or openrisc).") # Development mode. - parser.add_argument("--dev", action="store_true", help="Development-Mode (no Auto-Update of litex_setup.py / Switch to git@github.com URLs).") + parser.add_argument("--dev", action="store_true", help="Development-Mode (no Auto-Update of litex_setup.py / Switch to git@github.com URLs).") + parser.add_argument("--freeze", action="store_true", help="Freeze and display current config.") + parser.add_argument("--release", default=None, help="Make release.") # Retro-compatibility. parser.add_argument("compat_args", nargs="*", help="Retro-Compatibility arguments (init, update, install or gcc).") @@ -430,6 +453,10 @@ def main(): if args.freeze: litex_setup_freeze_repos(config=args.config) + # Release. + if args.release: + litex_setup_release_repos(tag=args.release) + # GCC. os.chdir(os.path.join(current_path)) if args.gcc == "riscv":