rlsbl v0.40.1 /rlsbl.commands.monorepo.publish_inline
On this page

Inline publish logic for monorepo projects: GitHub Actions workflow parsing, job extraction, trigger rewriting, and YAML emission.

#rlsbl.commands.monorepo.publish_inline

#rlsbl.commands.monorepo.publish_inline

Inline publish logic for monorepo projects: workflow parsing and YAML emission.

#parse_publish_workflow

python
def parse_publish_workflow(path: str) -> dict

Parse a GitHub Actions publish workflow file.

Reads the YAML file at path, validates it has a jobs: key, and returns a dict with the top-level keys that matter for inline publish generation.

Returns a dict with keys: jobs -- the jobs mapping from the workflow permissions -- workflow-level permissions mapping, or None env -- workflow-level env mapping, or None name -- workflow name string, or None

#_literal_str_representer

python
def _literal_str_representer(representer, data)

Represent multi-line strings with | literal block style.

#emit_workflow

python
def emit_workflow(workflow_dict: dict) -> str

Emit a workflow dict as a YAML string.

Uses literal block style (|) for multi-line strings and preserves key order. The custom representer is registered on a private Dumper subclass so the global yaml state is never modified.

#prefix_jobs

python
def prefix_jobs(project_name: str, jobs: dict) -> dict

Prefix every job key with {project_name}- and rewrite needs: references.

Returns a new dict; the original jobs is not mutated.

#inject_job_metadata

python
def inject_job_metadata(jobs: dict, tag_prefix: str, working_dir: str) -> dict

Add if: condition and defaults.run.working-directory to every job.

Returns a new dict; the original jobs is not mutated.

#rewrite_action_paths

python
def rewrite_action_paths(jobs: dict, project_path: str) -> dict

Rewrite action inputs that contain file paths so they are relative to project_path.

Handles:

  • pypa/gh-action-pypi-publish: sets with.packages-dir to {project_path}/dist/
  • actions/setup-{go,python,node}: prefixes version-file paths with project_path

Returns a new dict; the original jobs is not mutated.

#resolve_permissions

python
def resolve_permissions(jobs: dict, workflow_permissions: dict | None) -> dict

Push workflow-level permissions down to jobs that lack their own.

  • Jobs with an explicit permissions: key keep it unchanged.
  • Jobs without permissions: inherit workflow_permissions (if non-None).
  • If workflow_permissions is None and the job has no permissions, nothing is added.

Returns a new dict; the original jobs is not mutated.

#transform_project_jobs

python
def transform_project_jobs(project_name: str, project_path: str, tag_prefix: str, workflow_path: str) -> dict

Parse a sub-project's publish workflow and transform its jobs for the monorepo router.

Applies all transforms in the correct order:

  1. resolve_permissions (before prefixing — references original job structure)
  2. rewrite_action_paths
  3. inject_job_metadata
  4. prefix_jobs (last — changes keys)

Returns a dict of transformed jobs ready for merging into the root workflow.

#generate_inline_publish_router

python
def generate_inline_publish_router(projects_with_publish: list, root: str) -> str

Generate a monorepo publish router with all sub-project jobs inlined.

Instead of calling per-project reusable workflows via workflow_call, this inlines every sub-project's publish jobs directly into a single publish.yml. Each job gets an if: startsWith(...) condition so only the relevant project's jobs run on a given release.

Returns the complete YAML string, ready to write to disk.

#compute_publish_hashes

python
def compute_publish_hashes(projects: list, root: str) -> dict

Compute SHA256 hashes of each project's publish workflow.

Returns a dict mapping project name to the hex digest of its publish.yml content, or None if the project has no publish workflow.

#load_publish_cache

python
def load_publish_cache(monorepo_dir: str) -> dict | None

Load the publish hash cache from monorepo_dir.

Returns the parsed dict, or None if the cache file does not exist or contains invalid JSON.

#save_publish_cache

python
def save_publish_cache(monorepo_dir: str, hashes: dict) -> str

Write the publish hash cache to monorepo_dir.

Returns the absolute path to the written cache file.

#should_regenerate_router

python
def should_regenerate_router(cached: dict | None, current: dict, router_path: str) -> bool

Decide whether the publish router needs regeneration.

Returns False (skip) only when cached matches current exactly AND router_path exists on disk. Any mismatch -- missing cache, changed hash, added/removed project, missing router file -- returns True.