Skip to content

Commit 1b73eb3

Browse files
committed
add makefile for releases
1 parent 55eb0ae commit 1b73eb3

3 files changed

Lines changed: 45 additions & 0 deletions

File tree

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
opencode-litellm-config
2+
dist/

Makefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
BINARY := opencode-litellm-config
2+
VERSION ?= $(shell git describe --tags --always)
3+
DIST := dist
4+
5+
PLATFORMS := linux/amd64 darwin/amd64 darwin/arm64 windows/amd64
6+
7+
.PHONY: build-all checksums release clean
8+
9+
build-all: clean
10+
@mkdir -p $(DIST)
11+
@for platform in $(PLATFORMS); do \
12+
os=$${platform%/*}; \
13+
arch=$${platform#*/}; \
14+
output=$(DIST)/$(BINARY)-$$os-$$arch; \
15+
if [ "$$os" = "windows" ]; then output=$$output.exe; fi; \
16+
echo "Building $$os/$$arch..."; \
17+
CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch go build -ldflags "-X main.version=$(VERSION)" -o $$output .; \
18+
done
19+
20+
checksums: build-all
21+
@cd $(DIST) && sha256sum * > checksums.txt
22+
@echo "Checksums written to $(DIST)/checksums.txt"
23+
24+
release:
25+
ifndef VERSION
26+
$(error VERSION is required. Usage: make release VERSION=0.1.0)
27+
endif
28+
@if git rev-parse v$(VERSION) >/dev/null 2>&1; then \
29+
echo "Error: tag v$(VERSION) already exists"; \
30+
exit 1; \
31+
fi
32+
$(MAKE) checksums VERSION=$(VERSION)
33+
git tag v$(VERSION)
34+
git push origin v$(VERSION)
35+
gh release create v$(VERSION) $(DIST)/* --generate-notes --title "v$(VERSION)"
36+
37+
clean:
38+
rm -rf $(DIST)

main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import (
1010
"time"
1111
)
1212

13+
var version = "dev"
14+
1315
const usage = `Usage: %s [flags] <output-file>
1416
1517
Generates OpenCode config from LiteLLM models endpoint.
@@ -63,6 +65,10 @@ type Config struct {
6365
}
6466

6567
func main() {
68+
if len(os.Args) > 1 && (os.Args[1] == "--version" || os.Args[1] == "-v") {
69+
fmt.Println(version)
70+
os.Exit(0)
71+
}
6672
cfg := parseFlags()
6773
apiKey := requireEnvVar("DIUS_LITELLM_SK")
6874
models := fetchModels(cfg.baseURL, apiKey)

0 commit comments

Comments
 (0)