Просмотр исходного кода

Merge branch 'main' into v2

* main:
  docs: link to Docker image, APT, in release notes
  build: also create relaysrv and discosrv releases
  fix(stupgrades): return latest stable & pre for each major
  fix(syncthing): avoid writing panic log to nil fd (#10154)
Jakob Borg 6 месяцев назад
Родитель
Сommit
706409d2f3
5 измененных файлов с 74 добавлено и 38 удалено
  1. 19 5
      .github/workflows/build-syncthing.yaml
  2. 11 7
      cmd/infra/stupgrades/main.go
  3. 23 25
      cmd/syncthing/monitor.go
  4. 7 0
      relnotes/v1.md
  5. 14 1
      script/relnotes.go

+ 19 - 5
.github/workflows/build-syncthing.yaml

@@ -806,7 +806,7 @@ jobs:
         with:
           args: sync -v objstore:release/${{ env.VERSION }} objstore:release/latest
 
-      - name: Create GitHub release and push binaries
+      - name: Create GitHub releases and push binaries
         run: |
           maybePrerelease=""
           if [[ $VERSION == *-* ]]; then
@@ -814,8 +814,7 @@ jobs:
           fi
           export GH_PROMPT_DISABLED=1
           if ! gh release view --json name "$VERSION" >/dev/null 2>&1 ; then
-            gh release create \
-              "$VERSION" \
+            gh release create "$VERSION" \
               $maybePrerelease \
               --title "$VERSION" \
               --notes-from-tag
@@ -824,9 +823,24 @@ jobs:
             packages/*.asc packages/*.json \
             packages/syncthing-*.tar.gz \
             packages/syncthing-*.zip \
-            packages/syncthing*.deb
+            packages/syncthing_*.deb
+
+          PKGS=$(pwd)/packages
+          cd /tmp # gh will not release for repo x while inside repo y
+          for repo in relaysrv discosrv ; do
+            export GH_REPO="syncthing/$repo"
+            if ! gh release view --json name "$VERSION" >/dev/null 2>&1 ; then
+              gh release create "$VERSION" \
+                $maybePrerelease \
+                --title "$VERSION" \
+                --notes "https://github.com/syncthing/syncthing/releases/tag/$VERSION"
+            fi
+            gh release upload "$VERSION" \
+              $PKGS/*.asc \
+              $PKGS/*${repo}*
+          done
         env:
-          GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+          GH_TOKEN: ${{ secrets.ACTIONS_GITHUB_TOKEN }}
 
   #
   # Push Debian/APT archive

+ 11 - 7
cmd/infra/stupgrades/main.go

@@ -201,17 +201,21 @@ func (p *proxy) ServeHTTP(w http.ResponseWriter, req *http.Request) {
 // looking for a prerelease at all.
 func filterForLatest(rels []upgrade.Release) []upgrade.Release {
 	var filtered []upgrade.Release
-	var havePre bool
+	havePre := make(map[string]bool)
+	haveStable := make(map[string]bool)
 	for _, rel := range rels {
-		if !rel.Prerelease {
-			// We found a stable version, we're good now.
+		major, _, _ := strings.Cut(rel.Tag, ".")
+		if !rel.Prerelease && !haveStable[major] {
+			// Remember the first non-pre for each major
 			filtered = append(filtered, rel)
-			break
+			haveStable[major] = true
+			continue
 		}
-		if rel.Prerelease && !havePre {
-			// We remember the first prerelease we find.
+		if rel.Prerelease && !havePre[major] && !haveStable[major] {
+			// We remember the first prerelease we find, unless we've
+			// already found a non-pre of the same major.
 			filtered = append(filtered, rel)
-			havePre = true
+			havePre[major] = true
 		}
 	}
 	return filtered

+ 23 - 25
cmd/syncthing/monitor.go

@@ -238,19 +238,18 @@ func copyStderr(stderr io.Reader, dst io.Writer) {
 			return
 		}
 
-		if panicFd == nil {
-			dst.Write([]byte(line))
-
-			if strings.HasPrefix(line, "panic:") || strings.HasPrefix(line, "fatal error:") {
-				panicFd, err = os.Create(locations.GetTimestamped(locations.PanicLog))
-				if err != nil {
-					l.Warnln("Create panic log:", err)
-					continue
-				}
+		dst.Write([]byte(line))
 
-				l.Warnf("Panic detected, writing to \"%s\"", panicFd.Name())
-				if strings.Contains(line, "leveldb") && strings.Contains(line, "corrupt") {
-					l.Warnln(`
+		if panicFd == nil && (strings.HasPrefix(line, "panic:") || strings.HasPrefix(line, "fatal error:")) {
+			panicFd, err = os.Create(locations.GetTimestamped(locations.PanicLog))
+			if err != nil {
+				l.Warnln("Create panic log:", err)
+				continue
+			}
+
+			l.Warnf("Panic detected, writing to \"%s\"", panicFd.Name())
+			if strings.Contains(line, "leveldb") && strings.Contains(line, "corrupt") {
+				l.Warnln(`
 *********************************************************************************
 * Crash due to corrupt database.                                                *
 *                                                                               *
@@ -263,21 +262,20 @@ func copyStderr(stderr io.Reader, dst io.Writer) {
 *   https://docs.syncthing.net/users/faq.html#my-syncthing-database-is-corrupt  *
 *********************************************************************************
 `)
-				} else {
-					l.Warnln("Please check for existing issues with similar panic message at https://github.com/syncthing/syncthing/issues/")
-					l.Warnln("If no issue with similar panic message exists, please create a new issue with the panic log attached")
-				}
+			} else {
+				l.Warnln("Please check for existing issues with similar panic message at https://github.com/syncthing/syncthing/issues/")
+				l.Warnln("If no issue with similar panic message exists, please create a new issue with the panic log attached")
+			}
 
-				stdoutMut.Lock()
-				for _, line := range stdoutFirstLines {
-					panicFd.WriteString(line)
-				}
-				panicFd.WriteString("...\n")
-				for _, line := range stdoutLastLines {
-					panicFd.WriteString(line)
-				}
-				stdoutMut.Unlock()
+			stdoutMut.Lock()
+			for _, line := range stdoutFirstLines {
+				panicFd.WriteString(line)
+			}
+			panicFd.WriteString("...\n")
+			for _, line := range stdoutLastLines {
+				panicFd.WriteString(line)
 			}
+			stdoutMut.Unlock()
 
 			panicFd.WriteString("Panic at " + time.Now().Format(time.RFC3339) + "\n")
 		}

+ 7 - 0
relnotes/v1.md

@@ -6,3 +6,10 @@ protocol compatible with Syncthing 1.
 
 More detailed information about Syncthing 2 can be found in the release
 notes at https://github.com/syncthing/syncthing/releases.
+
+This release is also available as:
+
+* APT repository: https://apt.syncthing.net/
+
+* Docker image: `docker.io/syncthing/syncthing:{{.version}}` or `ghcr.io/syncthing/syncthing:{{.version}}`
+  (`{docker,ghcr}.io/syncthing/syncthing:1` to follow just the major version)

+ 14 - 1
script/relnotes.go

@@ -22,6 +22,7 @@ import (
 	"os"
 	"regexp"
 	"strings"
+	"text/template"
 )
 
 var (
@@ -59,12 +60,24 @@ func main() {
 
 // Load potential additional release notes from within the repo
 func additionalNotes(newVer string) ([]string, error) {
+	data := map[string]string{
+		"version": strings.TrimLeft(newVer, "v"),
+	}
+
 	var notes []string
 	ver, _, _ := strings.Cut(newVer, "-")
 	for {
 		file := fmt.Sprintf("relnotes/%s.md", ver)
 		if bs, err := os.ReadFile(file); err == nil {
-			notes = append(notes, strings.TrimSpace(string(bs)))
+			tpl, err := template.New("notes").Parse(string(bs))
+			if err != nil {
+				return nil, err
+			}
+			buf := new(bytes.Buffer)
+			if err := tpl.Execute(buf, data); err != nil {
+				return nil, err
+			}
+			notes = append(notes, strings.TrimSpace(buf.String()))
 		} else if !os.IsNotExist(err) {
 			return nil, err
 		}