Skip to content

Commit

Permalink
Merge pull request #476 from bgurney-rh/artifact-git-archive
Browse files Browse the repository at this point in the history
make_source_tarball: use git archive
  • Loading branch information
bgurney-rh authored Sep 21, 2023
2 parents 0638145 + 340686e commit 22e5c71
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions release_management/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# isort: STDLIB
import os
import subprocess
import tarfile
import tomllib
from datetime import datetime
from getpass import getpass
Expand Down Expand Up @@ -309,17 +308,16 @@ def make_source_tarball(package_name, release_version, output_dir):

output_file = os.path.join(output_dir, f"{prefix}.tar.gz")

with tarfile.open(output_file, "w:gz") as tar:
for root, _, files in os.walk("."):
for filename in files:
name = os.path.normpath(os.path.join(root, filename))
if name.startswith(".git"):
continue
tar.add(
name,
arcname=os.path.normpath(os.path.join(prefix, name)),
recursive=False,
)
archive_cmd = [
"git",
"archive",
"--format=tar.gz",
f"--output={output_file}",
f"--prefix={prefix}/",
"HEAD",
]

subprocess.run(archive_cmd, check=True)

return output_file

Expand Down

0 comments on commit 22e5c71

Please sign in to comment.