Skip to content

Commit 692fa2b

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

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

verify_release

+11-3
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,25 @@ 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

47-
4856
def get_git_version() -> str:
4957
"""Return version string from git describe"""
5058
cmd = ["git", "describe"]

0 commit comments

Comments
 (0)