Ver Fonte

Cambio Makefile para que vaya cambiando de versión

Tino há 3 meses atrás
pai
commit
01eec9ef57
1 ficheiros alterados com 18 adições e 5 exclusões
  1. 18 5
      K8S/Makefile

+ 18 - 5
K8S/Makefile

@@ -1,12 +1,25 @@
 export REGISTRO=harbor.reymota.es\/jugaralpadel
-export IMG_VERSION = alpine-47
 export NAMESPACE = jugaralpadel
+VERSION_FILE = .version
+
+# Get current version or default to alpine-1
+IMG_VERSION := $(shell cat $(VERSION_FILE) 2>/dev/null || echo "alpine-1")
+# Get built version for deployment targets
+BUILT_VERSION := $(shell cat .current_version 2>/dev/null || echo "$(IMG_VERSION)")
+export IMG_VERSION
 
 # limpia todo
 all: imagen clean install
 
 imagen:
+	@echo "Building image with version: $(IMG_VERSION)"
+	@# Store current version for other targets to use
+	@echo "$(IMG_VERSION)" > .current_version
 	cd ../; make
+	@# Increment version for next build
+	@echo "$(IMG_VERSION)" | sed 's/alpine-\([0-9]*\)/alpine-\1/' | awk -F'-' '{print "alpine-" $$2+1}' > $(VERSION_FILE)
+	@echo "Next version will be: $$(cat $(VERSION_FILE))"
+
 
 ns:
 	-cat namespace.yaml | sed -e "s/<NS>/${NAMESPACE}/" |kubectl create -f -
@@ -16,12 +29,12 @@ install:
 	-cat env-prod-configmap.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
 	-cat secreto-db.yaml| sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
 
-	-cat jugaralpadel-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${IMG_VERSION}/" | sed -e "s/<REGISTRO>/${REGISTRO}/" | kubectl create -f -
+	-cat jugaralpadel-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${BUILT_VERSION}/" | sed -e "s/<REGISTRO>/${REGISTRO}/" | kubectl create -f -
 	-cat jugaralpadel-ingress.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
 
 clean:
 	-cat jugaralpadel-ingress.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
-	-cat jugaralpadel-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${IMG_VERSION}/" | sed -e "s/<REGISTRO>/${REGISTRO}/" | kubectl delete -f -
+	-cat jugaralpadel-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${BUILT_VERSION}/" | sed -e "s/<REGISTRO>/${REGISTRO}/" | kubectl delete -f -
 
 	-cat secreto-db.yaml| sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
 	-cat env-prod-configmap.yaml  | sed -e "s/<NS>/${NAMESPACE}/" | kubectl delete -f -
@@ -42,8 +55,8 @@ claims:
 	-cat pvc-static.yaml | sed -e "s/<NS>/${NAMESPACE}/" | kubectl create -f -
 
 app:
-	-cat jugaralpadel-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${IMG_VERSION}/" | sed -e "s/<REGISTRO>/${REGISTRO}/" | kubectl delete -f -
-	-cat jugaralpadel-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${IMG_VERSION}/" | sed -e "s/<REGISTRO>/${REGISTRO}/" | kubectl create -f -
+	-cat jugaralpadel-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${BUILT_VERSION}/" | sed -e "s/<REGISTRO>/${REGISTRO}/" | kubectl delete -f -
+	-cat jugaralpadel-deployment.yaml | sed -e "s/<NS>/${NAMESPACE}/" | sed -e "s/<TAG>/${BUILT_VERSION}/" | sed -e "s/<REGISTRO>/${REGISTRO}/" | kubectl create -f -
 
 db:
 	-kubectl create -f jugaralpadel-db.yaml