def stage_deb(repo: mzbuild.Repository, package: str, version: str) -> None: """Stage a Debian package on Bintray. Note that this function does not cause anything to become public; a step to publish the files will be run in the deploy job. """ print(f"Staging deb {package} {version}") # Extract the materialized binary from the Docker image. This avoids # an expensive rebuild if we're using a cached image. ci_util.acquire_materialized( repo, repo.rd.xcargo_target_dir() / "release" / "materialized") # Build the Debian package. deb_path = repo.rd.xcargo_target_dir() / "debian" / "materialized.deb" spawn.runv( [ repo.rd.xcargo(), "deb", f"--variant={package}", "--no-build", "--no-strip", "--deb-version", version, "-p", "materialized", "-o", deb_path, ], cwd=repo.root, ) deb_size = deb_path.stat().st_size bt = bintray.Client("materialize", user="******", api_key=os.environ["BINTRAY_API_KEY"]) package = bt.repo("apt").package(package) try: print("Creating Bintray version...") commit_hash = git.rev_parse("HEAD") package.create_version(version, desc="git main", vcs_tag=commit_hash) except bintray.VersionAlreadyExistsError: # Ignore for idempotency. Bintray won't allow us to overwite an existing # .deb below with a file whose checksum doesn't match, so this is safe. pass print(f"Uploading Debian package ({humanize.naturalsize(deb_size)})...") package.debian_upload( version, path=f"/{version}/materialized-{commit_hash}.deb", data=open(deb_path, "rb"), distributions=["generic"], components=["main"], architectures=["amd64"], )
def main() -> None: pc = ( bintray.Client( "materialize", user="******", api_key=os.environ["BINTRAY_API_KEY"] ) .repo("apt") .package("materialized-unstable") ) old_versions = get_old_versions(pc) print(f"Will delete {len(old_versions)} old versions") for v in old_versions: print(f"Deleting version {v}") pc.delete_version(v)
def publish_deb(package: str, version: str) -> None: print(f"{package} v{version}") bt = bintray.Client("materialize", user="******", api_key=os.environ["BINTRAY_API_KEY"]) bt.repo("apt").package(package).publish_uploads(version)
def stage_deb(repo: mzbuild.Repository, package: str, version: str) -> None: """Stage a Debian package on Bintray. Note that this function does not cause anything to become public; a step to publish the files will be run in the deploy job. """ print(f"Staging deb {package} {version}") # Extract the materialized binary from the Docker image. This avoids # an expensive rebuild if we're using a cached image. ci_util.acquire_materialized( repo, repo.rd.xcargo_target_dir() / "release" / "materialized") # Build the Debian package. deb_path = repo.rd.xcargo_target_dir() / "debian" / "materialized.deb" spawn.runv( [ repo.rd.xcargo(), "deb", f"--variant={package}", "--no-build", "--no-strip", "--deb-version", version, "-p", "materialized", "-o", deb_path, ], cwd=repo.root, ) deb_size = deb_path.stat().st_size bt = bintray.Client("materialize", user="******", api_key=os.environ["BINTRAY_API_KEY"]) package = bt.repo("apt").package(package) try: print("Creating Bintray version...") commit_hash = git.rev_parse("HEAD") package.create_version(version, desc="git main", vcs_tag=commit_hash) except bintray.VersionAlreadyExistsError: # Ignore for idempotency. pass try: print( f"Uploading Debian package ({humanize.naturalsize(deb_size)})...") package.debian_upload( version, path=f"/{version}/materialized-{commit_hash}.deb", data=open(deb_path, "rb"), distributions=["generic"], components=["main"], architectures=["amd64"], ) except bintray.DebAlreadyExistsError: # Ideally `cargo deb` would produce identical output for identical input # to give us idempotency for free, since Bintray won't produce a # DebAlreadyExistsError if you upload the identical .deb file twice. But # it doesn't, so instead we just assume the .deb that's already uploaded # is functionally equivalent to the one we just built. print( "Debian package already exists; assuming it is valid and skipping upload" )