Skip to content
Merged
Show file tree
Hide file tree
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: 1 addition & 12 deletions .github/workflows/update_backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,7 @@ jobs:
cache: pip

- name: "Install dependencies"
run: |
python -m pip install --upgrade pip
pip install tomlkit
run: python -m pip install --upgrade pip

- name: "Get SymbolicRegression.jl latest version"
id: get-latest
Expand All @@ -36,13 +34,6 @@ jobs:
run: |
python .github/workflows/update_backend_version.py ${{ steps.get-latest.outputs.version }}

- name: "Restore changes if no diff to `pysr/juliapkg.json`"
run: |
if git diff --quiet pysr/juliapkg.json; then
echo "No changes to pysr/juliapkg.json. Restoring changes."
git restore pyproject.toml .release-please-manifest.json
fi

- name: "Create PR if necessary"
id: cpr
uses: peter-evans/create-pull-request@v8
Expand All @@ -56,8 +47,6 @@ jobs:
delete-branch: true
commit-message: "chore: update backend to v${{ steps.get-latest.outputs.version }}"
add-paths: |
.release-please-manifest.json
pyproject.toml
pysr/juliapkg.json

- name: "Trigger CI workflows (backend update PR)"
Expand Down
57 changes: 1 addition & 56 deletions .github/workflows/update_backend_version.py
Original file line number Diff line number Diff line change
@@ -1,65 +1,17 @@
import json
import re
import sys
from pathlib import Path

import tomlkit

new_backend_version = sys.argv[1]

assert not new_backend_version.startswith("v"), "Version should not start with 'v'"

repo_root = Path(__file__).parent / ".." / ".."
pyproject_toml = repo_root / "pyproject.toml"
juliapkg_json = repo_root / "pysr" / "juliapkg.json"
release_please_manifest = repo_root / ".release-please-manifest.json"

with open(pyproject_toml) as toml_file:
pyproject_data = tomlkit.parse(toml_file.read())

with open(juliapkg_json) as f:
juliapkg_data = json.load(f)

with open(release_please_manifest) as f:
release_please_manifest_data = json.load(f)

current_version = pyproject_data["project"]["version"]
parts = current_version.split(".")

if len(parts) < 3:
raise ValueError(
f"Invalid version format: {current_version}. Expected at least 3 components (major.minor.patch)"
)

major, minor = parts[0], parts[1]

patch_match = re.match(r"^(\d+)(.*)$", parts[2])
if not patch_match:
raise ValueError(
f"Could not parse patch version from '{parts[2]}' in version {current_version}. "
f"Expected patch to start with a number (e.g., '0', '1a1', '2rc3')"
)

patch_num_str, patch_suffix = patch_match.groups()
patch_num = int(patch_num_str)

pre_release_match = re.fullmatch(r"(a|b|rc)(\d+)", patch_suffix)
if pre_release_match:
pre_tag, pre_num = pre_release_match.groups()
new_patch = patch_num
new_suffix = f"{pre_tag}{int(pre_num) + 1}"
else:
new_patch = patch_num + 1
new_suffix = patch_suffix

# Add back any additional version components (e.g., "2.0.0.dev1" -> ".dev1")
extra_parts = "." + ".".join(parts[3:]) if len(parts) > 3 else ""
new_version = f"{major}.{minor}.{new_patch}{new_suffix}{extra_parts}"

pyproject_data["project"]["version"] = new_version
release_please_manifest_data["."] = new_version

# Update backend - maintain current format (either "rev" or "version")
# Update backend, maintain current format (either "rev" or "version")
backend_pkg = juliapkg_data["packages"]["SymbolicRegression"]
if "rev" in backend_pkg:
backend_pkg["rev"] = f"v{new_backend_version}"
Expand All @@ -70,13 +22,6 @@
"SymbolicRegression package must have either 'rev' or 'version' field"
)

with open(pyproject_toml, "w") as toml_file:
toml_file.write(tomlkit.dumps(pyproject_data))

with open(juliapkg_json, "w") as f:
json.dump(juliapkg_data, f, indent=4)
f.write("\n")

with open(release_please_manifest, "w") as f:
json.dump(release_please_manifest_data, f, indent=2)
f.write("\n")
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
".": "2.0.0a2"
".": "2.0.0a1"
}
Loading