Add a reproducible GitHub mirror sync

The GitHub mirror strips release installers from history, so its commit graph differs from origin. Document the workflow and add scripts/sync-github.sh instead of suggesting a direct push.
main
mula.liu 2026-11-25 16:30:22 +08:00
parent 29514edddb
commit e468c761c5
4 changed files with 46 additions and 6 deletions

View File

@ -336,7 +336,7 @@ The publish script rebuilds the `releases` branch with `squid-update.json`, both
See [`docs/RELEASE.md`](docs/RELEASE.md) for the full release, signing, and manifest process.
The GitHub repository receives source branches such as `main` only. It never receives `releases`; the publish script pushes the update branch to origin, and GitHub clones keep using that origin channel.
The GitHub repository receives source branches such as `main` only. It never receives `releases`; sync it with `scripts/sync-github.sh`, which strips release installers from GitHub history and therefore rewrites commit hashes. GitHub clones keep using the origin update channel.
## Platform status

View File

@ -316,7 +316,7 @@ scripts/publish-release.sh --notes /path/to/release-notes.md
完整发布流程、签名和清单格式见 [`docs/RELEASE.md`](docs/RELEASE.md)。
GitHub 仓库只推送 `main` 等源码分支,不推送 `releases`。发布脚本只向 origin 推送更新分支;GitHub 上的源码镜像继续使用 origin 的发布通道。
GitHub 仓库只保留源码分支(当前为 `main`),不承载 `releases`。同步使用 `scripts/sync-github.sh`;该脚本会从 GitHub 历史中剔除发布安装包,因此 GitHub 的提交哈希与 origin 不同。GitHub 上的源码镜像继续使用 origin 的发布通道。
## 平台状态

View File

@ -8,7 +8,8 @@ There are two remotes:
- `origin` is the canonical repository and the update channel. It carries the
orphan `releases` branch.
- GitHub is a public source mirror. It receives `main` only and must never
receive `releases`.
receive `releases`. Its history is rewritten to drop `release/`, `*.dmg` and
`*.exe`, so its commit hashes differ from origin.
## Artifact names
@ -130,14 +131,18 @@ scripts/publish-release.sh --dry-run --key ~/.config/squid-release/release.ed255
scripts/publish-release.sh --no-push --key ~/.config/squid-release/release.ed25519
```
The script pushes `releases` to `origin` only. Push the source mirror
separately, and never push the release branch to GitHub:
The script pushes `releases` to `origin` only. Push the source mirror with the
sync script, which strips release installers from GitHub history:
```bash
git push origin main
git push github main
scripts/sync-github.sh
```
Do not run `git push github main` from the working repository: its history still
contains the release installers, and the GitHub mirror has a different commit
graph.
The branch contains:
```text

View File

@ -0,0 +1,35 @@
#!/usr/bin/env bash
# Rebuild the public GitHub mirror without release installers.
#
# GitHub is a source mirror, not an update channel. Its history is rewritten to
# drop `release/`, `*.dmg` and `*.exe`, so its commit hashes differ from origin.
# Never push the working repository's `main` directly to GitHub; run this script
# after pushing origin/main instead.
#
# scripts/sync-github.sh
#
# Override the destination with SQUID_GITHUB_URL, or the branch with
# SQUID_GITHUB_BRANCH.
set -euo pipefail
cd "$(dirname "$0")/.."
BRANCH="${SQUID_GITHUB_BRANCH:-main}"
URL="${SQUID_GITHUB_URL:-https://github.com/VulpineLiu/squid.git}"
WORK="$(mktemp -d /tmp/squid-github-mirror.XXXXXX)"
trap 'rm -rf "$WORK"' EXIT
git clone --no-local --single-branch --branch "$BRANCH" . "$WORK/repo"
cd "$WORK/repo"
FILTER_BRANCH_SQUELCH_WARNING=1 git filter-branch --force \
--index-filter 'git rm -r --cached --ignore-unmatch release "*.dmg" "*.exe"' \
--prune-empty -- --all
git for-each-ref --format='%(refname)' refs/original/ | while read -r ref; do
git update-ref -d "$ref"
done
git reflog expire --expire=now --all
git gc --prune=now --aggressive >/dev/null
git remote add github "$URL"
git push --force github "$BRANCH:$BRANCH"