pyssg is pre-1.0 and under active development - APIs, config, and themes may change.
pyssg.deploy.state

1 min read

pyssg.deploy.state

Persistent last-deploy state under .pyssg-cache/deploy/<target>.json.

The pipeline writes one small JSON file per target after every successful deploy; the next run reads it back to answer "is the current output identical to what we last pushed?". The file is intentionally human-readable and stable: the user can inspect it, cat it, or delete it to force a redeploy.

This module is stdlib-only. The on-disk format is a tiny dict so we can add fields later without breaking older entries; unknown keys are tolerated on read.

class DeployRecord

A snapshot of the most recent successful deploy for one target.

hash is the output-tree hash at the moment of upload; deployment_id and url are whatever the target returned. timestamp is an ISO-8601 UTC string captured by the pipeline (the pipeline owns clock access, so this module stays pure: callers pass the value in).

read_record(site_dir: Path, target_name: str) -> DeployRecord | None

Return the last-deploy record for target_name or None if absent.

Returns None (rather than raising) on a missing or unreadable file: the caller treats a missing record as "never deployed", which is the same user-visible behavior, and a corrupted file would otherwise block any further deploy with no useful recovery path beyond deleting the cache.

write_record(site_dir: Path, record: DeployRecord) -> None

Persist record for record.target under the cache directory.

The parent directories are created on demand. The JSON is sorted and pretty-printed so diffs (e.g. when the cache is committed by accident) stay minimal and reviewable.