X-Git-Url: https://git.madduck.net/etc/vim.git/blobdiff_plain/f3b1a3b9d2fc6de8f0845399cb80d8bdfd6400fd..b542f589a5c4041f54847591104cd51684849f2e:/action/main.py diff --git a/action/main.py b/action/main.py index ff9d411..23c3a65 100644 --- a/action/main.py +++ b/action/main.py @@ -22,12 +22,34 @@ if JUPYTER: extra_deps = "[colorama,jupyter]" else: extra_deps = "[colorama]" -req = f"black{extra_deps}{version_specifier}" +if version_specifier: + req = f"black{extra_deps}{version_specifier}" +else: + describe_name = "" + with open(ACTION_PATH / ".git_archival.txt", encoding="utf-8") as fp: + for line in fp: + if line.startswith("describe-name: "): + describe_name = line[len("describe-name: ") :].rstrip() + break + if not describe_name: + print("::error::Failed to detect action version.", flush=True) + sys.exit(1) + # expected format is one of: + # - 23.1.0 + # - 23.1.0-51-g448bba7 + if describe_name.count("-") < 2: + # the action's commit matches a tag exactly, install exact version from PyPI + req = f"black{extra_deps}=={describe_name}" + else: + # the action's commit does not match any tag, install from the local git repo + req = f".{extra_deps}" +print(f"Installing {req}...", flush=True) pip_proc = run( [str(ENV_BIN / "python"), "-m", "pip", "install", req], stdout=PIPE, stderr=STDOUT, encoding="utf-8", + cwd=ACTION_PATH, ) if pip_proc.returncode: print(pip_proc.stdout)