rlsbl v0.92.0 /rlsbl.commands.monorepo.sync
On this page

Monorepo sync command and helpers: trigger rewriting, working-directory injection, router workflow generation, and tag prefix configuration.

#rlsbl.commands.monorepo.sync

#rlsbl.commands.monorepo.sync

Monorepo sync command and all sync helpers: trigger rewriting, working-directory injection, router generation.

#parse_ci_workflow

python
def parse_ci_workflow(content)

Parse CI workflow YAML content using round-trip mode (preserves comments, ordering).

Returns the parsed document, or None if the content is empty or has no jobs: key.

#emit_ci_workflow

python
def emit_ci_workflow(doc)

Serialize a parsed workflow document back to YAML string.

Uses round-trip mode to preserve comment annotations and key order from the original parse.

#_rewrite_trigger

python
def _rewrite_trigger(doc)

Replace the on: trigger with workflow_call: in a parsed YAML document.

YAML 1.1 treats bare on as boolean True, so the key may appear as either the string 'on' or the boolean True depending on the parser mode. Round-trip mode preserves the original text, but we check both forms defensively.

#_inject_working_directory

python
def _inject_working_directory(doc, path)

Add defaults.run.working-directory to each job in a parsed YAML document.

Merges with existing defaults.run (e.g. preserving shell) rather than overwriting. Only adds working-directory if it is not already present.

#_rewrite_version_file_inputs

python
def _rewrite_version_file_inputs(doc, project_path)

Prefix version-file values with project path in setup actions.

Actions like actions/setup-go resolve go-version-file relative to the repo root, not working-directory. When a workflow is copied into a monorepo sub-project we must adjust these inputs so the runner can still find the file.

Known inputs: go-version-file, python-version-file, node-version-file.

#_inject_packages_dir

python
def _inject_packages_dir(doc, project_path)

Add packages-dir to PyPI publish steps.

When working-directory is set, uv build creates artifacts in {project_path}/dist/ but the publish action looks for dist/ at the repo root. We inject packages-dir so it finds the right directory.

#_strip_uv_no_sources

python
def _strip_uv_no_sources(doc)

Remove UV_NO_SOURCES from workflow-level env block (defense-in-depth for monorepo).

#_generate_router

python
def _generate_router(projects)

Generate ci-router.yml content from project list.

Builds the router as a structured dict and serializes with emit_ci_workflow for consistent YAML output.

#_get_monorepo_tag_prefix

python
def _get_monorepo_tag_prefix(project, root, releasables=None)

Return the tag prefix for a monorepo project's publish router condition.

When releasables are provided and the project belongs to a releasable (releasable = "X"), the prefix is derived from the releasable's tag_format (e.g. "{name}@v{version}" -> "X@v").

Otherwise falls back to the target's monorepo_tag_glob (glob minus trailing *). For Go projects this yields go/v, for others name@v.

#_build_project_template_vars

python
def _build_project_template_vars(project_dir, root)

Build a template vars dict for a project, with both namespaced and un-namespaced keys.

Detects the project's targets, calls each target's template_vars(), and returns a merged dict where each target's vars appear under both their bare names and {target_name}.{key} namespaced names. This allows process_template to resolve patterns like {{pypi.minRequiredPython}} in workflow comments.

#scaffold_releasable_dirs

python
def scaffold_releasable_dirs(workspace_root)

Create the directory structure for each releasable in explicit mode.

In explicit mode (when [[releasables]] exists in workspace.toml), each releasable gets:

  • .rlsbl-monorepo/releasables/{name}/version (user-owned, never overwritten)
  • .rlsbl-monorepo/releasables/{name}/changes/unreleased.jsonl (user-owned)

Hook scripts are no longer scaffolded here -- hooks are config-driven (see hooks key in config.json). Version and unreleased.jsonl are user-owned: created once, never overwritten.

Args:

  • workspace_root: path to the monorepo root.

Returns:

  • A list of file paths that were created or updated (for commit tracking).