From add4de22bb028b6558ac52f29199f23e2aeeae97 Mon Sep 17 00:00:00 2001 From: Brennen Smith Date: Thu, 20 Nov 2025 11:19:52 -0800 Subject: [PATCH 1/5] CE-989 - runpodctl receive fails with a custom set tag --- cmd/croc/receive.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/croc/receive.go b/cmd/croc/receive.go index 7baa0d4..58100d4 100644 --- a/cmd/croc/receive.go +++ b/cmd/croc/receive.go @@ -48,22 +48,26 @@ var ReceiveCmd = &cobra.Command{ } sharedSecretCode := args[0] split := strings.Split(sharedSecretCode, "-") - if len(split) < 5 { - log.Fatalf("Malformed code %q: expected 5 parts separated by dashes, but got %v", sharedSecretCode, len(split)) + if len(split) < 2 { + log.Fatalf("Malformed code %q: expected at least 2 parts separated by dashes, but got %v. Please retry 'runpodctl send' to generate a valid code.", sharedSecretCode, len(split)) } - relayIndex, err := strconv.Atoi(split[4]) // relay index + relayIndex, err := strconv.Atoi(split[len(split)-1]) // relay index is the final split value if err != nil { - log.Fatalf("Malformed relay, please try again.") + log.Fatalf("Malformed relay, please retry 'runpodctl send' to generate a valid code.") } + if relayIndex < 0 || relayIndex >= len(relays) { + log.Fatalf("Relay index %d not found; please retry 'runpodctl send' to generate a valid code.", relayIndex) + return + } relay := relays[relayIndex] crocOptions := croc.Options{ Curve: "p256", Debug: false, IsSender: false, - NoPrompt: true, + NoPrompt: true, Overwrite: true, RelayAddress: relay.Address, RelayPassword: relay.Password, From 5a6e6ca00f597f744ebee4fda2775a79a47b6e65 Mon Sep 17 00:00:00 2001 From: Brennen Smith Date: Thu, 20 Nov 2025 11:21:25 -0800 Subject: [PATCH 2/5] CE-990 - runpodctl-uses-hardcoded-version-file --- .goreleaser.yml | 6 ++++-- main.go | 10 +++++++--- makefile | 47 +++++++++++++++++++++++++++-------------------- version | 1 - 4 files changed, 38 insertions(+), 26 deletions(-) delete mode 100644 version diff --git a/.goreleaser.yml b/.goreleaser.yml index c68e101..3b2f29b 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -6,6 +6,8 @@ builds: goarch: [amd64, arm64] env: [CGO_ENABLED=0] flags: [-mod=mod] + ldflags: + - -s -w -X main.Version={{ .Version }}-{{ .Github.sha }} release: prerelease: auto @@ -20,8 +22,8 @@ brews: owner: runpod name: homebrew-runpodctl commit_author: - name: rachfop - email: prachford@icloud.com + name: runpod + email: support@runpod.io checksum: name_template: "checksums.txt" diff --git a/main.go b/main.go index f73df96..57ad0d6 100644 --- a/main.go +++ b/main.go @@ -1,15 +1,19 @@ package main import ( - _ "embed" "strings" "github.com/runpod/runpodctl/cmd" ) -//go:embed version +// Version is set at build time via ldflags (see makefile and .goreleaser.yml) +// If not set, falls back to "dev" var Version string func main() { - cmd.Execute(strings.TrimRight(Version, "\r\n")) + version := Version + if version == "" { + version = "local-dev" + } + cmd.Execute(strings.TrimRight(version, "\r\n")) } diff --git a/makefile b/makefile index 8bdcad4..9324c80 100644 --- a/makefile +++ b/makefile @@ -1,8 +1,8 @@ .PHONY: proto - -local: version - go build -o bin/runpodctl . +local: + @COMMIT=$$(git rev-parse HEAD 2>/dev/null || echo "unknown"); \ + go build -mod=mod -ldflags "-s -w -X main.Version=dev-$$COMMIT" -o bin/runpodctl . release: buildall strip compress @@ -14,20 +14,27 @@ strip: strip bin/* || true -android-arm64: version - env GOOS=android GOARCH=arm64 go build -o bin/runpodctl-android-arm64 . -linux-amd64: version - env GOOS=linux GOARCH=amd64 go build -o bin/runpodctl-linux-amd64 . -darwin-arm64: version - env GOOS=darwin GOARCH=arm64 go build -o bin/runpodctl-darwin-arm64 . -windows-amd64: version - env GOOS=windows GOARCH=amd64 go build -o bin/runpodctl-windows-amd64.exe . -windows-arm64: version - env GOOS=windows GOARCH=arm64 go build -o bin/runpodctl-windows-arm64.exe . -darwin-amd64: version - env GOOS=darwin GOARCH=amd64 go build -o bin/runpodctl-darwin-amd64 . - -lint: version - golangci-lint run -version: - @test -f version || (echo "Error: version file not found" && exit 1) \ No newline at end of file +android-arm64: + @VERSION=$$(git describe --tags --exact-match HEAD 2>/dev/null || git describe --tags 2>/dev/null || echo "unknown"); \ + COMMIT=$$(git rev-parse HEAD 2>/dev/null || echo "unknown"); \ + env CGO_ENABLED=0 GOOS=android GOARCH=arm64 go build -mod=mod -ldflags "-s -w -X main.Version=$$VERSION-$$COMMIT" -o bin/runpodctl-android-arm64 . +linux-amd64: + @VERSION=$$(git describe --tags --exact-match HEAD 2>/dev/null || git describe --tags 2>/dev/null || echo "unknown"); \ + COMMIT=$$(git rev-parse HEAD 2>/dev/null || echo "unknown"); \ + env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -mod=mod -ldflags "-s -w -X main.Version=$$VERSION-$$COMMIT" -o bin/runpodctl-linux-amd64 . +darwin-arm64: + @VERSION=$$(git describe --tags --exact-match HEAD 2>/dev/null || git describe --tags 2>/dev/null || echo "unknown"); \ + COMMIT=$$(git rev-parse HEAD 2>/dev/null || echo "unknown"); \ + env CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -mod=mod -ldflags "-s -w -X main.Version=$$VERSION-$$COMMIT" -o bin/runpodctl-darwin-arm64 . +windows-amd64: + @VERSION=$$(git describe --tags --exact-match HEAD 2>/dev/null || git describe --tags 2>/dev/null || echo "unknown"); \ + COMMIT=$$(git rev-parse HEAD 2>/dev/null || echo "unknown"); \ + env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -mod=mod -ldflags "-s -w -X main.Version=$$VERSION-$$COMMIT" -o bin/runpodctl-windows-amd64.exe . +windows-arm64: + @VERSION=$$(git describe --tags --exact-match HEAD 2>/dev/null || git describe --tags 2>/dev/null || echo "unknown"); \ + COMMIT=$$(git rev-parse HEAD 2>/dev/null || echo "unknown"); \ + env CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -mod=mod -ldflags "-s -w -X main.Version=$$VERSION-$$COMMIT" -o bin/runpodctl-windows-arm64.exe . +darwin-amd64: + @VERSION=$$(git describe --tags --exact-match HEAD 2>/dev/null || git describe --tags 2>/dev/null || echo "unknown"); \ + COMMIT=$$(git rev-parse HEAD 2>/dev/null || echo "unknown"); \ + env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -mod=mod -ldflags "-s -w -X main.Version=$$VERSION-$$COMMIT" -o bin/runpodctl-darwin-amd64 . \ No newline at end of file diff --git a/version b/version deleted file mode 100644 index 3afb685..0000000 --- a/version +++ /dev/null @@ -1 +0,0 @@ -v1.14.11 From 1822544d578a136b7a2ba03f30c078e990a94e14 Mon Sep 17 00:00:00 2001 From: Brennen Smith Date: Thu, 20 Nov 2025 11:38:41 -0800 Subject: [PATCH 3/5] dry out the git commands --- makefile | 47 ++++++++++++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 21 deletions(-) diff --git a/makefile b/makefile index 9324c80..7d400fd 100644 --- a/makefile +++ b/makefile @@ -1,7 +1,11 @@ .PHONY: proto +# Build configuration +VERSION = git describe --tags --exact-match HEAD 2>/dev/null || git describe --tags 2>/dev/null || echo "unknown" +COMMIT = git rev-parse HEAD 2>/dev/null || echo "unknown" + local: - @COMMIT=$$(git rev-parse HEAD 2>/dev/null || echo "unknown"); \ + @COMMIT=$$($(COMMIT)); \ go build -mod=mod -ldflags "-s -w -X main.Version=dev-$$COMMIT" -o bin/runpodctl . release: buildall strip compress @@ -10,31 +14,32 @@ buildall: android-arm64 linux-amd64 darwin-arm64 windows-amd64 windows-arm64 dar compress: upx --best bin/* || true + strip: strip bin/* || true - +# Generic build function +define build-target + @VERSION=$$($(VERSION)); \ + COMMIT=$$($(COMMIT)); \ + env CGO_ENABLED=0 GOOS=$(1) GOARCH=$(2) go build -mod=mod -ldflags "-s -w -X main.Version=$$VERSION-$$COMMIT" -o bin/runpodctl-$(1)-$(2)$(3) . +endef + +# Platform-specific targets android-arm64: - @VERSION=$$(git describe --tags --exact-match HEAD 2>/dev/null || git describe --tags 2>/dev/null || echo "unknown"); \ - COMMIT=$$(git rev-parse HEAD 2>/dev/null || echo "unknown"); \ - env CGO_ENABLED=0 GOOS=android GOARCH=arm64 go build -mod=mod -ldflags "-s -w -X main.Version=$$VERSION-$$COMMIT" -o bin/runpodctl-android-arm64 . + $(call build-target,android,arm64,) + linux-amd64: - @VERSION=$$(git describe --tags --exact-match HEAD 2>/dev/null || git describe --tags 2>/dev/null || echo "unknown"); \ - COMMIT=$$(git rev-parse HEAD 2>/dev/null || echo "unknown"); \ - env CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -mod=mod -ldflags "-s -w -X main.Version=$$VERSION-$$COMMIT" -o bin/runpodctl-linux-amd64 . + $(call build-target,linux,amd64,) + darwin-arm64: - @VERSION=$$(git describe --tags --exact-match HEAD 2>/dev/null || git describe --tags 2>/dev/null || echo "unknown"); \ - COMMIT=$$(git rev-parse HEAD 2>/dev/null || echo "unknown"); \ - env CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -mod=mod -ldflags "-s -w -X main.Version=$$VERSION-$$COMMIT" -o bin/runpodctl-darwin-arm64 . + $(call build-target,darwin,arm64,) + +darwin-amd64: + $(call build-target,darwin,amd64,) + windows-amd64: - @VERSION=$$(git describe --tags --exact-match HEAD 2>/dev/null || git describe --tags 2>/dev/null || echo "unknown"); \ - COMMIT=$$(git rev-parse HEAD 2>/dev/null || echo "unknown"); \ - env CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -mod=mod -ldflags "-s -w -X main.Version=$$VERSION-$$COMMIT" -o bin/runpodctl-windows-amd64.exe . + $(call build-target,windows,amd64,.exe) + windows-arm64: - @VERSION=$$(git describe --tags --exact-match HEAD 2>/dev/null || git describe --tags 2>/dev/null || echo "unknown"); \ - COMMIT=$$(git rev-parse HEAD 2>/dev/null || echo "unknown"); \ - env CGO_ENABLED=0 GOOS=windows GOARCH=arm64 go build -mod=mod -ldflags "-s -w -X main.Version=$$VERSION-$$COMMIT" -o bin/runpodctl-windows-arm64.exe . -darwin-amd64: - @VERSION=$$(git describe --tags --exact-match HEAD 2>/dev/null || git describe --tags 2>/dev/null || echo "unknown"); \ - COMMIT=$$(git rev-parse HEAD 2>/dev/null || echo "unknown"); \ - env CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -mod=mod -ldflags "-s -w -X main.Version=$$VERSION-$$COMMIT" -o bin/runpodctl-darwin-amd64 . \ No newline at end of file + $(call build-target,windows,arm64,.exe) \ No newline at end of file From 27fc82d4592e3f9f910f85d1a3ad1798a1c960fe Mon Sep 17 00:00:00 2001 From: Brennen Smith Date: Thu, 20 Nov 2025 11:39:01 -0800 Subject: [PATCH 4/5] dry out the git commands --- makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makefile b/makefile index 7d400fd..05ad86e 100644 --- a/makefile +++ b/makefile @@ -1,6 +1,6 @@ .PHONY: proto -# Build configuration +# Git version and commit VERSION = git describe --tags --exact-match HEAD 2>/dev/null || git describe --tags 2>/dev/null || echo "unknown" COMMIT = git rev-parse HEAD 2>/dev/null || echo "unknown" From b34aa50753fea1693d41f101c9b6fe9de79a0f7a Mon Sep 17 00:00:00 2001 From: Brennen Smith Date: Fri, 21 Nov 2025 09:51:16 -0800 Subject: [PATCH 5/5] remove trailing whitespace and errant return --- cmd/croc/receive.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cmd/croc/receive.go b/cmd/croc/receive.go index 58100d4..11415b5 100644 --- a/cmd/croc/receive.go +++ b/cmd/croc/receive.go @@ -59,7 +59,6 @@ var ReceiveCmd = &cobra.Command{ if relayIndex < 0 || relayIndex >= len(relays) { log.Fatalf("Relay index %d not found; please retry 'runpodctl send' to generate a valid code.", relayIndex) - return } relay := relays[relayIndex] @@ -67,7 +66,7 @@ var ReceiveCmd = &cobra.Command{ Curve: "p256", Debug: false, IsSender: false, - NoPrompt: true, + NoPrompt: true, Overwrite: true, RelayAddress: relay.Address, RelayPassword: relay.Password,