From 587c3f2338b3a630075ed8fa4e9f610fe17e1aea Mon Sep 17 00:00:00 2001 From: Jose Garcia Crosta Date: Fri, 26 Apr 2024 10:33:48 -0400 Subject: [PATCH] Delete old script --- .github/workflows/test-release.yml | 8 ++-- scripts/publish-to-crates-io-old.py | 61 ----------------------------- 2 files changed, 4 insertions(+), 65 deletions(-) delete mode 100644 scripts/publish-to-crates-io-old.py diff --git a/.github/workflows/test-release.yml b/.github/workflows/test-release.yml index 03cb3a47..925da5b3 100644 --- a/.github/workflows/test-release.yml +++ b/.github/workflows/test-release.yml @@ -61,22 +61,22 @@ jobs: python -m pip install --upgrade pip pip install requests toml - - name: Publish Scout Audit + - name: Test Scout Audit id: scout-audit if: ${{ needs.filter-paths.outputs.scout-audit == 'true' }} run: python scripts/publish-to-crates-io.py --crate-path apps/cargo-scout-audit --dry-run - - name: Publish Dylint Linting + - name: Test Dylint Linting id: dylint-linting if: ${{ needs.filter-paths.outputs.dylint-linting == 'true' }} run: python scripts/publish-to-crates-io.py --crate-path scout-audit-dylint-linting --dry-run - - name: Publish Clippy Utils + - name: Test Clippy Utils id: clippy-utils if: ${{ needs.filter-paths.outputs.clippy-utils == 'true' }} run: python scripts/publish-to-crates-io.py --crate-path scout-audit-clippy-linting --dry-run - - name: Publish Clippy Config + - name: Test Clippy Config id: clippy-config if: ${{ needs.filter-paths.outputs.clippy-config == 'true' }} run: python scripts/publish-to-crates-io.py --crate-path scout-audit-clippy-config --dry-run diff --git a/scripts/publish-to-crates-io-old.py b/scripts/publish-to-crates-io-old.py deleted file mode 100644 index a169d444..00000000 --- a/scripts/publish-to-crates-io-old.py +++ /dev/null @@ -1,61 +0,0 @@ -from pathlib import Path -import shutil -import subprocess -import tempfile -import time - -def get_package_name(file_path): - with open(file_path, "r") as f: - for line in f: - if line.startswith("name"): - return line.split("=")[1].strip().strip('"') - raise Exception("Could not find package name in Cargo.toml") - -def get_package_version(file_path): - with open(file_path, "r") as f: - for line in f: - if line.startswith("version"): - return line.split("=")[1].strip().strip('"') - raise Exception("Could not find package version in Cargo.toml") - -def is_package_published(package_name, package_version, package_path): - with tempfile.TemporaryDirectory() as tmpdirname: - subprocess.call(["cargo", "init"], cwd=tmpdirname) - if (package_path / "rust-toolchain").exists(): - shutil.copy(package_path / "rust-toolchain", Path(tmpdirname) / "rust-toolchain") - with open(Path(tmpdirname) / "Cargo.toml", "a") as f: - f.write(f'{package_name} = "={package_version}"') - print(f"Checking if {package_name} {package_version} is published...") - try: - subprocess.check_output(["cargo", "check"], cwd=tmpdirname) - return True - except subprocess.CalledProcessError: - return False - except: - raise - -def publish_package(package_path): - subprocess.check_output(["cargo", "publish"], cwd=package_path) - -if __name__ == "__main__": - ROOT_PATH = Path(__file__).parent.parent - CARGO_SCOUT_AUDIT_PATH = ROOT_PATH / "apps" / "cargo-scout-audit" - SCOUT_AUDIT_CLIPPY_UTILS = ROOT_PATH / "scout-audit-clippy-utils" - SCOUT_AUDIT_INTERNAL_PATH = ROOT_PATH / "scout-audit-internal" - SCOUT_AUDIT_DYLINT_LINTING = ROOT_PATH / "scout-audit-dylint-linting" - - packages_paths = [SCOUT_AUDIT_CLIPPY_UTILS, SCOUT_AUDIT_INTERNAL_PATH, CARGO_SCOUT_AUDIT_PATH, SCOUT_AUDIT_DYLINT_LINTING] - - for path in packages_paths: - package_name = get_package_name(path / "Cargo.toml") - package_version = get_package_version(path / "Cargo.toml") - print(f"Publishing {package_name} {package_version}...") - - if not is_package_published(package_name, package_version, path): - publish_package(path) - while not is_package_published(package_name, package_version, path): - print(f"{package_name} {package_version} is not published yet, waiting 10 seconds...") - time.sleep(10) - print(f"{package_name} {package_version} is published") - else: - print(f"{package_name} {package_version} is already published")