Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ archives:
checksum:
name_template: verda_{{ .Version }}_SHA256SUMS

changelog:
disable: true
# Release notes are provided by git-cliff via --release-notes flag.
# Do NOT set changelog.disable: true — it also ignores --release-notes.
14 changes: 11 additions & 3 deletions internal/verda-cli/cmd/version/verify.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,23 @@ func parseChecksumLine(line string) (hexStr, key string, ok bool) {
// findMatchingChecksum finds the expected hash for the given OS/arch from the
// checksum file body.
func findMatchingChecksum(body, goos, goarch string) (string, error) {
// The key format is: verda_<os>_<arch>/verda[.exe]
prefix := fmt.Sprintf("verda_%s_%s/", goos, goarch)
// GoReleaser dist directories include arch variant suffixes, e.g.:
// verda_darwin_arm64_v8.0/verda
// verda_linux_amd64_v1/verda
// Match "verda_<os>_<arch>" followed by "/" or "_" (variant suffix).
prefix := fmt.Sprintf("verda_%s_%s", goos, goarch)

for _, line := range strings.Split(body, "\n") {
hexStr, key, ok := parseChecksumLine(line)
if !ok {
continue
}
if strings.HasPrefix(key, prefix) {
if !strings.HasPrefix(key, prefix) {
continue
}
// After the os_arch prefix, expect "/" or "_" (variant like _v8.0/)
rest := key[len(prefix):]
if rest != "" && (rest[0] == '/' || rest[0] == '_') {
return hexStr, nil
}
}
Expand Down
9 changes: 5 additions & 4 deletions internal/verda-cli/cmd/version/verify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,10 @@ func TestParseChecksumLine(t *testing.T) {
func TestFindMatchingChecksum(t *testing.T) {
t.Parallel()

body := `aaa111 verda_linux_amd64/verda
bbb222 verda_darwin_arm64/verda
ccc333 verda_windows_amd64/verda.exe
// GoReleaser dist directories include arch variant suffixes
body := `aaa111 verda_linux_amd64_v1/verda
bbb222 verda_darwin_arm64_v8.0/verda
ccc333 verda_windows_amd64_v1/verda.exe
`

tests := []struct {
Expand Down Expand Up @@ -256,7 +257,7 @@ func TestVerifyBinaryMatch(t *testing.T) {

goos := runtime.GOOS
goarch := runtime.GOARCH
checksumBody := fmt.Sprintf("%s verda_%s_%s/verda\n", expectedHash, goos, goarch)
checksumBody := fmt.Sprintf("%s verda_%s_%s_v1/verda\n", expectedHash, goos, goarch)

srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_, _ = fmt.Fprint(w, checksumBody)
Expand Down
Loading