mirror of
https://github.com/henrygd/beszel.git
synced 2026-08-17 20:56:18 +00:00
fix(release): avoid duplicate ARM archives (#1884)
This commit is contained in:
+3
-3
@@ -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]
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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{
|
||||
|
||||
@@ -215,9 +215,15 @@ detect_architecture() {
|
||||
x86_64)
|
||||
arch="amd64"
|
||||
;;
|
||||
armv6l|armv7l)
|
||||
armv5*)
|
||||
arch="armv5"
|
||||
;;
|
||||
armv6l)
|
||||
arch="arm"
|
||||
;;
|
||||
armv7l)
|
||||
arch="armv7"
|
||||
;;
|
||||
aarch64)
|
||||
arch="arm64"
|
||||
;;
|
||||
|
||||
Reference in New Issue
Block a user