Skip to content

Commit 8a7243f

Browse files
author
Jussi Kukkonen
authored
Merge pull request #1947 from jku/verify-release-build-isolation
verify_release: Build from git sources only
2 parents 76a4609 + 62580ab commit 8a7243f

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

verify_release

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,22 @@ PYPI_PROJECT = "tuf"
3434

3535
def build(build_dir: str) -> str:
3636
"""Build release locally. Return version as string"""
37-
cmd = ["python3", "-m", "build", "--outdir", build_dir]
38-
subprocess.run(cmd, stdout=subprocess.DEVNULL, check=True)
37+
orig_dir = os.path.dirname(os.path.abspath(__file__))
38+
39+
with TemporaryDirectory() as src_dir:
40+
# fresh git clone: this prevents uncommitted files from affecting build
41+
git_cmd = ["git", "clone", "--quiet", orig_dir, src_dir]
42+
subprocess.run(git_cmd, stdout=subprocess.DEVNULL, check=True)
43+
44+
build_cmd = ["python3", "-m", "build", "--outdir", build_dir, src_dir]
45+
subprocess.run(build_cmd, stdout=subprocess.DEVNULL, check=True)
46+
3947
build_version = None
4048
for filename in os.listdir(build_dir):
4149
prefix, postfix = f"{PYPI_PROJECT}-", ".tar.gz"
4250
if filename.startswith(prefix) and filename.endswith(postfix):
4351
build_version = filename[len(prefix) : -len(postfix)]
52+
4453
assert build_version
4554
return build_version
4655

0 commit comments

Comments
 (0)