From ab8200d356a57e1703d95469e0e7a54cbbbac373 Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Thu, 2 Feb 2023 17:48:38 +0100 Subject: [PATCH 1/4] Fix setuptools_scm not working with git archives --- .git_archival.txt | 4 ++++ .gitattributes | 1 + 2 files changed, 5 insertions(+) create mode 100644 .git_archival.txt create mode 100644 .gitattributes diff --git a/.git_archival.txt b/.git_archival.txt new file mode 100644 index 00000000000..8fb235d7045 --- /dev/null +++ b/.git_archival.txt @@ -0,0 +1,4 @@ +node: $Format:%H$ +node-date: $Format:%cI$ +describe-name: $Format:%(describe:tags=true,match=*[0-9]*)$ +ref-names: $Format:%D$ diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000000..00a7b00c94e --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +.git_archival.txt export-subst From e29e12c973d0e294a0a905b1fb4d8f4962bfa408 Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Thu, 2 Feb 2023 18:03:00 +0100 Subject: [PATCH 2/4] Use GH action version when not specified --- action/main.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/action/main.py b/action/main.py index ff9d4112aed..23c3a652194 100644 --- a/action/main.py +++ b/action/main.py @@ -22,12 +22,34 @@ 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) From 9a168472de3144674dd7db3c6b514b7e5f5d5c20 Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Thu, 2 Feb 2023 16:45:24 +0100 Subject: [PATCH 3/4] Empty commit From 77a24a69ff08ff1b5ee28fcc54237fdad8b4d2e1 Mon Sep 17 00:00:00 2001 From: Jakub Kuczys Date: Sun, 12 Feb 2023 13:20:07 +0100 Subject: [PATCH 4/4] Add changelog entry --- CHANGES.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 2071eb3f800..b10cfc9888a 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -42,6 +42,9 @@ +- Update GitHub Action to use the version of Black equivalent to action's version if + version input is not specified (#3543) + ### Documentation