Files
piik/docs/operations/github.md
T
TNTcraft a6ddc01eca fix(release): decouple download mirrors from source synchronization
## Problem and outcome / 问题与结果

A published GitHub release could remain missing from AtomGit while the
mirror workflow reported a successful deferral, because it required the
mirrored Git commit and tag first. Package distribution now depends on
the canonical GitHub release and original artifacts. A missing mirror
proceeds to publication; only a matching stable release with its
complete attachment inventory counts as complete.

Release creation uses the mirror's default branch to satisfy AtomGit's
local tag requirement. The release body identifies GitHub as the source
authority, and the publisher retains full anonymous size/SHA-256
verification before marking the mirror stable. The operations guide
makes verified mirror publication part of release completion and
documents the read-only Pull-mirror restriction.

## Verification / 验证

- 58 release publication/readiness/source tests, tooling type checks and
repository hygiene passed.
- Workflow lint passed with the existing unsupported `concurrency.queue`
diagnostic excluded.
- Recovered the original v2.6.3 artifacts without rebuilding: all ten
packages (331,048,966 bytes) were uploaded, anonymously downloaded and
matched against their original SHA-256 values; AtomGit now reports
v2.6.3 as stable/latest.
- The platform's Pull association still needs to permit new local tags
independently of source synchronization; this remains an explicit
operator follow-up.

## Impact / 影响

Release tooling and its operating contract only; no App/Server version
or compatibility change. Scheduled retries remain recovery support and
no longer report missing source synchronization as successful
completion.
2026-11-13 15:23:00 -04:00

183 lines
11 KiB
Markdown

# GitHub Repository And Releases
[Versioning](../standards/versioning.md) owns release meaning and compatibility;
[CONTRIBUTING](../../CONTRIBUTING.md) owns review and local validation. This file
owns the one-time GitHub settings. The source repository is public; automatic
package publication has its own activation gate below.
## Main And Pull Requests
Use squash merging only, with the PR title and body as the squash commit. These
repository settings are applied. Keep automatic branch deletion off: the normal
cleanup step checks local worktrees and remaining references first.
Protect `main` with PRs required, zero mandatory peer approvals for the solo
maintainer, administrator enforcement, linear history, and no force pushes or
deletions. PRs run the read-only release-note check; ordinary branch pushes stay
quiet. Local validation and acceptance precede the squash merge, and required
check settings remain a repository-owner decision. PR/issue
templates live in `.github/`; [naming](../../CONTRIBUTING.md#commit-pr-and-branch-names)
is shared with automatic version selection.
These protections are active, including conversation resolution. GitHub Pages
uses the **GitHub Actions** publishing source and the `piik.tv` custom domain;
the repository homepage points to `https://piik.tv`. The dedicated Website
workflow publishes the static site under [website operations](./website.md).
## Enable Automatic Publication Once
Before enabling, accept the release packages, compatibility baseline, public
copy and repository visibility; finish main protection. Then set repository
Actions variable `PIIK_RELEASES_ENABLED` to `true`. This is a repository setting,
not an environment variable for Piik App or Server.
Subsequent accepted PRs merged to main use the existing CI workflow. Product
changes calculate one version, validate, package Server and all App targets,
and publish the same artifacts. Standalone website/docs changes validate without
packaging or releasing; [versioning](../standards/versioning.md#automatic-publication)
owns that boundary. Runs queue rather than overlap or cancel one another. PRs
validate release notes without packaging or publication; manual `app_checks`
dispatch remains available for candidates.
Writing a new version back to main is unnecessary and prohibited.
For a complete package rehearsal, dispatch with `app_checks: true` and an
explicit `candidate_version` such as `v1.0.0`. This builds genuine Server and
native App artifacts under one revision and version without tagging or
publishing. Prepare its [release-note section](../standards/versioning.md#release-notes)
in the candidate PR and review that rendered body; branch checkpoints need no
release copy. The publishing run generates the final notes from accepted squash
commits. To preview that aggregate locally after integration, run
`node scripts/release-notes.mjs VERSION FULL_SOURCE_SHA` from the checkout with
full history and tags. Download the candidate run's artifacts and pass their
directory, version and full revision to `scripts/publish-release.mjs --dry-run`
(put the flag after the three positional arguments). This validates package
identity and checksums without publishing or aggregating branch commit messages.
An omitted candidate version keeps the usual development/exact-tag identity.
Enable GitHub's built-in release immutability for formal publication where
available. Upload all assets to the draft before publishing. A failed upload can
resume its same-source draft; a published version is never clobbered. If its
files are wrong or incomplete, publish a corrected new version. An older retry
must not replace a newer release's `latest` designation.
To stop future automatic publication, remove/set false the activation variable;
this does not alter existing releases or a currently running workflow. Inspect
the active run separately. No pipeline step changes visibility or installs an
update into a running Piik deployment.
For accepted contribution PRs that should merge without a release, set
`PIIK_RELEASES_ENABLED=false` before merging and confirm no active publishing
run will release the changes. Keep it false through subsequent merges until
the next release is authorized. Then restore `true` before that release's
integration merge. The existing release planner and notes collector include
all eligible changes since the last stable tag; no separate contribution
release or version-record commit is needed.
## Container Registry
The Server image uses `ghcr.io/tntcrafthim/piik`. The publishing job authenticates
with `GITHUB_TOKEN` and `packages: write`; no additional registry secret is needed.
The image's source label links it to this repository. GitHub's
[Container registry guide](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-container-registry)
owns the registry permission and visibility behavior.
At first publication, set the Piik container package's visibility to **public**
in its GitHub package settings; repository visibility alone does not do this.
Verify both its version tag and `latest` with an anonymous pull before announcing
the Docker download. Keep repository Actions access enabled for later releases.
Image checks, version identity and retries follow
[container distribution](../standards/versioning.md#container-distribution).
## AtomGit Download Mirror
[AtomGit TNTcraftHIM/Piik](https://atomgit.com/TNTcraftHIM/Piik) is the public
download mirror. GitHub owns development, issues, source identity and original packages.
The **AtomGit mirror** GitHub workflow copies published binary assets. Repository
synchronization is optional and must not gate package distribution. A mirror's
local Release tag only locates attachments; the GitHub source marker and verified
original package digests establish their identity. Release creation uses the
mirror's initialized default branch when the local tag does not exist.
Its repository Actions secret is `ATOMGIT_TOKEN`. Never put this token in source,
a remote URL or a distributed package. GitHub publication keeps its scoped token.
Use a writable repository for package distribution. AtomGit's Pull-mirror mode
rejects Release creation when it needs to create a tag, with an `image repository`
error. Remove that Pull association in **Project Settings → Repository Mirroring**
without deleting the repository or its Releases. Automatic source synchronization
is optional; it must not make the distribution repository read-only. Provider-generated
source archives are not the canonical source linked in the mirrored release body.
After a completed main-push CI run, the workflow checks the current stable GitHub
release and finds its original publishing CI run, even when the triggering run
only updated tooling. A later failed container step does not prevent
mirroring already-published packages. It downloads the source run's complete
original Server and App artifacts and invokes `scripts/mirror-release.mjs`.
An authorized release is not complete until its mirror and managed deployments
pass their postflight checks. GitHub publication and **Website** can proceed independently,
but a failed mirror remains unfinished release work. An unfinished mirror remains a
prerelease until every package passes anonymous full-download SHA-256 validation.
This includes the original signed APK and its already-built ZIP wrapper.
Every three hours the same workflow also checks the latest GitHub release's mirror
metadata. A stable mirror with the matching source marker and complete package
inventory of uploaded attachments needs no further work; provider-generated source
archives do not count as packages. A missing or incomplete prerelease resumes
publication from original artifacts without reading mirrored commits or tags.
Completed mirrors use a sparse tools-only checkout and skip dependency installation
and artifact downloads. API failures or conflicting source identities remain failures.
When ready, recovery locates the completed main-push CI run for that exact source,
downloads its original artifacts and resumes the existing publisher. It never
builds software. The publisher verifies every package anonymously before marking
the mirror stable; the periodic metadata check reuses that completion boundary.
Expired original artifacts require retained original build output, not rebuilding
the same published version. A stable release missing packages is an explicit
integrity failure and is never silently replaced.
For recovery, rerun **AtomGit mirror** with the original publishing CI run ID:
```sh
gh workflow run atomgit-mirror.yml --repo TNTcraftHIM/Piik --ref main -f run_id=RUN_ID
```
The run ID is optional; without it, the workflow resolves the latest GitHub release.
The scheduled check is recovery support, not the release-completion gate. If a
scheduled run is delayed or an upload fails, run this recovery during the authorized
release instead of assuming a later schedule will finish it.
The source must be a completed main-push CI run matching the latest published
GitHub release. The workflow runs trusted main tooling and treats artifacts only
as data. A superseded release cannot complete a new mirror. Both publishers reject
changing published bytes; a corrected package needs a corrected new version.
For a local retry, let any active workflow finish and recover the complete original
build output, including descriptors, manifests and checksum sidecars, in one fresh
directory. Use `gh run download` for each `piik-server*` and `piik-app-*` artifact
from that publishing run, or use the retained operator output after CI expiry.
Public Release archives alone do not include all validation sidecars. Never rebuild
a published version to recover metadata. See [artifact retention](../deployment.md#build-host).
```sh
node scripts/mirror-release.mjs /path/to/original-artifacts VERSION FULL_SOURCE_SHA --dry-run
node scripts/mirror-release.mjs /path/to/original-artifacts VERSION FULL_SOURCE_SHA
```
Supply `ATOMGIT_TOKEN` only through the publisher environment. Reads retry within
a bounded deadline, including complete response bodies. Mutations are not blindly
retried: rerunning inventories existing files before uploading missing ones. Signed
upload URLs and callback headers are credentials and are never logged. A failed
upload leaves a visible failed workflow and pending prerelease.
No automatic attachment cleanup runs. Do not apply Gitee's former size/quota or
retention rules to AtomGit. This migration does not delete the old Gitee repository
or its packages. Already published software keeps its embedded old fallback until
a later software release replaces it.
## Platform References
- [Protected branch availability](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches)
- [Workflow concurrency and queued runs](https://docs.github.com/en/actions/reference/workflows-and-actions/workflow-syntax#example-queueing-multiple-pending-runs)
- [Workflow completion triggers and trust boundaries](https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows#workflow_run)
- [Downloading original artifacts from another run](https://github.com/actions/download-artifact#download-artifacts-from-other-workflow-runs-or-repositories)
- [Immutable release workflow](https://docs.github.com/en/code-security/concepts/supply-chain-security/immutable-releases)