mirror of
https://github.com/henrygd/beszel.git
synced 2026-08-19 08:47:46 +02:00
fix(release): avoid duplicate ARM archives (#1884)
This commit is contained in:
@@ -22,9 +22,6 @@ builds:
|
|||||||
- amd64
|
- amd64
|
||||||
- arm64
|
- arm64
|
||||||
- arm
|
- arm
|
||||||
goarm:
|
|
||||||
- "6"
|
|
||||||
- "7"
|
|
||||||
ignore:
|
ignore:
|
||||||
- goos: windows
|
- goos: windows
|
||||||
goarch: arm64
|
goarch: arm64
|
||||||
@@ -42,6 +39,8 @@ builds:
|
|||||||
main: internal/cmd/agent/agent.go
|
main: internal/cmd/agent/agent.go
|
||||||
env:
|
env:
|
||||||
- CGO_ENABLED=0
|
- CGO_ENABLED=0
|
||||||
|
ldflags:
|
||||||
|
- -s -w -X github.com/henrygd/beszel/internal/ghupdate.buildGOARM={{ .Arm }}
|
||||||
goos:
|
goos:
|
||||||
- linux
|
- linux
|
||||||
- darwin
|
- darwin
|
||||||
@@ -108,6 +107,7 @@ archives:
|
|||||||
{{ .Binary }}_
|
{{ .Binary }}_
|
||||||
{{- .Os }}_
|
{{- .Os }}_
|
||||||
{{- .Arch }}
|
{{- .Arch }}
|
||||||
|
{{- if ne .Arm "6" }}{{ with .Arm }}v{{ . }}{{ end }}{{ end }}
|
||||||
format_overrides:
|
format_overrides:
|
||||||
- goos: windows
|
- goos: windows
|
||||||
formats: [zip]
|
formats: [zip]
|
||||||
|
|||||||
@@ -30,6 +30,10 @@ const (
|
|||||||
colorGray = "\033[90m"
|
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) {
|
func ColorPrint(color, text string) {
|
||||||
fmt.Println(color + text + colorReset)
|
fmt.Println(color + text + colorReset)
|
||||||
}
|
}
|
||||||
@@ -129,7 +133,7 @@ func (p *updater) update() (updated bool, err error) {
|
|||||||
return false, nil
|
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)
|
asset, err := latest.findAssetBySuffix(suffix)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, err
|
return false, err
|
||||||
@@ -346,7 +350,7 @@ func copyFile(src, dst string) error {
|
|||||||
return destFile.Chmod(sourceInfo.Mode())
|
return destFile.Chmod(sourceInfo.Mode())
|
||||||
}
|
}
|
||||||
|
|
||||||
func archiveSuffix(binaryName, goos, goarch string) string {
|
func archiveSuffix(binaryName, goos, goarch, goarm string) string {
|
||||||
if goos == "windows" {
|
if goos == "windows" {
|
||||||
return fmt.Sprintf("%s_%s_%s.zip", binaryName, goos, goarch)
|
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() {
|
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_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 {
|
func isGlibc() bool {
|
||||||
|
|||||||
@@ -8,6 +8,31 @@ import (
|
|||||||
"testing"
|
"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) {
|
func TestReleaseFindAssetBySuffix(t *testing.T) {
|
||||||
r := release{
|
r := release{
|
||||||
Assets: []*releaseAsset{
|
Assets: []*releaseAsset{
|
||||||
|
|||||||
@@ -215,9 +215,15 @@ detect_architecture() {
|
|||||||
x86_64)
|
x86_64)
|
||||||
arch="amd64"
|
arch="amd64"
|
||||||
;;
|
;;
|
||||||
armv6l|armv7l)
|
armv5*)
|
||||||
|
arch="armv5"
|
||||||
|
;;
|
||||||
|
armv6l)
|
||||||
arch="arm"
|
arch="arm"
|
||||||
;;
|
;;
|
||||||
|
armv7l)
|
||||||
|
arch="armv7"
|
||||||
|
;;
|
||||||
aarch64)
|
aarch64)
|
||||||
arch="arm64"
|
arch="arm64"
|
||||||
;;
|
;;
|
||||||
|
|||||||
Reference in New Issue
Block a user