From e9266d467e1edd183f1d9f70b280b03ae250027d Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Thu, 5 Mar 2026 15:28:35 +0100 Subject: [PATCH 1/6] (Debug) bundle timestamps --- server/cmd/server.go | 1 + 1 file changed, 1 insertion(+) diff --git a/server/cmd/server.go b/server/cmd/server.go index ba29fbaa..bd32c0f8 100644 --- a/server/cmd/server.go +++ b/server/cmd/server.go @@ -175,6 +175,7 @@ func buildConfig(bundledFiles fs.FS, args []string) *server.ServerConfig { bundlePathDate = stat.ModTime() } } + log.Printf("Determined bundle path change date: %s, %d", bundlePathDate, bundlePathDate.UnixMilli()) serverConfig.ClientBundle = server.NewReadOnlyFallthroughSpacePrimitives(bundledFiles, "client", bundlePathDate, nil) rootSpaceConfig.SpacePrimitives = server.NewReadOnlyFallthroughSpacePrimitives(bundledFiles, "base_fs", bundlePathDate, spacePrimitives) From 19483e8687c88ce07835f5b9fe9489709a26e3f0 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Thu, 5 Mar 2026 16:03:25 +0100 Subject: [PATCH 2/6] Attempting to determine the build time in a more reliable way --- .github/workflows/edge.yml | 25 +------------------------ .github/workflows/server.yml | 25 +------------------------ Makefile | 18 ++++++++++++++---- server/cmd/server.go | 20 ++++++++++++-------- silverbullet.go | 5 ++++- 5 files changed, 32 insertions(+), 61 deletions(-) diff --git a/.github/workflows/edge.yml b/.github/workflows/edge.yml index 7e9d427e..5b15c2a6 100644 --- a/.github/workflows/edge.yml +++ b/.github/workflows/edge.yml @@ -23,30 +23,7 @@ jobs: deno task build-production deno task build-plug-compile - name: Build Go binaries for multiple platforms - run: | - # Linux ARM64 - GOOS=linux GOARCH=arm64 go build -o silverbullet . - zip silverbullet-server-linux-aarch64.zip silverbullet - - # Linux x86_64 - GOOS=linux GOARCH=amd64 go build -o silverbullet . - zip silverbullet-server-linux-x86_64.zip silverbullet - - # macOS ARM64 - GOOS=darwin GOARCH=arm64 go build -o silverbullet . - zip silverbullet-server-darwin-aarch64.zip silverbullet - - # macOS x86_64 - GOOS=darwin GOARCH=amd64 go build -o silverbullet . - zip silverbullet-server-darwin-x86_64.zip silverbullet - - # Windows x86_64 - GOOS=windows GOARCH=amd64 go build -o silverbullet.exe . - zip silverbullet-server-windows-x86_64.zip silverbullet.exe - - # FreeBSD x86_64 - GOOS=freebsd GOARCH=amd64 go build -o silverbullet . - zip silverbullet-server-freebsd-x86_64.zip silverbullet + run: make build-server-releases - name: Update edge release uses: softprops/action-gh-release@v1 diff --git a/.github/workflows/server.yml b/.github/workflows/server.yml index 5b2fc36f..0c3bcdce 100644 --- a/.github/workflows/server.yml +++ b/.github/workflows/server.yml @@ -23,30 +23,7 @@ jobs: deno task build-production deno task build-plug-compile - name: Build Go binaries for multiple platforms - run: | - # Linux ARM64 - GOOS=linux GOARCH=arm64 go build -o silverbullet . - zip silverbullet-server-linux-aarch64.zip silverbullet - - # Linux x86_64 - GOOS=linux GOARCH=amd64 go build -o silverbullet . - zip silverbullet-server-linux-x86_64.zip silverbullet - - # macOS ARM64 - GOOS=darwin GOARCH=arm64 go build -o silverbullet . - zip silverbullet-server-darwin-aarch64.zip silverbullet - - # macOS x86_64 - GOOS=darwin GOARCH=amd64 go build -o silverbullet . - zip silverbullet-server-darwin-x86_64.zip silverbullet - - # Windows x86_64 - GOOS=windows GOARCH=amd64 go build -o silverbullet.exe . - zip silverbullet-server-windows-x86_64.zip silverbullet.exe - - # FreeBSD x86_64 - GOOS=freebsd GOARCH=amd64 go build -o silverbullet . - zip silverbullet-server-freebsd-x86_64.zip silverbullet + run: make build-server-releases - name: Release uses: softprops/action-gh-release@v1 env: diff --git a/Makefile b/Makefile index cb029597..3838903e 100644 --- a/Makefile +++ b/Makefile @@ -1,21 +1,31 @@ +LDFLAGS = -X main.buildTime=$$(date -u +%Y-%m-%dT%H:%M:%SZ) + build: # Build client deno task build # Build plug-compile deno task build-plug-compile # Build server - go build + go build -ldflags "$(LDFLAGS)" build-for-docker: build - GOOS=linux GOARCH=arm64 go build -o silverbullet-arm64 . - GOOS=linux GOARCH=amd64 go build -o silverbullet-amd64 . + GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o silverbullet-arm64 . + GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o silverbullet-amd64 . docker: build-for-docker docker buildx build --platform linux/arm64,linux/amd64 --push . +build-server-releases: + GOOS=linux GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o silverbullet . && zip silverbullet-server-linux-aarch64.zip silverbullet + GOOS=linux GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o silverbullet . && zip silverbullet-server-linux-x86_64.zip silverbullet + GOOS=darwin GOARCH=arm64 go build -ldflags "$(LDFLAGS)" -o silverbullet . && zip silverbullet-server-darwin-aarch64.zip silverbullet + GOOS=darwin GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o silverbullet . && zip silverbullet-server-darwin-x86_64.zip silverbullet + GOOS=windows GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o silverbullet.exe . && zip silverbullet-server-windows-x86_64.zip silverbullet.exe + GOOS=freebsd GOARCH=amd64 go build -ldflags "$(LDFLAGS)" -o silverbullet . && zip silverbullet-server-freebsd-x86_64.zip silverbullet + clean: rm -rf client_bundle/{base_fs,client} dist public_version.ts - rm -f silverbullet silverbullet-arm64 silverbullet-amd64 + rm -f silverbullet silverbullet-arm64 silverbullet-amd64 silverbullet.exe silverbullet-server-*.zip check: # Frontend type check diff --git a/server/cmd/server.go b/server/cmd/server.go index bd32c0f8..27d15936 100644 --- a/server/cmd/server.go +++ b/server/cmd/server.go @@ -17,7 +17,7 @@ import ( "github.com/spf13/cobra" ) -func buildConfig(bundledFiles fs.FS, args []string) *server.ServerConfig { +func buildConfig(bundledFiles fs.FS, args []string, buildTime string) *server.ServerConfig { serverConfig := &server.ServerConfig{ BindHost: "127.0.0.1", Port: 3000, @@ -168,13 +168,17 @@ func buildConfig(bundledFiles fs.FS, args []string) *server.ServerConfig { } } - // Extract the last modified time from the main binary, best effort - bundlePathDate := time.Now() - if executablePath, err := os.Executable(); err == nil { - if stat, err := os.Stat(executablePath); err == nil { - bundlePathDate = stat.ModTime() + // Determine bundle timestamp from build-time injected value, fall back to current time + var bundlePathDate time.Time + if buildTime != "" { + if t, err := time.Parse(time.RFC3339, buildTime); err == nil { + bundlePathDate = t } } + if bundlePathDate.IsZero() { + log.Println("Couldn't determine build time of binary, falling back to current time stamp") + bundlePathDate = time.Now() + } log.Printf("Determined bundle path change date: %s, %d", bundlePathDate, bundlePathDate.UnixMilli()) serverConfig.ClientBundle = server.NewReadOnlyFallthroughSpacePrimitives(bundledFiles, "client", bundlePathDate, nil) @@ -232,7 +236,7 @@ func ensureIndexAndConfig(rootSpaceConfig *server.SpaceConfig) { } } -func ServerCommand(bundledFiles fs.FS, versionFileText string) *cobra.Command { +func ServerCommand(bundledFiles fs.FS, versionFileText string, buildTime string) *cobra.Command { var hostname string var port int var c = &cobra.Command{ @@ -243,7 +247,7 @@ func ServerCommand(bundledFiles fs.FS, versionFileText string) *cobra.Command { if version, err := server.ParseVersionFromTypeScript(versionFileText); err == nil { log.Printf("Starting SilverBullet version %s", version) } - serverConfig := buildConfig(bundledFiles, args) + serverConfig := buildConfig(bundledFiles, args, buildTime) if port != 3000 { serverConfig.Port = port } diff --git a/silverbullet.go b/silverbullet.go index a0fac44a..c128c55b 100644 --- a/silverbullet.go +++ b/silverbullet.go @@ -10,8 +10,11 @@ import ( //go:embed public_version.ts var VersionFileText string +// Set via LDFLAGS +var buildTime string + func main() { - c := cmd.ServerCommand(client_bundle.BundledFiles, VersionFileText) + c := cmd.ServerCommand(client_bundle.BundledFiles, VersionFileText, buildTime) c.AddCommand(cmd.VersionCommand(VersionFileText), cmd.UpgradeCommand(), cmd.UpgradeEdgeCommand()) c.Execute() } From 4b66106c2056af43ec1e6044ce3652a59b0b8625 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Thu, 5 Mar 2026 16:11:32 +0100 Subject: [PATCH 3/6] Reduce logging in common cases --- server/cmd/server.go | 1 - 1 file changed, 1 deletion(-) diff --git a/server/cmd/server.go b/server/cmd/server.go index 27d15936..f665688b 100644 --- a/server/cmd/server.go +++ b/server/cmd/server.go @@ -179,7 +179,6 @@ func buildConfig(bundledFiles fs.FS, args []string, buildTime string) *server.Se log.Println("Couldn't determine build time of binary, falling back to current time stamp") bundlePathDate = time.Now() } - log.Printf("Determined bundle path change date: %s, %d", bundlePathDate, bundlePathDate.UnixMilli()) serverConfig.ClientBundle = server.NewReadOnlyFallthroughSpacePrimitives(bundledFiles, "client", bundlePathDate, nil) rootSpaceConfig.SpacePrimitives = server.NewReadOnlyFallthroughSpacePrimitives(bundledFiles, "base_fs", bundlePathDate, spacePrimitives) From 91ecfcbd605cfca50159cc5843cd66b380f51700 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Thu, 5 Mar 2026 16:12:49 +0100 Subject: [PATCH 4/6] 2.5.1 --- deno.json | 2 +- version.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/deno.json b/deno.json index 7101ae34..d4498562 100644 --- a/deno.json +++ b/deno.json @@ -1,6 +1,6 @@ { "name": "@silverbulletmd/silverbullet", - "version": "2.5.0", + "version": "2.5.1", "tasks": { "build": "make clean && deno run -A build_plugs_libraries.ts && deno run -A build_client.ts", "build-production": "deno task build --production", diff --git a/version.ts b/version.ts index cb86341e..d2f8a9cd 100644 --- a/version.ts +++ b/version.ts @@ -1 +1 @@ -export const version = "2.5.0"; +export const version = "2.5.1"; From 06e4a4c7ed507a61440a890ce275b25d2dfe8ec5 Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Fri, 6 Mar 2026 08:20:45 +0100 Subject: [PATCH 5/6] Fixes #1869 --- client/markdown_renderer/inline.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/client/markdown_renderer/inline.ts b/client/markdown_renderer/inline.ts index ea6c6e64..16a4659d 100644 --- a/client/markdown_renderer/inline.ts +++ b/client/markdown_renderer/inline.ts @@ -66,7 +66,7 @@ export async function expandMarkdown( const result = await inlineContentFromURL(space, transclusion); // We don't transclude anything that's not markdown - if (typeof result !== "string") { + if (!("text" in result)) { return n; } @@ -74,7 +74,7 @@ export async function expandMarkdown( // it so we won't touch it down the line and cause endless recursion processedPages.add(transclusion.url); - const tree = parseMarkdown(result); + const tree = parseMarkdown(result.text); // Recursively process return expandMarkdown( From 9db8d822f7181ed4c8a2c6018a41df42ef98fbae Mon Sep 17 00:00:00 2001 From: Zef Hemel Date: Fri, 6 Mar 2026 08:31:53 +0100 Subject: [PATCH 6/6] Fixes #1850 --- plugs/index/refactor.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugs/index/refactor.ts b/plugs/index/refactor.ts index 4bc8411d..6147301e 100644 --- a/plugs/index/refactor.ts +++ b/plugs/index/refactor.ts @@ -220,7 +220,7 @@ async function renamePage(oldName: string, newName: string) { let newTail = text.substring(link.pos); // Only relative links need to be updated - if (/^[^/][^\]]+?(? if link has spaces @@ -448,7 +448,7 @@ async function updateBacklinks( for (const link of linksInPage) { let newTail = text.substring(link.pos); let newLink = newName; - if (/^[^\]]+?(?