Skip to content
Merged
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
42 changes: 37 additions & 5 deletions cookiecutter/migrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ def migrate_to_ubuntu_slim() -> None:
"""
workflows_dir = Path(".github") / "workflows"
project_type = read_project_type()
github_org = read_cookiecutter_github_org()
include_protolint = project_type == "api"
include_publish_to_pypi = github_org == "frequenz-floss"
if project_type is None:
include_protolint = True
manual_step(
Expand Down Expand Up @@ -125,11 +127,6 @@ def migrate_to_ubuntu_slim() -> None:
"old": " discussions: write\n runs-on: ubuntu-24.04",
"new": " discussions: write\n runs-on: ubuntu-slim",
},
{
"job": "publish-to-pypi",
"old": ' needs: ["create-github-release"]\n runs-on: ubuntu-24.04',
"new": ' needs: ["create-github-release"]\n runs-on: ubuntu-slim',
},
],
"release-notes-check.yml": [
{
Expand Down Expand Up @@ -173,6 +170,19 @@ def migrate_to_ubuntu_slim() -> None:
}
],
}
if include_publish_to_pypi:
migrations["ci.yaml"].append(
{
"job": "publish-to-pypi",
"old": (
' needs: ["create-github-release"]\n runs-on: ubuntu-24.04'
),
"new": (
' needs: ["create-github-release"]\n runs-on: ubuntu-slim'
),
}
)

if include_protolint:
protolint_rule = {
"job": "protolint",
Expand Down Expand Up @@ -517,6 +527,28 @@ def read_project_type() -> str | None:
return project_type


def read_cookiecutter_github_org() -> str | None:
"""Read the cookiecutter GitHub organization from the replay file."""
replay_path = Path(".cookiecutter-replay.json")
if not replay_path.exists():
return None

try:
data = json.loads(replay_path.read_text(encoding="utf-8"))
except (json.JSONDecodeError, OSError):
return None

cookiecutter_data = data.get("cookiecutter")
if not isinstance(cookiecutter_data, dict):
return None

github_org = cookiecutter_data.get("github_org")
if not isinstance(github_org, str):
return None

return github_org


def read_cookiecutter_license() -> str | None:
"""Read the cookiecutter license from the replay file."""
replay_path = Path(".cookiecutter-replay.json")
Expand Down