# Publishing source to GitHub

1. **dev** Every commit, by `git commit` in the main checkout or a worktree Development instance, port 18200
2. `scripts/publishing/publish-github.sh -m`, about once a day
3. **main** One squashed commit per sync, its own history GitHub; `latest.json` follows it, nobody is told
4. `scripts/publishing/publish-github.sh --tag vX.Y.Z`, now and then
5. **Release** `channel.json` and a GitHub Release; X.Y.0 adds installers built by the Release workflow Stable App, port 18100, updates to it in-app

GitHub carries `main` and nothing else. Its history never merges with `dev`, and nothing pulls GitHub's `main` back. Users hear of a version only through a release. The stable App on this machine follows releases, as every user's does.

## Branches

| Line | Role |
| --- | --- |
| `dev` | Takes every commit, from the main checkout or a worktree. The [development instance](https://openprogram.io/docs/reference/design/distribution/dev-instance.html) (`/Applications/OpenProgram Dev.app`, port 18200, `~/.openprogram-dev`) runs it, updated after commits by `openprogram dev deploy` or `scripts/local-instances/refresh-dev-instance.sh` |
| `main` | The line GitHub carries, with its own history. Only `scripts/publishing/publish-github.sh` adds to it: one commit per sync, holding a `dev` tree on top of the previous `main` commit |

A worktree branch is merged into `dev` and deleted, or deleted when abandoned. One worth keeping goes under `refs/archive/`, which no command lists as a branch and nothing pushes.

## Daily sync, occasional release

Both go through `scripts/release/publish-updates.py`, which builds `main` on this machine and puts its code on the rolling `updates` release under two signed pointers ([automatic updates](https://openprogram.io/docs/reference/design/distribution/automatic-updates.html)).

| Step | What happens |
| --- | --- |
| Sync (`publish-github.sh -m "summary"`) | About once a day, when `dev` has new commits. GitHub gets the day's source and `latest.json` points at it, for development and testing installs. Nobody is notified; no workflow runs. When the runtime inputs changed, it is refused until the Release workflow uploaded every platform's runtime layer (`gh workflow run release.yml -R Fzkuji/OpenProgram --ref main -f runtime_layers_only=true`), and a rerun then goes through |
| Feature release (`--tag vX.Y.0`) | `main` and the tag are pushed and the Release workflow is dispatched; it builds the installers, every platform's runtime layer, every App's shell layer and the GitHub Release. App shell changes ride on these feature releases only. Once it finished, `publish-updates.py announce vX.Y.0` signs `channel.json`, which announces it to every install; it refuses until that Release, every runtime layer and a shell layer for every App it published that replaces itself are up |
| Code-only release (`--tag vX.Y.Z`, `vX.Y.Z.W`) | The same, without a workflow: `publish-updates.py release-page` creates the GitHub Release with the notes in one call. It is not marked latest, so the Latest badge stays on the X.Y.0 release that holds the installers, which its notes link. Refused before anything moves when the runtime or shell inputs changed: that needs a feature release |

Pushing `main` or a tag starts nothing, so a sync costs no Actions time and a code-only release only the website's two-minute build:

| Workflow | Starts on |
| --- | --- |
| `release.yml` | Only by hand with `tag`, which `publish-github.sh --tag vX.Y.0` does; `rehearse` builds and checks everything without publishing |
| `docs-pages.yml` | Dispatched by `publish-github.sh --tag` for every release, so the site shows the released tree; otherwise by hand |
| `ci.yml`, `contributors-readme.yml`, `linux-release-smoke.yml`, `windows-install-smoke.yml` | Only by hand (`workflow_dispatch`) |

## The stable App on this machine

`/Applications/OpenProgram.app` (port 18100, data in `~/.openprogram`) is the official Release: installed once from its DMG, then updated only by the App's own [updater](https://openprogram.io/docs/reference/design/distribution/automatic-updates.html), which reads the signed `channel.json`, downloads the release it announces in the background, shows **New** and swaps it in on **Restart to update**.

Nothing on this machine builds or installs it, so what the owner runs as stable is exactly what users download.

## Syncing

```
scripts/publishing/publish-github.sh -m "Sidebar run status, Launchpad, Agent cards" --dry-run
scripts/publishing/publish-github.sh -m "Sidebar run status, Launchpad, Agent cards"
python scripts/release/release-version.py set 1.6.0
scripts/publishing/publish-github.sh -m "Office editor" --tag v1.6.0 --dry-run
scripts/publishing/publish-github.sh -m "Office editor" --tag v1.6.0
python scripts/release/release-version.py set 1.6.1
scripts/publishing/publish-github.sh -m "Sidebar fixes" --tag v1.6.1
```

| Flag | Effect |
| --- | --- |
| `-m "summary"` | What the sync brings; required when the source differs from `main` |
| `--source <ref>` | Squash another commit on `dev`; default `dev` |
| `--dry-run` | Show the message, the checks and `publish-updates.py plan`, change nothing |
| `--no-push` | Stop after step 7 |
| `--tag vX.Y.Z[.W]` | Steps 9 and 10; cannot be combined with `--no-push` |
| `--office-archive <file>` | With `--tag vX.Y.0`: the local copy of the [Office archive](#office-archive), checked against its pin and put on the tag's draft release when GitHub has none |

1. On a real run, install the guards into the shared `.git/hooks`, so every worktree has them.
2. Refuse a source not on `dev`. When `main` already holds the source's tree there is nothing to sync; go to step 8.
3. Refuse a source whose tree, or a summary, names a [retired account](#retired-accounts), listing each `path:line`. This runs on every call, dry runs included.
4. Scan added lines for live-looking credentials (GitHub tokens, Anthropic API keys, AWS access keys, private key blocks) and refuse on a hit. AWS's documented example key and one-line PEM strings in tests do not count.
5. Refuse if `scripts.docs_site.check --all` or `scripts.docs_site.check_landing --source-only` fails on the source commit, read from a temporary checkout of it.
6. Write the message: the summary, the number of local commits since the previous sync, and a `Local-Source:` trailer.
7. Create the commit with `git commit-tree`: the source's tree, the previous `main` as only parent (none for the first sync), author and committer the [publishing identity](#publishing-identity). Move `main` and record the source in `refs/publish/last`, where the next sync starts counting.
8. Push `main` after checking GitHub's `main` is an earlier point of local `main`, so the push only fast-forwards. Refuse when any commit being uploaded has another author or committer, or its message names a retired account.
9. Upload the code layer: `publish-updates.py run --commit <main>`, with `--release` on a code-only tag, never on vX.Y.0. A call with nothing to sync still does this, so a failed upload heals.
10. With `--tag`, tag the pushed commit, push the tag and dispatch `docs-pages.yml`; the release then goes on as [its row](#sync-and-release) says.

| A tag run refuses, before anything moves | When |
| --- | --- |
| Tag | It already exists, here or on GitHub, or it is not `vX.Y.Z` or `vX.Y.Z.W` |
| [Version places](#version-places) | One disagrees on the source; each is named |
| Release notes | The source has no `.github/release-notes/vX.Y.Z.md` starting with `# OpenProgram X.Y.Z Release Notes`, followed by 1 to 8 numbered points (`1. …`), the only part the App shows |
| Update plan | `publish-updates.py plan --release` refuses (exit 3), such as a code-only version whose runtime or shell inputs changed. For vX.Y.0 a refusal for missing runtime layers is only shown, since its workflow builds them |
| [Office archive](#office-archive), vX.Y.0 | A given `--office-archive` is not the pinned one, or, on a real run, no file is given and neither the newest release nor the tag's draft has it (asked with `gh`). A given file seeds the draft |

`--dry-run` runs these checks without the question to GitHub, says whether a local archive was given and matches, and shows the release.

### Version places

A version is `X.Y.Z` or `X.Y.Z.W`, written in six places:

- `pyproject.toml` and `uv.lock`, the code's own, take every version.
- The installer places, the rest, move only with a feature release X.Y.0. Under a code-only version they keep the 3-part version of the last installer build in the same X.Y series.

`python scripts/release/release-version.py set VERSION` writes its places, or none when one cannot be found; `check vVERSION` names each that disagrees, and is what step 10 runs on the source commit.

| Place | What stops a release that missed it |
| --- | --- |
| `pyproject.toml`, `apps/desktop/package.json` | `verify-release-version.py --tag` in every build job, which also refuses a tag whose places do not all agree, so the workflow builds only a feature release |
| `scripts/release/install-release.sh` and `.ps1` default version | The same check |
| `uv.lock`, its `openprogram` entry | `uv run --locked` and `uv sync --locked` in the wheel, runtime and Windows contract steps |
| `package-lock.json`, its `apps/desktop` entry | Nothing in the build; kept with the others so the tree never names two versions |

**Other refusals**

| Condition | Result |
| --- | --- |
| `refs/publish/last` is not an ancestor of the source | Refused; nothing changes |
| No `origin` remote | The version stays on local `main` |
| GitHub's `main` is not part of local `main` | Push refused |

## Publishing identity

| Part | Rule |
| --- | --- |
| Repository | `Fzkuji/OpenProgram`, the project's first repository: `main` carries its history up to 0.9.8, then squashed commits from 1.0.0 on |
| Sync commits | Signed `FuzzyKuji`, `9404270+FuzzyKuji@users.noreply.github.com`, the account that uploads them, whatever identity the checkout commits with, so no commit on GitHub carries the owner account's address |
| Before the push | The part of `main` GitHub lacks holds only that signature, or nothing goes up; the earlier history has many authors and is not checked |
| Upload account | `FuzzyKuji`, whichever `gh` account is active: the script takes its token from `gh` and has git ask `gh` for credentials, so the owner account's token never reaches GitHub. Without that login a real run stops first |
| 1.0.0 to 1.3.0 | Built in `FuzzyKuji/OpenProgram`, where their installers stay and their notes link. Such an App checks that repository, so 1.4.0 or later is installed over it by hand once |
| From 1.4.0 | Built in `Fzkuji/OpenProgram`; download links, the installer scripts, the App's update check and source links read it |
| Author lines | `pyproject.toml`, `apps/desktop/package.json` and the README licence line keep the name the 1.x versions shipped with |

## Retired accounts

The project once published under a GitHub account it no longer has. Nothing published names it: no author, link, example, fixture or note.

| Where | Check |
| --- | --- |
| `scripts/publishing/retired_accounts.py` | Holds each login, address and id only as the SHA-256 of its lowercase form, so the guard names none. Text is compared token by token; tokens are also split at `/ @ + . _ -` and percent-encoding (also double), HTML entities and `\u`/`\x` escapes are decoded, so a login inside a URL, an address or a file name is found |
| `tests/unit/config/test_no_retired_accounts.py` | Fails when any tracked text file, or a tracked path, names one |
| `scripts/publishing/publish-github.sh` | Scans the source commit's tree, read from the object store rather than the checkout, the summary and the part of `main` being uploaded |
| `scripts/publishing/update_readme_contributors.py` | Never lists a retired login in the README contributor block |

`.github/release-notes/` holds notes for those versions only, and the 1.0.0 notes link to no earlier version.

## The website

The landing page and the documentation are published by the docs-pages workflow as the GitHub Pages site of `Fzkuji/OpenProgram` itself, at `https://openprogram.io/`, documentation under `docs/`. A separate site repository under another account went down with that account, so the site lives with the code. The address is one setting: `SITE_URL` in `openprogram/operations/project_site.py`.

Every release dispatches the workflow, so the site follows releases, not daily syncs. The workflow refuses a landing page whose release link does not name the version in `pyproject.toml`, so every sync runs `scripts.docs_site.check_landing --source-only` (the same checks, without the built site) on the commit it publishes, and a version bump moves the landing page's version with the rest.

| Point | Decision |
| --- | --- |
| Verified custom domain | `openprogram.io` is verified under Fzkuji and attached to this repository. Retain its DNS TXT ownership record; `www` points to the account Pages host. The personal homepage remains separate. |
| Derived in code | Canonical and language links, the sitemap, Markdown copies, `llms.txt`, `robots.txt`, social-card URLs, the IndexNow host and key, the update source and its host. Files in `docs/_static_root` write `{{SITE_URL}}`; the build writes `CNAME` only for a custom domain |
| Mount path | Links the build writes start with `OPENPROGRAM_DOCS_BASE`: `/docs/` in the worker, `project_site.DOCS_PATH` in the workflow. They stay root-absolute because the site script keeps the sidebar across page changes and matches it by path. Files that sit at the site root, such as `favicon.ico`, are linked through the parent of that path, so they resolve below the address's path too |
| Relative | Links written between documentation pages, including the newest-download links to `../latest.html?<name>`, and every link on the landing page. `latest.js` reads only GitHub and the page's own query |
| Written out | READMEs, release notes, install scripts, the landing page's canonical and social URLs, the desktop App's update source. `tests/unit/config/test_site_address.py` fails on any tracked file naming another site address, and on an absolute link between documentation pages |
| Read at run time | `install`, `install.ps1` and `install.cmd` at the site root; `update-source.json`, optional and read only when GitHub fails |

## What a release builds

Every platform leg is independent. A code-only release builds nothing here.

A feature release is tagged straight after a `--dry-run`: `publish-github.sh -m "…" --tag vX.Y.0` pushes `main` and the tag and starts the Release workflow. `rehearse=true` stays available to build and check everything without publishing, but a release does not wait for it.

`gh workflow run windows-install-smoke.yml -f tag=vX.Y.0 -f run_id=<run>` installs a run's Windows files on a Windows runner when a Windows change needs it.

| Point | Behaviour |
| --- | --- |
| Failed leg | Its files are left out; the publish job uploads what succeeded |
| Windows checks | App leg: the platform contract tests in `scripts/release/windows-contracts.txt`, then the installer installs, launches to a healthy worker, makes one tool call and uninstalls keeping the data. A failed contract does not stop the build and the install check; a step before the upload keeps that App out. Runtime leg: the installed command makes one tool call. A failure leaves out only that package. A failed Windows leg keeps its logs as a `diagnostics-windows-*` artifact, never published |
| `release-manifest.json` | Lists only what exists |
| Release notes | Gain a "Not in this release" section naming what is missing and why |
| Planned package missing | After the release is public, the publish job fails and names each one, so the run cannot look complete |
| Publishing refused | Only when the wheel or the [Office archive](#office-archive) is missing, or no macOS or Linux command-line runtime was built |

Certificates decide the form of a package, never whether it exists.

| Package | With credentials | Without |
| --- | --- | --- |
| macOS App | Developer ID signed and notarized, `OpenProgram-X.Y.Z-mac-<arch>.dmg` | Ad-hoc signature, `-unsigned` in the name |
| Windows App | Authenticode signed, `OpenProgram-X.Y.Z-win-<arch>.exe` | `-unsigned.exe` |
| Linux App | AppImage and deb need none; built on Ubuntu 22.04, x86_64 and arm64 | The same |

| Case | Result |
| --- | --- |
| `OPENPROGRAM_UPDATE_SIGNING_KEY` absent or not listed in `RELEASE_PUBLIC_KEYS` | Windows and Linux Apps are left out and named in the notes: a thin-layout App with no trusted update signing key could never update |
| AppImage build fails | The deb still ships |
| One copy per file | Each App is uploaded once, under its versioned name; newest-download links go through `latest.html` on the docs site ([why](https://openprogram.io/docs/reference/design/distribution/installation-packaging.html#one-copy-per-file)) |

Repository variables adjust the legs. None is needed for a normal release.

| Variable | Default | Effect |
| --- | --- | --- |
| `OPENPROGRAM_RELEASE_DESKTOP_MAC`, `_WINDOWS`, `_LINUX` | On; `false` switches off | That platform's App |
| `OPENPROGRAM_RELEASE_WINDOWS_RUNTIME` | On; `false` switches off | The Windows command-line runtime |
| `OPENPROGRAM_RELEASE_WINDOWS_ARM64` | Off; `true` switches on | Windows on Arm, App and runtime |
| `OPENPROGRAM_RELEASE_MAC_THIN` | On; `false` forces the full App | The thin macOS App, whenever signing and the update key exist |
| `OPENPROGRAM_RELEASE_CLI_SEEDS` | Off; `true` switches on | `-seed-` assets for the command-line installers, once the key exists |

macOS stays on the full App, and command-line installs on the complete runtime, until those two switches are turned on: Apps and command lines from v1.0.0 need the existing DMG names, runtime archives and `release-manifest.json`, and a seed install needs a released network fetcher.

## The Office archive

The optional Office editor installs from one zip, about 699 MiB, whose name, size and SHA-256 are pinned in `openprogram/programs/applications/office_editor/install.py`; the download limit for `office.assets` in `safe_http.py` is the same size. Every feature release from 1.3.0 uploads it once; 1.0.0 to 1.2.0 and code-only releases carry none.

| Point | Behaviour |
| --- | --- |
| Where the App looks | Its own version's release, then `releases/latest/download/`, which serves a code-only version or a build with no release of its own while the pin is unchanged: the latest release is the X.Y.0 one. Both copies are held to the pinned size and SHA-256 |
| Why not only the newest release | A fixed name on the newest release breaks every installed version the day a release changes the pack; a copy in each release keeps each version installable for as long as its release exists |
| No release has it | The install answers `office_release_missing`: a version before 1.3.0 is told to update to 1.3.0 or newer, any other to update to the newest version. A retry is not offered as the fix |
| Where a release gets it | It cannot be rebuilt in CI: the licensed fonts and the pinned editor build are the owner's inputs ([Office README](https://github.com/Fzkuji/OpenProgram/blob/main/scripts/release/office/README.md)). The `office` job downloads the newest published release's copy, or else the one on the tag's draft release, and checks its bytes |
| First release to carry it | `publish-github.sh --tag vX.Y.0 --office-archive /path/to/OfficeAssets-….zip` checks the file and, before anything moves, puts it on the tag's draft release (`office-archive.py seed`). Every later release carries the previous one's copy with no upload by hand |
| Neither copy exists | The `office` job fails with the file name, size, SHA-256 and the seed command. Every build waits for it, so nothing is built or published |
| After publishing | The check on the public latest release also requires exactly one copy of the archive |
| A new pack | Needs a new file name, never new bytes under an old one, because installed versions pin the bytes behind each name. `office-archive.py pack` names it `OfficeAssets-<editor>-<patch>-<pack>.zip`, the last part from the pack's own manifest digest, so different bytes always get a different name |

### Rebuilding the archive

On the owner's machine, from a `dev` checkout. The `pack` step makes the same zip from the same prepared pack. An installed copy is a prepared pack: when `~/.openprogram/cache/office/<source>-<patch>/versions/<manifest>` validates against the pins in `office_editor/assets.py`, copy it out and go straight to the `pack` step; nothing is built or downloaded.

1. Gather the inputs the [Office README](https://github.com/Fzkuji/OpenProgram/blob/main/scripts/release/office/README.md) names: a git checkout of `agentbridges-ai/onlyoffice-browser` at `d15d12b6945be4d8b0f3aa1806120e740d2950ee` (package 0.3.34); the licensed font input and the font pack made from it with `font-generation.mjs` and Document Server 9.3.0's generator, whose manifest digest must equal `OFFICE_FONT_MANIFEST_DIGEST` in `office_editor/assets.py`; npm registry access for `npm ci`.
2. Set `OFFICE_LOCK_SHA256` in `office_editor/assets.py` to the SHA-256 of `scripts/release/office/package-lock.json`, the reviewed lock `prepare.py` builds with; the pack's last validation refuses any other lock.
3. `python scripts/release/office/prepare.py --source … --font-pack … --font-input … --output /path/to/prepared-office`
4. `python scripts/release/office-archive.py pack /path/to/prepared-office /path/to/out` writes the zip and pins its name, size and SHA-256 in `install.py` and the download limit in `safe_http.py`.
5. Run the affected tests, commit on `dev` and deploy.
6. `scripts/publishing/publish-github.sh -m "…" --tag vX.Y.0 --office-archive /path/to/out/OfficeAssets-….zip --dry-run`, then the same without `--dry-run`.

## The guards

| Hook | Refuses | Allows |
| --- | --- | --- |
| `scripts/git-hooks/pre-push` | A push to `refs/heads/main` without `OPENPROGRAM_GITHUB_PUBLISH=1` (set by the script) or not sending local `main`; a push of any other branch, which would upload the working history; a tag not pushed by the script or not naming local `main`, because a tag marks a release | Deleting a remote branch or tag |
| `scripts/git-hooks/pre-commit` | A commit while `main` is checked out; a commit whose staged docs fail `scripts.docs_site.check`; a commit whose staged Python imports a higher layer or closes a cycle inside one (`scripts.testing.layer_check`) | Every other branch |

The machine's global hooks (`core.hooksPath`) delegate both to the repository's `.git/hooks`, which is why the script installs them there.

## Rules for sessions

- **Commit**: to `dev` as often as the work needs; deploy as in [Deploying to the development instance](https://openprogram.io/docs/reference/design/distribution/dev-instance.html#deploying-to-the-development-instance)
- **Sync**: about once a day when `dev` has new commits, without `--tag`; it updates `latest.json` only
- **Release**: when a version is ready: bump it with `release-version.py set`, write its notes, then `--tag vX.Y.Z`. vX.Y.0 when installers must be rebuilt, otherwise a code-only vX.Y.Z or vX.Y.Z.W
- **Never**: commit on `main`
- **Never**: `git push` `main` by hand
- **Never**: merge `main` into `dev`
- **Never**: push another branch to GitHub
- **Never**: open a pull request from a local branch: it would list every local commit

## Implementation status

| Status | Items |
| --- | --- |
| Implemented | `scripts/publishing/publish-github.sh` with dry run, `--no-push`, `--tag` for feature and code-only releases, credential scan, retired-account scan, publishing-identity check and `refs/publish/last`; both guards; every workflow started only by hand; the rules in `AGENTS.md`; the Release workflow's independent legs; the Office archive in every release and the App's download from its own release |
| Switch-over | The stable App on this machine is still a local build. It becomes the official Release when the next release is installed from its DMG; installing an older release over data written by newer local builds is avoided, so the switch waits for that release. |
| Not yet run | A complete Release run. The one run so far, for v1.1.0, published the macOS and Linux Apps and every command-line runtime; the Windows installer was built and left out. The 1.2.0 rehearsal ran once: the publish job's check named the three Apps that did not pass (both macOS legs at signing, Windows at its App smoke). The Windows install smoke workflow has not run |
| Waiting for 1.3.0 | No release carries the Office archive yet. The pinned file, `OfficeAssets-d15d12b-dc31dd9d-24d2d8e1.zip`, is [packed](#rebuilding-the-office-archive) from the installed pack and kept on the owner's machine at `~/OpenProgram-release/office/`; 1.3.0 is tagged with `--office-archive` pointing at it |
