mirror upstream before building host releases
custom release / build-custom-release (push) Successful in 8m24s

This commit is contained in:
2026-08-12 11:51:16 +02:00
parent 74d469b35e
commit ca01296949
5 changed files with 82 additions and 0 deletions
+6
View File
@@ -12,6 +12,7 @@ on:
- ".gitea/workflows/custom-release.yml" - ".gitea/workflows/custom-release.yml"
- "patches/**" - "patches/**"
- "scripts/update-custom-release.sh" - "scripts/update-custom-release.sh"
- "scripts/sync-upstream.sh"
workflow_dispatch: workflow_dispatch:
inputs: inputs:
upstream_tag: upstream_tag:
@@ -43,6 +44,11 @@ jobs:
git config user.name "Gitea Actions" git config user.name "Gitea Actions"
git config user.email "actions@git.felixfoertsch.de" git config user.email "actions@git.felixfoertsch.de"
- name: Mirror upstream and rebuild patched main
run: ./scripts/sync-upstream.sh
env:
SYNC_REMOTE: origin
- name: Set up tea - name: Set up tea
run: | run: |
go install code.gitea.io/tea@v0.14.1 go install code.gitea.io/tea@v0.14.1
+6
View File
@@ -11,6 +11,7 @@ on:
- ".github/workflows/custom-release.yml" - ".github/workflows/custom-release.yml"
- "patches/**" - "patches/**"
- "scripts/update-custom-release.sh" - "scripts/update-custom-release.sh"
- "scripts/sync-upstream.sh"
workflow_dispatch: workflow_dispatch:
inputs: inputs:
upstream_tag: upstream_tag:
@@ -42,6 +43,11 @@ jobs:
git config user.name "GitHub Actions" git config user.name "GitHub Actions"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com" git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Mirror upstream and rebuild patched main
run: ./scripts/sync-upstream.sh
env:
SYNC_REMOTE: origin
- name: Build patched Syncthing release - name: Build patched Syncthing release
run: | run: |
case "$(uname -m)" in case "$(uname -m)" in
+2
View File
@@ -34,6 +34,8 @@ CUSTOM_RELEASE_BUILDS="darwin/amd64/zip darwin/arm64/zip linux/amd64/tar linux/a
The Gitea and GitHub workflows run the script on their respective CI hosts when The Gitea and GitHub workflows run the script on their respective CI hosts when
the local patchset changes on `main`, on a schedule, and on manual dispatch. the local patchset changes on `main`, on a schedule, and on manual dispatch.
The repository's `upstream` branch stays a clean upstream mirror. The repository's `upstream` branch stays a clean upstream mirror.
Before building, each host updates its own `upstream` branch from official
Syncthing `main` and rebuilds its patched `main` directly on that commit.
The workflow detects the latest upstream Syncthing stable tag, exits if the The workflow detects the latest upstream Syncthing stable tag, exits if the
matching custom tag already exists, pushes only the `<upstream>-stignore.7` tag matching custom tag already exists, pushes only the `<upstream>-stignore.7` tag
by default, and publishes release assets on the CI host running the workflow. by default, and publishes release assets on the CI host running the workflow.
+55
View File
@@ -0,0 +1,55 @@
#!/usr/bin/env bash
set -euo pipefail
upstream_url="${SYNC_UPSTREAM_URL:-https://github.com/syncthing/syncthing.git}"
remote="${SYNC_REMOTE:-origin}"
upstream_branch="${SYNC_UPSTREAM_BRANCH:-upstream}"
main_branch="${SYNC_MAIN_BRANCH:-main}"
tmp=""
die() {
printf 'error: %s\n' "$*" >&2
exit 1
}
cleanup() {
[[ -z "$tmp" ]] || rm -rf "$tmp"
}
main() {
[[ -z "$(git status --porcelain)" ]] || die "working tree has uncommitted changes"
local current_main
local current_upstream
local new_upstream
current_main="$(git rev-parse "refs/heads/$main_branch")"
current_upstream="$(git rev-parse "refs/remotes/$remote/$upstream_branch")"
git fetch "$upstream_url" "refs/heads/main:refs/remotes/official/main"
new_upstream="$(git rev-parse refs/remotes/official/main)"
if [[ "$new_upstream" == "$current_upstream" ]]; then
printf 'Upstream is already current at %s.\n' "$new_upstream"
return
fi
tmp="$(mktemp -d)"
trap cleanup EXIT
mkdir -p "$tmp/.gitea/workflows" "$tmp/.github/workflows" "$tmp/patches" "$tmp/scripts/tests"
cp .gitea/workflows/custom-release.yml "$tmp/.gitea/workflows/"
cp .github/workflows/custom-release.yml "$tmp/.github/workflows/"
cp patches/*.patch patches/README.md "$tmp/patches/"
cp scripts/update-custom-release.sh scripts/sync-upstream.sh "$tmp/scripts/"
cp scripts/tests/test-custom-release-macos-runner.bats "$tmp/scripts/tests/"
git branch -f "$upstream_branch" "$new_upstream"
git push --force-with-lease="$upstream_branch:$current_upstream" "$remote" "$upstream_branch"
git checkout -B "$main_branch" "$new_upstream"
cp -R "$tmp/.gitea" "$tmp/.github" "$tmp/patches" "$tmp/scripts" .
git apply patches/sync-stignore.patch patches/webui-build-marker.patch
git add -A
git commit -m "sync upstream, apply stignore patch"
git push --force-with-lease="$main_branch:$current_main" "$remote" "$main_branch"
}
main "$@"
@@ -5,6 +5,19 @@ setup() {
WORKFLOW="$REPO_ROOT/.gitea/workflows/custom-release.yml" WORKFLOW="$REPO_ROOT/.gitea/workflows/custom-release.yml"
GITHUB_WORKFLOW="$REPO_ROOT/.github/workflows/custom-release.yml" GITHUB_WORKFLOW="$REPO_ROOT/.github/workflows/custom-release.yml"
RELEASE_SCRIPT="$REPO_ROOT/scripts/update-custom-release.sh" RELEASE_SCRIPT="$REPO_ROOT/scripts/update-custom-release.sh"
SYNC_SCRIPT="$REPO_ROOT/scripts/sync-upstream.sh"
}
@test "both hosts mirror upstream before building their own release" {
run rg -n 'run: ./scripts/sync-upstream.sh' "$WORKFLOW" "$GITHUB_WORKFLOW"
[ "$status" -eq 0 ]
[ "${#lines[@]}" -eq 2 ]
run rg -n 'git push --force-with-lease=.*upstream|git push --force-with-lease=.*main' "$SYNC_SCRIPT"
[ "$status" -eq 0 ]
run rg -n 'git apply patches/sync-stignore.patch patches/webui-build-marker.patch' "$SYNC_SCRIPT"
[ "$status" -eq 0 ]
} }
@test "github custom release uses a github macos runner and github releases" { @test "github custom release uses a github macos runner and github releases" {