Skip to content

verify_release: Build from git sources only #1947

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions verify_release
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,22 @@ PYPI_PROJECT = "tuf"

def build(build_dir: str) -> str:
"""Build release locally. Return version as string"""
cmd = ["python3", "-m", "build", "--outdir", build_dir]
subprocess.run(cmd, stdout=subprocess.DEVNULL, check=True)
orig_dir = os.path.dirname(os.path.abspath(__file__))

with TemporaryDirectory() as src_dir:
# fresh git clone: this prevents uncommitted files from affecting build
git_cmd = ["git", "clone", "--quiet", orig_dir, src_dir]
subprocess.run(git_cmd, stdout=subprocess.DEVNULL, check=True)

build_cmd = ["python3", "-m", "build", "--outdir", build_dir, src_dir]
subprocess.run(build_cmd, stdout=subprocess.DEVNULL, check=True)

build_version = None
for filename in os.listdir(build_dir):
prefix, postfix = f"{PYPI_PROJECT}-", ".tar.gz"
if filename.startswith(prefix) and filename.endswith(postfix):
build_version = filename[len(prefix) : -len(postfix)]

assert build_version
return build_version

Expand Down