build: clear Go cache between platform builds in release script

In this commit, we add a call to "go clean -cache" after each platform
build in the release script to prevent the Go build cache from accumulating
unbounded disk space during the sequential 15-platform build process.

When building for multiple platforms in sequence with "go build -v", Go
creates intermediate build artifacts and caches compiled packages for each
target platform. While this caching improves build performance within a
single platform build, it causes the cache to grow substantially when
building for many platforms sequentially. With 15 different platform/
architecture combinations, each with their own cached artifacts, this
accumulation was contributing to the disk space exhaustion.

By clearing the build cache after each platform completes, we prevent this
unbounded growth while still allowing each individual platform build to
benefit from caching during its own compilation. The module cache is
preserved (we only clear the build cache), so dependencies don't need to be
re-downloaded between platforms.
This commit is contained in:
Olaoluwa Osuntokun
2025-10-20 15:58:56 +01:00
parent b82ed88be5
commit dfee57023c

View File

@@ -193,6 +193,9 @@ required Go version ($goversion)."
env CGO_ENABLED=0 GOOS=$os GOARCH=$arch GOARM=$arm go build -v -trimpath -ldflags="${ldflags}" -tags="${buildtags}" ${PKG}/cmd/lncli
popd
# Clear Go build cache to prevent disk space issues during multi-platform builds.
go clean -cache
# Add the hashes for the individual binaries as well for easy verification
# of a single installed binary.
shasum -a 256 "${dir}/"* >> "manifest-$tag.txt"