Skip to content

Commit 38ed8ca

Browse files
committed
Apply sha256 on the root directory of the layout
1 parent 8f8f48f commit 38ed8ca

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

scripts/release/release-layout.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ layout:
2020
- file: docs/user_manual.md
2121
checksums.txt:
2222
- shell: |
23-
sha256sum ./* > checksums.txt
23+
sha256sum ${{ layout.root }}/* > checksums.txt

scripts/release/update-release-assets.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from __future__ import annotations # This enables postponed evaluation of type annotations. Required for typing.TYPE_CHECKING. See https://peps.python.org/pep-0563/
2-
from typing import TYPE_CHECKING, List, Union, cast, Dict, Any
2+
from typing import TYPE_CHECKING, List, Union, cast, Dict, Any, TypeVar, Callable, Sequence
33
import shutil
44
from tempfile import TemporaryDirectory
55
import subprocess
@@ -124,7 +124,11 @@ def make(self, directory: Path, workflow_runs: List[WorkflowRun.WorkflowRun]) ->
124124
elif action_type == "workflow-artifact":
125125
actions.append(WorkflowArtifactAction(workflow_runs, **cast(Dict[str, Any], action_args)))
126126
elif action_type == "shell":
127-
actions.append(ShellAction(action_args))
127+
modifiers : List[Callable[[str], str]] = [
128+
lambda cmd: re.sub(pattern=r"\${{\s*coding-standards\.root\s*}}", repl=str(root_path), string=cmd),
129+
lambda cmd: re.sub(pattern=r"\${{\s*layout\.root\s*}}", repl=str(directory), string=cmd)
130+
]
131+
actions.append(ShellAction(action_args, modifiers=modifiers))
128132
elif action_type == "file":
129133
actions.append(FileAction(action_args))
130134
else:
@@ -178,12 +182,24 @@ def run(self) -> List[Path]:
178182
return list(map(Path, Path(self.temp_workdir.name).glob("**/*")))
179183

180184
class ShellAction():
181-
def __init__(self, command: str) -> None:
185+
def __init__(self, command: str, **kwargs: Any) -> None:
182186
self.command = command.strip()
183187
self.temp_workdir = TemporaryDirectory()
188+
self.options = kwargs
189+
190+
def _rewrite_command(self) -> str:
191+
E = TypeVar("E")
192+
R = TypeVar("R")
193+
def lfold(fn: Callable[[R, E], R], lst: Sequence[E], init: R) -> R:
194+
return lfold(fn, lst[1:], fn(init, lst[0])) if lst else init
195+
if 'modifiers' in self.options:
196+
return lfold(lambda acc, x: x(acc), self.options['modifiers'], self.command)
197+
else:
198+
return self.command
184199

185200
def run(self) -> List[Path]:
186-
concrete_command = re.sub(pattern=r"\${{\s*coding-standards\.root\s*}}", repl=str(root_path), string=self.command)
201+
#concrete_command = re.sub(pattern=r"\${{\s*coding-standards\.root\s*}}", repl=str(root_path), string=self.command)
202+
concrete_command = self._rewrite_command()
187203
subprocess.run(concrete_command, cwd=self.temp_workdir.name, check=True, shell=True)
188204
return list(map(Path, Path(self.temp_workdir.name).glob("**/*")))
189205

0 commit comments

Comments
 (0)