add version flag and Gitea release targets

This commit is contained in:
Ein Anderssono
2026-06-11 20:32:08 +02:00
parent ca3a3e4a2a
commit 6002fda1f6
4 changed files with 53 additions and 9 deletions
+34 -9
View File
@@ -1,12 +1,18 @@
BINARY := ./bin/photoscli
MODULE := gitea.k3s.k0.nu/tools/photocli
BINARY := ./bin/photoscli
MODULE := gitea.k3s.k0.nu/tools/photocli
VERSION := 0.1.0
BRIDGE_DIR := bridge
OBJ := $(BRIDGE_DIR)/photokit_bridge.o
LIB := $(BRIDGE_DIR)/libphotokit_bridge.a
STUB_OBJ := $(BRIDGE_DIR)/photokit_bridge_stub.o
STUB_LIB := $(BRIDGE_DIR)/libphotokit_bridge_stub.a
LDFLAGS := -X main.version=$(VERSION)
OBJ := $(BRIDGE_DIR)/photokit_bridge.o
LIB := $(BRIDGE_DIR)/libphotokit_bridge.a
STUB_OBJ := $(BRIDGE_DIR)/photokit_bridge_stub.o
STUB_LIB := $(BRIDGE_DIR)/libphotokit_bridge_stub.a
GITEA_HOST := gitea-1.tail82444.ts.net
GITEA_REPO := tools/photocli
.PHONY: build clean test coverage
.PHONY: all build clean test coverage tag release
all: build
$(LIB): $(OBJ)
ar rcs $@ $<
@@ -21,7 +27,7 @@ $(STUB_OBJ): $(BRIDGE_DIR)/photokit_bridge_stub.c $(BRIDGE_DIR)/photokit_bridge.
cc -c -o $@ $<
build: $(LIB)
go build -o $(BINARY) $(MODULE)/cmd/photoscli
go build -ldflags "$(LDFLAGS)" -o $(BINARY) $(MODULE)/cmd/photoscli
test: $(STUB_LIB)
go test -tags=test -coverprofile=coverage.out -covermode=atomic -coverpkg=./... ./...
@@ -36,4 +42,23 @@ coverage: $(STUB_LIB)
go tool cover -func=coverage.out
clean:
rm -f $(BINARY) $(OBJ) $(LIB) $(STUB_OBJ) $(STUB_LIB) coverage.out
rm -f $(BINARY) $(OBJ) $(LIB) $(STUB_OBJ) $(STUB_LIB) coverage.out
tag:
git tag v$(VERSION)
git push origin v$(VERSION)
release: build tag
ifndef GITEA_TOKEN
$(error GITEA_TOKEN is required. Set it with: export GITEA_TOKEN=your-token)
endif
curl -sf -X POST "https://$(GITEA_HOST)/api/v1/repos/$(GITEA_REPO)/releases" \
-H "Authorization: token $(GITEA_TOKEN)" \
-H "Content-Type: application/json" \
-d '{"tag_name":"v$(VERSION)","name":"v$(VERSION)","body":"photoscli v$(VERSION)"}' | python3 -c "import sys,json; d=json.load(sys.stdin); print(d['id'])" > /tmp/_photoscli_release_id
@echo "created release v$(VERSION)"
curl -sf -X POST "https://$(GITEA_HOST)/api/v1/repos/$(GITEA_REPO)/releases/$$(cat /tmp/_photoscli_release_id)/assets?name=photoscli" \
-H "Authorization: token $(GITEA_TOKEN)" \
-F "attachment=@$(BINARY)"
@echo "uploaded $(BINARY) to release v$(VERSION)"
@rm -f /tmp/_photoscli_release_id