Skip to content

Commit 88a7fa9

Browse files
author
Jussi Kukkonen
committed
verify_release: Build from git sources only
Make a new (local) git clone to ensure uncommitted files do not affect the build. Signed-off-by: Jussi Kukkonen <[email protected]>
1 parent 10f9fea commit 88a7fa9

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

verify_release

+16-9
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,23 @@ 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)
39-
build_version = None
40-
for filename in os.listdir(build_dir):
41-
prefix, postfix = f"{PYPI_PROJECT}-", ".tar.gz"
42-
if filename.startswith(prefix) and filename.endswith(postfix):
43-
build_version = filename[len(prefix) : -len(postfix)]
44-
assert build_version
45-
return build_version
37+
orig_dir = os.path.dirname(os.path.abspath(__file__))
38+
build_cmd = ["python3", "-m", "build", "--outdir", build_dir, orig_dir]
4639

40+
with TemporaryDirectory() as src_dir:
41+
# fresh git clone: this prevents uncommitted files from affecting build
42+
git_cmd = ["git", "clone", "--quiet", orig_dir, src_dir]
43+
subprocess.run(git_cmd, stdout=subprocess.DEVNULL, check=True)
44+
45+
subprocess.run(build_cmd, stdout=subprocess.DEVNULL, check=True)
46+
build_version = None
47+
for filename in os.listdir(build_dir):
48+
prefix, postfix = f"{PYPI_PROJECT}-", ".tar.gz"
49+
if filename.startswith(prefix) and filename.endswith(postfix):
50+
build_version = filename[len(prefix) : -len(postfix)]
51+
52+
assert build_version
53+
return build_version
4754

4855
def get_git_version() -> str:
4956
"""Return version string from git describe"""

0 commit comments

Comments
 (0)