Calculate tags and version automatically (#100)

Signed-off-by: Andrei Kvapil <kvapss@gmail.com>
This commit is contained in:
Andrei Kvapil
2024-04-24 11:31:22 +02:00
committed by GitHub
parent ca79f725a3
commit 20fcd25d64
40 changed files with 109 additions and 107 deletions

View File

@@ -1,25 +0,0 @@
#!/bin/sh
set -e
if [ -e $1 ]; then
echo "Please pass version in the first argument"
echo "Example: $0 0.2.0"
exit 1
fi
version=$1
talos_version=$(awk '/^version:/ {print $2}' packages/core/installer/images/talos/profiles/installer.yaml)
set -x
sed -i "/^TAG / s|=.*|= v${version}|" \
packages/apps/http-cache/Makefile \
packages/apps/kubernetes/Makefile \
packages/core/installer/Makefile \
packages/system/dashboard/Makefile
sed -i "/^VERSION / s|=.*|= ${version}|" \
packages/core/Makefile \
packages/system/Makefile
make -C packages/core fix-chartnames
make -C packages/system fix-chartnames

View File

@@ -1,22 +1,20 @@
PUSH := 1
LOAD := 0
REGISTRY := ghcr.io/aenix-io/cozystack
NGINX_CACHE_TAG = v0.1.0
TAG := v0.3.1
include ../../../scripts/common-envs.mk
image: image-nginx
image-nginx:
docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 images/nginx-cache \
--provenance false \
--tag $(REGISTRY)/nginx-cache:$(NGINX_CACHE_TAG) \
--tag $(REGISTRY)/nginx-cache:$(NGINX_CACHE_TAG)-$(TAG) \
--cache-from type=registry,ref=$(REGISTRY)/nginx-cache:$(NGINX_CACHE_TAG) \
--tag $(REGISTRY)/nginx-cache:$(call settag,$(NGINX_CACHE_TAG)) \
--tag $(REGISTRY)/nginx-cache:$(call settag,$(NGINX_CACHE_TAG)-$(TAG)) \
--cache-from type=registry,ref=$(REGISTRY)/nginx-cache:latest \
--cache-to type=inline \
--metadata-file images/nginx-cache.json \
--push=$(PUSH) \
--load=$(LOAD)
echo "$(REGISTRY)/nginx-cache:$(NGINX_CACHE_TAG)" > images/nginx-cache.tag
echo "$(REGISTRY)/nginx-cache:$(call settag,$(NGINX_CACHE_TAG))" > images/nginx-cache.tag
update:
tag=$$(git ls-remote --tags --sort="v:refname" https://github.com/chrislim2888/IP2Location-C-Library | awk -F'[/^]' 'END{print $$3}') && \

View File

@@ -1,19 +1,17 @@
PUSH := 1
LOAD := 0
REGISTRY := ghcr.io/aenix-io/cozystack
TAG := v0.3.1
UBUNTU_CONTAINER_DISK_TAG = v1.29.1
include ../../../scripts/common-envs.mk
image: image-ubuntu-container-disk
image-ubuntu-container-disk:
docker buildx build --platform linux/amd64 --build-arg ARCH=amd64 images/ubuntu-container-disk \
--provenance false \
--tag $(REGISTRY)/ubuntu-container-disk:$(UBUNTU_CONTAINER_DISK_TAG) \
--tag $(REGISTRY)/ubuntu-container-disk:$(UBUNTU_CONTAINER_DISK_TAG)-$(TAG) \
--cache-from type=registry,ref=$(REGISTRY)/ubuntu-container-disk:$(UBUNTU_CONTAINER_DISK_TAG) \
--tag $(REGISTRY)/ubuntu-container-disk:$(call settag,$(UBUNTU_CONTAINER_DISK_TAG)) \
--tag $(REGISTRY)/ubuntu-container-disk:$(call settag,$(UBUNTU_CONTAINER_DISK_TAG)-$(TAG)) \
--cache-from type=registry,ref=$(REGISTRY)/ubuntu-container-disk:latest \
--cache-to type=inline \
--metadata-file images/ubuntu-container-disk.json \
--push=$(PUSH) \
--load=$(LOAD)
echo "$(REGISTRY)/ubuntu-container-disk:$(UBUNTU_CONTAINER_DISK_TAG)" > images/ubuntu-container-disk.tag
echo "$(REGISTRY)/ubuntu-container-disk:$(call settag,$(UBUNTU_CONTAINER_DISK_TAG))" > images/ubuntu-container-disk.tag

View File

@@ -1,6 +0,0 @@
VERSION := 0.3.1
gen: fix-chartnames
fix-chartnames:
find . -name Chart.yaml -maxdepth 2 | awk -F/ '{print $$2}' | while read i; do printf "name: cozy-%s\nversion: $(VERSION)\n" "$$i" > "$$i/Chart.yaml"; done

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-fluxcd
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-installer
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,11 +1,10 @@
NAME=installer
NAMESPACE=cozy-system
PUSH := 1
LOAD := 0
REGISTRY := ghcr.io/aenix-io/cozystack
TAG := v0.3.1
TALOS_VERSION=$(shell awk '/^version:/ {print $$2}' images/talos/profiles/installer.yaml)
include ../../../scripts/common-envs.mk
show:
helm template -n $(NAMESPACE) $(NAME) .
@@ -24,33 +23,33 @@ image-cozystack:
make -C ../../.. repos
docker buildx build -f images/cozystack/Dockerfile ../../.. \
--provenance false \
--tag $(REGISTRY)/cozystack:$(TAG) \
--cache-from type=registry,ref=$(REGISTRY)/cozystack:$(TAG) \
--tag $(REGISTRY)/cozystack:$(call settag,$(TAG)) \
--cache-from type=registry,ref=$(REGISTRY)/cozystack:latest \
--cache-to type=inline \
--metadata-file images/cozystack.json \
--push=$(PUSH) \
--load=$(LOAD)
echo "$(REGISTRY)/cozystack:$(TAG)" > images/cozystack.tag
echo "$(REGISTRY)/cozystack:$(call settag,$(TAG))" > images/cozystack.tag
image-talos:
test -f ../../../_out/assets/installer-amd64.tar || make talos-installer
docker load -i ../../../_out/assets/installer-amd64.tar
docker tag ghcr.io/siderolabs/installer:$(TALOS_VERSION) ghcr.io/aenix-io/cozystack/talos:$(TALOS_VERSION)
docker push ghcr.io/aenix-io/cozystack/talos:$(TALOS_VERSION)
docker tag ghcr.io/siderolabs/installer:$(TALOS_VERSION) ghcr.io/aenix-io/cozystack/talos:$(call settag,$(TALOS_VERSION))
docker push ghcr.io/aenix-io/cozystack/talos:$(call settag,$(TALOS_VERSION))
image-matchbox:
test -f ../../../_out/assets/kernel-amd64 || make talos-kernel
test -f ../../../_out/assets/initramfs-metal-amd64.xz || make talos-initramfs
docker buildx build -f images/matchbox/Dockerfile ../../.. \
--provenance false \
--tag $(REGISTRY)/matchbox:$(TAG) \
--tag $(REGISTRY)/matchbox:$(TALOS_VERSION)-$(TAG) \
--cache-from type=registry,ref=$(REGISTRY)/matchbox:$(TALOS_VERSION) \
--tag $(REGISTRY)/matchbox:$(call settag,$(TAG)) \
--tag $(REGISTRY)/matchbox:$(call settag,$(TALOS_VERSION)-$(TAG)) \
--cache-from type=registry,ref=$(REGISTRY)/matchbox:latest \
--cache-to type=inline \
--metadata-file images/matchbox.json \
--push=$(PUSH) \
--load=$(LOAD)
echo "$(REGISTRY)/matchbox:$(TALOS_VERSION)" > images/matchbox.tag
echo "$(REGISTRY)/matchbox:$(call settag,$(TALOS_VERSION))" > images/matchbox.tag
assets: talos-iso talos-nocloud

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-platform
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,13 +1,12 @@
OUT=../../_out/repos/system
VERSION := 0.3.1
gen: fix-chartnames
include ../../scripts/common-envs.mk
repo: fix-chartnames
repo:
rm -rf "$(OUT)"
mkdir -p "$(OUT)"
helm package -d "$(OUT)" $$(find . -mindepth 2 -maxdepth 2 -name Chart.yaml | awk 'sub("/Chart.yaml", "")')
helm package -d "$(OUT)" $$(find . -mindepth 2 -maxdepth 2 -name Chart.yaml | awk 'sub("/Chart.yaml", "")') --version $(VERSION)
cd "$(OUT)" && helm repo index .
fix-chartnames:
find . -name Chart.yaml -maxdepth 2 | awk -F/ '{print $$2}' | while read i; do printf "name: cozy-%s\nversion: $(VERSION)\n" "$$i" > "$$i/Chart.yaml"; done
find . -name Chart.yaml -maxdepth 2 | awk -F/ '{print $$2}' | while read i; do sed -i "s/^name: .*/name: cozy-$$i/" "$$i/Chart.yaml"; done

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-capi-operator
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-capi-providers
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-cert-manager-issuers
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-cert-manager
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-cilium
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-clickhouse-operator
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-dashboard
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,10 +1,7 @@
NAME=dashboard
NAMESPACE=cozy-$(NAME)
PUSH := 1
LOAD := 0
REPOSITORY := ghcr.io/aenix-io/cozystack
TAG := v0.3.1
include ../../../scripts/common-envs.mk
include ../../../scripts/package-system.mk
update: update-chart update-dockerfiles
@@ -30,21 +27,21 @@ update-dockerfiles:
image-dashboard:
docker buildx build images/dashboard \
--provenance false \
--tag $(REPOSITORY)/dashboard:$(TAG) \
--cache-from type=registry,ref=$(REPOSITORY)/dashboard:$(TAG) \
--tag $(REGISTRY)/dashboard:$(call settag,$(TAG)) \
--cache-from type=registry,ref=$(REGISTRY)/dashboard:latest \
--cache-to type=inline \
--metadata-file images/dashboard.json \
--push=$(PUSH) \
--load=$(LOAD)
echo "$(REPOSITORY)/dashboard:$(TAG)" > images/dashboard.tag
echo "$(REGISTRY)/dashboard:$(call settag,$(TAG))" > images/dashboard.tag
image-kubeapps-apis:
docker buildx build images/kubeapps-apis \
--provenance false \
--tag $(REPOSITORY)/kubeapps-apis:$(TAG) \
--cache-from type=registry,ref=$(REPOSITORY)/kubeapps-apis:$(TAG) \
--tag $(REGISTRY)/kubeapps-apis:$(call settag,$(TAG)) \
--cache-from type=registry,ref=$(REGISTRY)/kubeapps-apis:latest \
--cache-to type=inline \
--metadata-file images/kubeapps-apis.json \
--push=$(PUSH) \
--load=$(LOAD)
echo "$(REPOSITORY)/kubeapps-apis:$(TAG)" > images/kubeapps-apis.tag
echo "$(REGISTRY)/kubeapps-apis:$(call settag,$(TAG))" > images/kubeapps-apis.tag

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-grafana-oncall
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-grafana-operator
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-ingress-nginx
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-kafka-operator
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-kamaji-etcd
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-kamaji
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-kubeovn
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-kubevirt-cdi-operator
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-kubevirt-cdi
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-kubevirt-csi-node
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-kubevirt-operator
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-kubevirt
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-linstor
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-mariadb-operator
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-metallb
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-monitoring
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-piraeus-operator
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-postgres-operator
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-rabbitmq-operator
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-redis-operator
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-telepresence
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

View File

@@ -1,2 +1,3 @@
apiVersion: v2
name: cozy-victoria-metrics-operator
version: 0.3.1
version: 0.0.0 # Placeholder, the actual version will be automatically set during the build process

10
scripts/common-envs.mk Normal file
View File

@@ -0,0 +1,10 @@
REGISTRY := ghcr.io/aenix-io/cozystack
PUSH := 1
LOAD := 0
VERSION = $(patsubst v%,%,$(shell git describe --tags --abbrev=0))
TAG = $(shell git describe --tags --exact-match 2>/dev/null || echo latest)
# Returns 'latest' if the git tag is not assigned, otherwise returns the provided value
define settag
$(if $(filter $(TAG),latest),latest,$(1))
endef