Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix: resolve merge conflicts with main in check_version_has_incremented.py

Devin AI7ebe27962a27
diff --cc .github/scripts/check_version_has_incremented.py
index 7c4f4a21e,129a0a3ff..5b959a43f
--- a/.github/scripts/check_version_has_incremented.py
+++ b/.github/scripts/check_version_has_incremented.py
@@@ -82,25 -91,73 +91,80 @@@ def get_maven_central_version(package_n
return version_match.group(1).strip()
return "0.0.0"
+ def get_csproj_version(file_path: str) -> str:
+ """Extract version string from .csproj file."""
+ csproj_file = Path(file_path).read_text()
+ version_match = re.search(r'<Version>(.*?)</Version>', csproj_file)
+ if version_match:
+ return version_match.group(1).strip()
+ raise RuntimeError("Unable to find version string in .csproj file.")
+
+ def get_nuget_version(package_name: str) -> str:
+ """Get latest version of .NET package from NuGet."""
+ url = f"https://api.nuget.org/v3-flatcontainer/{package_name.lower()}/index.json"
+ response = requests.get(url)
+ if response.status_code == 404:
+ return "0.0.0"
+ response.raise_for_status()
+ versions = response.json().get('versions', [])
+ if versions:
+ return versions[-1].strip()
+ return "0.0.0"
+
+ def get_php_version(file_path: str) -> str:
+ """Extract version string from PHP Version.php file."""
+ version_file = Path(file_path).read_text()
+ version_match = re.search(r"SDK_VERSION\s*=\s*['\"]([^'\"]*)['\"]", version_file)
+ if version_match:
+ return version_match.group(1).strip()
+ raise RuntimeError("Unable to find SDK_VERSION string in Version.php.")
+
+ def get_packagist_version(package_name: str) -> str:
+ """Get latest version of PHP package from Packagist. package_name should be vendor/package."""
+ url = f"https://packagist.org/packages/{package_name}.json"
+ response = requests.get(url)
+ if response.status_code == 404:
+ return "0.0.0"
+ response.raise_for_status()
+ data = response.json()
+ package_data = data.get("package", {})
+ versions = package_data.get("versions", {})
+ # Filter out dev versions and find highest stable version
+ stable_versions = []
+ for v in versions:
+ normalized = v.lstrip("v")
+ if "dev" in v or not re.match(r"^\d", normalized):
+ continue
+ try:
+ parsed = parse_version(normalized)
+ except Exception:
+ continue
+ if not parsed.is_prerelease:
+ stable_versions.append(normalized)
+ if not stable_versions:
+ return "0.0.0"
+ stable_versions.sort(key=lambda x: parse_version(x), reverse=True)
+ return stable_versions[0]
+
-# def get_rust_version(file_path: str) -> str:
-# """Extract version string from Cargo.toml."""
-# cargo_toml = toml.load(file_path)
-# if 'package' in cargo_toml and 'version' in cargo_toml['package']:
-# return cargo_toml['package']['version'].strip()
-# raise RuntimeError("Unable to find version string in Cargo.toml.")
-
-# def get_crates_version(package_name: str) -> str:
-# """Get latest version of Rust package from crates.io."""
-# response = requests.get(f"https://crates.io/api/v1/crates/{package_name}")
-# version = response.json()['crate']['newest_version']
-# return version.strip()
+def get_rust_version(file_path: str) -> str:
+ """Extract version string from Cargo.toml."""
+ import toml
+ cargo_toml = toml.load(file_path)
+ if 'package' in cargo_toml and 'version' in cargo_toml['package']:
+ return cargo_toml['package']['version'].strip()
+ raise RuntimeError("Unable to find version string in Cargo.toml.")
+
+def get_crates_version(package_name: str) -> str:
+ """Get latest version of Rust package from crates.io."""
+ response = requests.get(
+ f"https://crates.io/api/v1/crates/{package_name}",
+ headers={"User-Agent": "firecrawl-version-check"}
+ )
+ if response.status_code == 404:
+ return "0.0.0"
+ response.raise_for_status()
+ version = response.json()['crate']['newest_version']
+ return version.strip()
def is_version_incremented(local_version: str, published_version: str) -> bool:
"""Compare local and published versions."""
@@@ -128,14 -185,27 +192,27 @@@ if __name__ == "__main__"
current_version = get_gradle_version(os.path.join(package_path, 'build.gradle.kts'))
# Get published version from Maven Central
published_version = get_maven_central_version(package_name)
+ elif package_type == "dotnet":
+ # Get current version from .csproj file — look for any .csproj in the directory
+ csproj_files = list(Path(package_path).glob('*.csproj'))
+ if not csproj_files:
+ raise RuntimeError(f"No .csproj file found in {package_path}")
+ current_version = get_csproj_version(str(csproj_files[0]))
+ # Get published version from NuGet
+ published_version = get_nuget_version(package_name)
+ elif package_type == "php":
+ # Get current version from src/Version.php
+ current_version = get_php_version(os.path.join(package_path, 'src', 'Version.php'))
+ # Get published version from Packagist
+ published_version = get_packagist_version(package_name)
- # if package_type == "rust":
- # # Get current version from Cargo.toml
- # current_version = get_rust_version(os.path.join(package_path, 'Cargo.toml'))
- # # Get published version from crates.io
- # published_version = get_crates_version(package_name)
+ elif package_type == "rust":
+ # Get current version from Cargo.toml
+ current_version = get_rust_version(os.path.join(package_path, 'Cargo.toml'))
+ # Get published version from crates.io
+ published_version = get_crates_version(package_name)
else:
- raise ValueError("Invalid package type. Use 'python', 'js', 'java', or 'rust'.")
- raise ValueError("Invalid package type. Use 'python', 'js', 'java', 'dotnet', or 'php'.")
++ raise ValueError("Invalid package type. Use 'python', 'js', 'java', 'rust', 'dotnet', or 'php'.")
# Print versions for debugging
# print(f"Local version: {current_version}")