fix(release): avoid duplicate ARM archives (#1884)

This commit is contained in:
henrygd
2026-08-17 16:49:59 -04:00
parent 19f250c7de
commit 2054b276a7
4 changed files with 46 additions and 7 deletions
+3 -3
View File
@@ -22,9 +22,6 @@ builds:
- amd64
- arm64
- arm
goarm:
- "6"
- "7"
ignore:
- goos: windows
goarch: arm64
@@ -42,6 +39,8 @@ builds:
main: internal/cmd/agent/agent.go
env:
- CGO_ENABLED=0
ldflags:
- -s -w -X github.com/henrygd/beszel/internal/ghupdate.buildGOARM={{ .Arm }}
goos:
- linux
- darwin
@@ -108,6 +107,7 @@ archives:
{{ .Binary }}_
{{- .Os }}_
{{- .Arch }}
{{- if ne .Arm "6" }}{{ with .Arm }}v{{ . }}{{ end }}{{ end }}
format_overrides:
- goos: windows
formats: [zip]
+11 -3
View File
@@ -30,6 +30,10 @@ const (
colorGray = "\033[90m"
)
// buildGOARM is set by GoReleaser for agent builds. An empty value identifies
// legacy builds, which used GoReleaser's default GOARM value (ARMv6).
var buildGOARM string
func ColorPrint(color, text string) {
fmt.Println(color + text + colorReset)
}
@@ -129,7 +133,7 @@ func (p *updater) update() (updated bool, err error) {
return false, nil
}
suffix := archiveSuffix(p.config.ArchiveExecutable, runtime.GOOS, runtime.GOARCH)
suffix := archiveSuffix(p.config.ArchiveExecutable, runtime.GOOS, runtime.GOARCH, buildGOARM)
asset, err := latest.findAssetBySuffix(suffix)
if err != nil {
return false, err
@@ -346,7 +350,7 @@ func copyFile(src, dst string) error {
return destFile.Chmod(sourceInfo.Mode())
}
func archiveSuffix(binaryName, goos, goarch string) string {
func archiveSuffix(binaryName, goos, goarch, goarm string) string {
if goos == "windows" {
return fmt.Sprintf("%s_%s_%s.zip", binaryName, goos, goarch)
}
@@ -354,7 +358,11 @@ func archiveSuffix(binaryName, goos, goarch string) string {
if binaryName == "beszel-agent" && goos == "linux" && goarch == "amd64" && isGlibc() {
return fmt.Sprintf("%s_%s_%s_glibc.tar.gz", binaryName, goos, goarch)
}
return fmt.Sprintf("%s_%s_%s.tar.gz", binaryName, goos, goarch)
armSuffix := ""
if binaryName == "beszel-agent" && goarch == "arm" && (goarm == "5" || goarm == "7") {
armSuffix = "v" + goarm
}
return fmt.Sprintf("%s_%s_%s%s.tar.gz", binaryName, goos, goarch, armSuffix)
}
func isGlibc() bool {
+25
View File
@@ -8,6 +8,31 @@ import (
"testing"
)
func TestArchiveSuffix(t *testing.T) {
tests := []struct {
name string
binary, goos, goarch string
goarm, want string
}{
{"armv5 agent", "beszel-agent", "linux", "arm", "5", "beszel-agent_linux_armv5.tar.gz"},
{"armv6 keeps legacy name", "beszel-agent", "linux", "arm", "6", "beszel-agent_linux_arm.tar.gz"},
{"hub keeps legacy arm name", "beszel", "linux", "arm", "6", "beszel_linux_arm.tar.gz"},
{"armv7 agent", "beszel-agent", "linux", "arm", "7", "beszel-agent_linux_armv7.tar.gz"},
{"newer arm keeps legacy name", "beszel-agent", "linux", "arm", "8", "beszel-agent_linux_arm.tar.gz"},
{"unknown arm keeps legacy name", "beszel-agent", "linux", "arm", "", "beszel-agent_linux_arm.tar.gz"},
{"amd64 hub", "beszel", "linux", "amd64", "", "beszel_linux_amd64.tar.gz"},
{"windows", "beszel-agent", "windows", "amd64", "", "beszel-agent_windows_amd64.zip"},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := archiveSuffix(tt.binary, tt.goos, tt.goarch, tt.goarm); got != tt.want {
t.Errorf("archiveSuffix() = %q, want %q", got, tt.want)
}
})
}
}
func TestReleaseFindAssetBySuffix(t *testing.T) {
r := release{
Assets: []*releaseAsset{
+7 -1
View File
@@ -215,9 +215,15 @@ detect_architecture() {
x86_64)
arch="amd64"
;;
armv6l|armv7l)
armv5*)
arch="armv5"
;;
armv6l)
arch="arm"
;;
armv7l)
arch="armv7"
;;
aarch64)
arch="arm64"
;;