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
6 changes: 4 additions & 2 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
11 changes: 7 additions & 4 deletions cmd/croc/receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,18 @@ 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)
}
relay := relays[relayIndex]

crocOptions := croc.Options{
Expand Down
10 changes: 7 additions & 3 deletions main.go
Original file line number Diff line number Diff line change
@@ -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"))
}
52 changes: 32 additions & 20 deletions makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,45 @@
.PHONY: proto

# 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"

local: version
go build -o bin/runpodctl .
local:
@COMMIT=$$($(COMMIT)); \
go build -mod=mod -ldflags "-s -w -X main.Version=dev-$$COMMIT" -o bin/runpodctl .

release: buildall strip compress

buildall: android-arm64 linux-amd64 darwin-arm64 windows-amd64 windows-arm64 darwin-amd64

compress:
upx --best bin/* || true

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)
# 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:
$(call build-target,android,arm64,)

linux-amd64:
$(call build-target,linux,amd64,)

darwin-arm64:
$(call build-target,darwin,arm64,)

darwin-amd64:
$(call build-target,darwin,amd64,)

windows-amd64:
$(call build-target,windows,amd64,.exe)

windows-arm64:
$(call build-target,windows,arm64,.exe)
1 change: 0 additions & 1 deletion version

This file was deleted.