Skip to content

sow publish

Deliver the current Generation to a filesystem or R2 target in an order that keeps clients working, with resume and abort.

sow publish delivers the current Generation to a target configured under targets: in sow.yml: a directory behind a web server, or an R2 bucket. It sends only what changed since the target’s last publication, in an order that never leaves an index pointing at a file that is not there yet, then reads the result back through the public URL and records a checkpoint. Old files stay on the target until client caches have expired, and an interrupted run resumes where it stopped. Use it for every update to a configured target; to copy a repository to an isolated host instead, see Serve and Publish Repositories.

Synopsis

sow publish TARGET [--abort | --rebind] [-C|--workdir DIR] [-T|--timeout DUR | -N|--no-wait] [--json] [--passfile PATH]

TARGET names a configured filesystem or r2 target. The target already names its repository, so publish takes no -r.

Flag Meaning Default
--abort Abandon an interrupted attempt that has not reached commit intent false
--rebind Accept a changed target name, public_endpoint, or max_cache_ttl, then continue false
-C, --workdir DIR Workspace discovery start directory current directory
-T, --timeout DUR Maximum lock wait; 0 waits indefinitely 0
-N, --no-wait Fail immediately when the lock is held false
--passfile PATH Signing password file, needed only if SOW must first recover an interrupted local operation (Password files) —
--json Output JSON false

--abort and --rebind are mutually exclusive.

Before you publish

  1. Configure the target under targets: in sow.yml; see Publication targets. For a filesystem target, create the endpoint directory first.
  2. Make public_endpoint serve the published files (a web server root or bucket access), because SOW verifies every publication through it.
  3. Run sow build and sow check. publish always sends the latest completed Generation, so a dirty repository publishes its last build without the unbuilt changes.

Publication protocol

Clients find everything through the entry points (repomd.xml, InRelease, Release), so SOW changes those last. Each run:

  1. Verifies the source. Local files must match the manifest of the completed Generation.
  2. Uploads packages. New packages reach the target before any index lists them. A package path is immutable there: SOW never replaces it with different bytes.
  3. Uploads immutable metadata. Content-addressed files such as …-primary.xml.gz and APT by-hash indexes get new names, so clients still reading the old entry points see no change.
  4. Records commit intent. From this point the attempt can only roll forward.
  5. Replaces the entry points, one view at a time, each signature before the index it signs. A client that refreshes now sees the new Generation.
  6. Verifies and checkpoints. SOW reads the changed files back through public_endpoint, records the target’s new checkpoint, and starts the cache-grace period for superseded files.

While step 5 runs, different views can briefly serve indexes from different builds, and a detached signature changes in a separate write from its index, so a client may need to retry one refresh. The design record Publication & Recovery gives the per-format order.

sow publish local
published demo generation=00000000000000000005 to local (filesystem): phase=grace objects=14
sow publish local
publication demo generation=00000000000000000005 to local is already current (noop)

objects counts the files the target now holds. phase=grace means the checkpoint is recorded and the files this Generation no longer needs are in their grace period: clients and CDNs may still hold the old entry points for up to max_cache_ttl, and those point at the old files. After grace expires, sow gc TARGET can delete eligible files on a filesystem target. R2 reports candidates by default and requires --delete to remove them. Running publish again with nothing new to send is a no-op.

Resume or abandon an attempt

SOW saves each attempt’s plan and progress. If publish stops on a network error, Ctrl-C, or a crash, fix the cause and run the same command again. The resumed attempt follows its saved plan, so it finishes the Generation it started with even if you have built since; run publish once more to send the newer Generation.

Saved state What to do
Before commit intent Rerun to resume, or run sow publish TARGET --abort to abandon the attempt
After commit intent Rerun to finish; --abort is refused because entry points may already have changed
Checkpoint recorded Rerun to finish the remaining bookkeeping; a current target is a no-op
Conflicting remote file Inspect the named file and the target configuration before retrying

--abort reconciles what the attempt already uploaded and records those objects as abandoned so a later attempt can reuse matching bytes. It deletes nothing on the target; for a filesystem target it removes only private staging files. Without an attempt in progress, --abort exits 6.

Change target settings

The first publication binds the target to its repository and storage location. If you later change the target’s name, public_endpoint, or max_cache_ttl in sow.yml, publish stops with exit 1 until you confirm the change:

sow publish local
bind publication target "local": state object conflicts with existing identity: publication target "local" is already bound with different mutable configuration; rerun publish with --rebind after operator review

Review the change, then rerun with --rebind, using the new name if you renamed the target. SOW records the new settings and continues publishing:

sow publish local --rebind
May change with --rebind Immutable; configure a new target
target name Repository identity
public_endpoint provider, storage endpoint, or region
max_cache_ttl bucket or prefix
  • GC uses the later of the recorded deadline and the checkpoint’s publication time plus the current max_cache_ttl. Raising the TTL can extend protection for an earlier publication. Lowering it preserves the recorded minimum.
  • Finish an interrupted sow gc TARGET before changing max_cache_ttl, and finish an active conditional delete before changing public_endpoint.
  • A target that was never published has nothing to rebind; publish it once without --rebind.

Removing a published view

While a target is configured, SOW refuses any local change that would withdraw an entry point that target has published: a whole Dist, an RPM architecture view, or a signature file. Its clients would otherwise lose an index they use. build, dist rm, and similar commands name the file and exit 6:

sow dist rm el8
operation rejected: managed: operation rejected: mutation would withdraw published pointer "dists/el8/aarch64/repodata/repomd.xml" from configured target "local"; retire or move that target binding/prefix before removing the view, architecture, or signing companion

To remove the view anyway, retire the target first:

  1. Stop publishing to the target and remove its entry from targets: in sow.yml.
  2. Run sow config check.
  3. Remove the view locally, for example with sow dist rm el8.

The old remote files and the publication history stay untouched. To publish the reduced repository, configure a new target with a different storage prefix and move clients to it.

Details

Public visibility checks

Before recording a checkpoint, SOW downloads the changed files and affected entry points through public_endpoint and checks their content. Filesystem targets accept a file:// or HTTP(S) public_endpoint; R2 targets require HTTP(S).

Over HTTP(S), SOW uses ordinary GET requests and follows CDN redirects (up to 10). It refuses a redirect from HTTPS to HTTP, a redirect to a loopback, link-local, or unspecified address (checked again on the address actually connected), and a cross-origin redirect through an HTTP proxy; in that last case, configure the final public URL or reach that host without a proxy. A CDN may still serve a cached copy, so SOW retries stale or missing content for up to max_cache_ttl. Harmless foreign files at the target root outside pool/ and dists/ are ignored.

R2 inventory

Each R2 publication lists the target prefix. An object whose path, size, and ETag match a known immutable object reuses its recorded SHA-256; other objects are checked with HEAD requests, up to eight at a time per listing page. Upload progress resets the idle timeout, so a long upload that is still moving data does not time out.

Filesystem target paths

SOW rejects a filesystem target that overlaps the repository or the private .sow/ directory. It checks only the selected target’s prospective path, so sibling targets that share a parent directory, such as /srv/www/pgsql and /srv/www/pigsty, do not block each other.

Changed content and conflicts

A published package URL stands for fixed content. To ship changed bytes, use a new package version and filename. If a remote file differs from what the attempt recorded, publish stops and names it; see Troubleshooting.

Other preconditions

  • publish first finishes any interrupted local operation in the repository. If that recovery must re-sign metadata, pass --passfile; publishing an existing Generation signs nothing.
  • If an earlier sow gc TARGET stopped with a report in progress, publish exits 5 and asks you to resume that GC first.
  • A repository that was never built, or that is in the middle of a layout migration, cannot be published (exit 5).

Exit behavior

Code Trigger
0 Publication completed, or the target was already current
1 Filesystem, provider, network, or verification failure, or a target binding conflict (including a change that needs --rebind)
2 Usage error, workspace discovery error, or invalid sow.yml
4 Repository write lock unavailable
5 Source is not deliverable, recovery evidence is inconsistent, or an unfinished target GC must be resumed first
6 Target is missing or unsafe, --abort has no eligible attempt, or another safety precondition rejects the request

See also

Table reader