add reusable stignore sync release automation
Keep main as an upstream mirror while storing the local .stignore behavior, GUI marker, reusable patch files, and Gitea release workflow in one replayable branch commit.
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
# Local Syncthing Patches
|
||||
|
||||
Apply the local patches manually after pulling a new upstream Syncthing release:
|
||||
|
||||
```bash
|
||||
git apply patches/sync-stignore.patch patches/webui-build-marker.patch
|
||||
go run build.go -build-out bin/syncthing-stignore build syncthing
|
||||
```
|
||||
|
||||
The automated release flow uses:
|
||||
|
||||
```bash
|
||||
./scripts/update-custom-release.sh
|
||||
```
|
||||
|
||||
By default the script finds the latest stable upstream tag, creates a local
|
||||
`custom/<version>-<suffix>` branch, applies all local patches, removes upstream
|
||||
GitHub/Gitea workflow files from the release commit, tags
|
||||
`<upstream>-stignore.6`, regenerates embedded GUI assets, runs focused tests,
|
||||
and writes build artifacts to `dist/`.
|
||||
|
||||
Useful options:
|
||||
|
||||
```bash
|
||||
CUSTOM_RELEASE_UPSTREAM_TAG=v2.1.0 ./scripts/update-custom-release.sh
|
||||
CUSTOM_RELEASE_FORCE=1 ./scripts/update-custom-release.sh
|
||||
CUSTOM_RELEASE_PATCHES="patches/sync-stignore.patch patches/webui-build-marker.patch" ./scripts/update-custom-release.sh
|
||||
CUSTOM_RELEASE_PUSH=1 CUSTOM_RELEASE_REMOTE=gitea ./scripts/update-custom-release.sh
|
||||
CUSTOM_RELEASE_PUSH=1 CUSTOM_RELEASE_PUSH_BRANCH=1 CUSTOM_RELEASE_REMOTE=gitea ./scripts/update-custom-release.sh
|
||||
CUSTOM_RELEASE_CREATE_GITEA_RELEASE=1 CUSTOM_RELEASE_TEA_REPO=felixfoertsch/syncthing ./scripts/update-custom-release.sh
|
||||
CUSTOM_RELEASE_BUILDS="darwin/amd64/zip darwin/arm64/zip linux/amd64/tar linux/arm64/tar" ./scripts/update-custom-release.sh
|
||||
```
|
||||
|
||||
The Gitea workflow in `.gitea/workflows/custom-release.yml` runs the script when
|
||||
the local patchset changes on `felix/release-automation`, on a schedule, and on
|
||||
manual dispatch. The repository's `main` branch stays a clean upstream mirror.
|
||||
The workflow detects the latest upstream Syncthing stable tag, exits if the
|
||||
matching custom tag already exists, pushes only the `<upstream>-stignore.6` tag
|
||||
by default, and publishes the Gitea release assets.
|
||||
The local `custom/<version>` branch is only pushed when
|
||||
`CUSTOM_RELEASE_PUSH_BRANCH=1` is set. The workflow builds macOS amd64, macOS
|
||||
arm64, Linux amd64, and Linux arm64 archives.
|
||||
|
||||
The patch makes root-level `.stignore` sync like regular folder content while
|
||||
keeping `.stfolder` and `.stversions` protected as internal Syncthing paths.
|
||||
The web UI patch adds `It syncs .stignore now!` to the GUI footer so the custom
|
||||
binary is visually distinguishable from upstream builds. The release test fails
|
||||
if the generated GUI asset bundle does not contain that marker.
|
||||
@@ -0,0 +1,119 @@
|
||||
diff --git a/lib/fs/filesystem.go b/lib/fs/filesystem.go
|
||||
index 31bbb9770..dcece778e 100644
|
||||
--- a/lib/fs/filesystem.go
|
||||
+++ b/lib/fs/filesystem.go
|
||||
@@ -284,8 +284,8 @@ func NewFilesystem(fsType FilesystemType, uri string, opts ...Option) Filesystem
|
||||
}
|
||||
|
||||
// fs cannot import config or versioner, so we hard code .stfolder
|
||||
-// (config.DefaultMarkerName) and .stversions (versioner.DefaultPath)
|
||||
-var internals = []string{".stfolder", ".stignore", ".stversions"}
|
||||
+// (config.DefaultMarkerName) and .stversions (versioner.DefaultPath).
|
||||
+var internals = []string{".stfolder", ".stversions"}
|
||||
|
||||
// IsInternal returns true if the file, as a path relative to the folder
|
||||
// root, represents an internal file that should always be ignored. The file
|
||||
diff --git a/lib/fs/filesystem_test.go b/lib/fs/filesystem_test.go
|
||||
index 08e45ff50..2d100a2b0 100644
|
||||
--- a/lib/fs/filesystem_test.go
|
||||
+++ b/lib/fs/filesystem_test.go
|
||||
@@ -21,10 +21,8 @@ func TestIsInternal(t *testing.T) {
|
||||
internal bool
|
||||
}{
|
||||
{".stfolder", true},
|
||||
- {".stignore", true},
|
||||
{".stversions", true},
|
||||
{".stfolder/foo", true},
|
||||
- {".stignore/foo", true},
|
||||
{".stversions/foo", true},
|
||||
|
||||
{".stfolderfoo", false},
|
||||
@@ -34,6 +32,8 @@ func TestIsInternal(t *testing.T) {
|
||||
{"foo.stignore", false},
|
||||
{"foo.stversions", false},
|
||||
{"foo/.stfolder", false},
|
||||
+ {".stignore", false},
|
||||
+ {".stignore/foo", false},
|
||||
{"foo/.stignore", false},
|
||||
{"foo/.stversions", false},
|
||||
}
|
||||
diff --git a/lib/model/folder_recvonly_test.go b/lib/model/folder_recvonly_test.go
|
||||
index e84d0c49d..fbd442966 100644
|
||||
--- a/lib/model/folder_recvonly_test.go
|
||||
+++ b/lib/model/folder_recvonly_test.go
|
||||
@@ -60,15 +60,15 @@ func TestRecvOnlyRevertDeletes(t *testing.T) {
|
||||
|
||||
must(t, m.ScanFolder("ro"))
|
||||
|
||||
- // We should now have two files and two directories, with global state unchanged.
|
||||
+ // We should now have three files and two directories, with global state unchanged.
|
||||
|
||||
size = mustV(m.GlobalSize("ro"))
|
||||
if size.Files != 1 || size.Directories != 1 {
|
||||
t.Fatalf("Global: expected 1 file and 1 directory: %+v", size)
|
||||
}
|
||||
size = mustV(m.LocalSize("ro", protocol.LocalDeviceID))
|
||||
- if size.Files != 2 || size.Directories != 2 {
|
||||
- t.Fatalf("Local: expected 2 files and 2 directories: %+v", size)
|
||||
+ if size.Files != 3 || size.Directories != 2 {
|
||||
+ t.Fatalf("Local: expected 3 files and 2 directories: %+v", size)
|
||||
}
|
||||
size = mustV(m.ReceiveOnlySize("ro"))
|
||||
if size.Files+size.Directories == 0 {
|
||||
diff --git a/lib/model/requests_test.go b/lib/model/requests_test.go
|
||||
index 288140721..6f8124e97 100644
|
||||
--- a/lib/model/requests_test.go
|
||||
+++ b/lib/model/requests_test.go
|
||||
@@ -974,13 +974,15 @@ func TestIgnoreDeleteUnignore(t *testing.T) {
|
||||
file := "foobar"
|
||||
contents := []byte("test file contents\n")
|
||||
|
||||
- basicCheck := func(fs []protocol.FileInfo) {
|
||||
+ basicCheck := func(fs []protocol.FileInfo) protocol.FileInfo {
|
||||
t.Helper()
|
||||
- if len(fs) != 1 {
|
||||
- t.Fatal("expected a single index entry, got", len(fs))
|
||||
- } else if fs[0].Name != file {
|
||||
- t.Fatalf("expected a index entry for %v, got one for %v", file, fs[0].Name)
|
||||
+ for _, f := range fs {
|
||||
+ if f.Name == file {
|
||||
+ return f
|
||||
+ }
|
||||
}
|
||||
+ t.Fatalf("expected an index entry for %v, got %v", file, fs)
|
||||
+ return protocol.FileInfo{}
|
||||
}
|
||||
|
||||
done := make(chan struct{})
|
||||
@@ -1001,8 +1003,7 @@ func TestIgnoreDeleteUnignore(t *testing.T) {
|
||||
|
||||
done = make(chan struct{})
|
||||
fc.setIndexFn(func(_ context.Context, folder string, fs []protocol.FileInfo) error {
|
||||
- basicCheck(fs)
|
||||
- f := fs[0]
|
||||
+ f := basicCheck(fs)
|
||||
if !f.IsInvalid() {
|
||||
t.Errorf("Received non-invalid index update")
|
||||
}
|
||||
@@ -1022,8 +1023,7 @@ func TestIgnoreDeleteUnignore(t *testing.T) {
|
||||
|
||||
done = make(chan struct{})
|
||||
fc.setIndexFn(func(_ context.Context, folder string, fs []protocol.FileInfo) error {
|
||||
- basicCheck(fs)
|
||||
- f := fs[0]
|
||||
+ f := basicCheck(fs)
|
||||
if f.IsInvalid() {
|
||||
t.Errorf("Received invalid index update")
|
||||
}
|
||||
diff --git a/lib/scanner/walk_test.go b/lib/scanner/walk_test.go
|
||||
index d75dddaf3..3693ae4db 100644
|
||||
--- a/lib/scanner/walk_test.go
|
||||
+++ b/lib/scanner/walk_test.go
|
||||
@@ -40,6 +40,7 @@ type testfile struct {
|
||||
type testfileList []testfile
|
||||
|
||||
var testdata = testfileList{
|
||||
+ {".stignore", 48, "f60db5c36f642f8a6c1a636024330cd4dba6ab965083542f3629ff7d8c547911"},
|
||||
{"afile", 4, "b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b878ae4944c"},
|
||||
{"dir1", 128, ""},
|
||||
{filepath.Join("dir1", "dfile"), 5, "49ae93732fcf8d63fe1cce759664982dbd5b23161f007dba8561862adc96d063"},
|
||||
@@ -0,0 +1,62 @@
|
||||
diff --git a/gui/default/index.html b/gui/default/index.html
|
||||
index e3e573c9a..5ec76e740 100644
|
||||
--- a/gui/default/index.html
|
||||
+++ b/gui/default/index.html
|
||||
@@ -1017,6 +1017,9 @@
|
||||
</div> <!-- /row -->
|
||||
|
||||
</div> <!-- /container -->
|
||||
+ <footer class="container text-center text-muted small" aria-label="Custom build marker">
|
||||
+ It syncs .stignore now!
|
||||
+ </footer>
|
||||
</div> <!-- /ng-cloak -->
|
||||
|
||||
<ng-include src="'syncthing/core/networkErrorDialogView.html'"></ng-include>
|
||||
diff --git a/lib/api/auto/custom_marker_test.go b/lib/api/auto/custom_marker_test.go
|
||||
new file mode 100644
|
||||
index 000000000..73eae3db7
|
||||
--- /dev/null
|
||||
+++ b/lib/api/auto/custom_marker_test.go
|
||||
@@ -0,0 +1,42 @@
|
||||
+// Copyright (C) 2026 The Syncthing Authors.
|
||||
+//
|
||||
+// This Source Code Form is subject to the terms of the Mozilla Public
|
||||
+// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
+// You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
+
|
||||
+package auto
|
||||
+
|
||||
+import (
|
||||
+ "compress/gzip"
|
||||
+ "io"
|
||||
+ "strings"
|
||||
+ "testing"
|
||||
+)
|
||||
+
|
||||
+const customBuildMarker = "It syncs .stignore now!"
|
||||
+
|
||||
+func TestCustomBuildMarkerIsEmbedded(t *testing.T) {
|
||||
+ asset, ok := Assets()["default/index.html"]
|
||||
+ if !ok {
|
||||
+ t.Fatal("default/index.html is missing from embedded GUI assets")
|
||||
+ }
|
||||
+
|
||||
+ content := asset.Content
|
||||
+ if asset.Gzipped {
|
||||
+ reader, err := gzip.NewReader(strings.NewReader(asset.Content))
|
||||
+ if err != nil {
|
||||
+ t.Fatal(err)
|
||||
+ }
|
||||
+ defer reader.Close()
|
||||
+
|
||||
+ data, err := io.ReadAll(reader)
|
||||
+ if err != nil {
|
||||
+ t.Fatal(err)
|
||||
+ }
|
||||
+ content = string(data)
|
||||
+ }
|
||||
+
|
||||
+ if !strings.Contains(content, customBuildMarker) {
|
||||
+ t.Fatalf("embedded GUI assets do not contain custom build marker %q", customBuildMarker)
|
||||
+ }
|
||||
+}
|
||||
Reference in New Issue
Block a user