From cd0454bd38be413e182155ba154ada2f5039b797 Mon Sep 17 00:00:00 2001 From: Ronen Hilewicz Date: Thu, 29 Aug 2024 16:26:24 -0400 Subject: [PATCH] `make deps` and `make bump` --- .gitignore | 1 + makefile | 54 ++++++++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 47 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 474b91d..d3a14b3 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +.ext/ /charts/*/build/*-*.*.*.tgz /charts/*/charts/*-*.*.*.tgz diff --git a/makefile b/makefile index 41668e0..6f00127 100644 --- a/makefile +++ b/makefile @@ -7,10 +7,19 @@ WARN_COLOR := \033[36;01m ATTN_COLOR := \033[33;01m CHART_REPO := "oci://ghcr.io/aserto-dev/helm" +CHARTS_DIR := charts +CHARTS := ${shell ls ${CHARTS_DIR}} +BUMP_PART ?= patch -CHARTS_DIR := charts -CHARTS := ${shell ls ${CHARTS_DIR}} -BUMP_PART ?= patch +CT_VERSION := 3.11.0 + +BIN_DIR := ./bin +EXT_DIR := ./.ext +EXT_BIN_DIR := ${EXT_DIR}/bin +EXT_TMP_DIR := ${EXT_DIR}/tmp + +.PHONY: deps +deps: install-ct install-bumpversion; .PHONY: clean clean: ${addprefix clean-,${CHARTS}} @@ -18,7 +27,7 @@ clean: ${addprefix clean-,${CHARTS}} .PHONY: lint lint: @echo -e "${ATTN_COLOR}==> $@ ${NO_COLOR}" - @ct lint --config ct.yaml --helm-repo-extra-args "aserto-helm=-u gh -p ${GITHUB_TOKEN}" + @${EXT_BIN_DIR}/ct lint --config ct.yaml --helm-repo-extra-args "aserto-helm=-u gh -p ${GITHUB_TOKEN}" .PHONY: update update: ${addprefix update-,${CHARTS}} @@ -32,12 +41,12 @@ package: ${addprefix package-,${CHARTS}} .PHONY: push push: ${addprefix push-,${CHARTS}} -.PHONY: release -release: build package push - .PHONY: bump bump: ${addprefix bump-,${CHARTS}} +.PHONY: release +release: build package push + .PHONY: clean-% clean-%: @echo -e "${ATTN_COLOR}==> clean $* ${NO_COLOR}" @@ -46,7 +55,7 @@ clean-%: .PHONY: lint-% lint-%: @echo -e "${ATTN_COLOR}==> lint $* ${NO_COLOR}" - @ct lint --charts ${CHARTS_DIR}/$* --config ct.yaml --helm-repo-extra-args "aserto-helm=-u gh -p ${GITHUB_TOKEN}" + @${EXT_BIN_DIR}/ct lint --charts ${CHARTS_DIR}/$* --config ct.yaml --helm-repo-extra-args "aserto-helm=-u gh -p ${GITHUB_TOKEN}" .PHONY: update-% update-%: @@ -77,6 +86,9 @@ push-%: # https://www.gnu.org/software/make/manual/html_node/Pattern_002dspecific.html bump-%: CHART_VERSION = ${shell cat ${CHARTS_DIR}/$*/Chart.yaml | yq '.version'} +.PHONY: release-% +release-%: update-% build-% package-% push-%; + .PHONY: bump-% bump-%: @echo -e "${ATTN_COLOR}==> bump ${BUMP_PART} $* (${CHART_VERSION}) ${NO_COLOR}" @@ -84,3 +96,29 @@ bump-%: ${BUMP_PART} ${CHARTS_DIR}/$*/Chart.yaml @echo -e "New version: $$(cat ${CHARTS_DIR}/$*/Chart.yaml | yq '.version')" +.PHONY: install-ct +install-ct: ${EXT_TMP_DIR} ${EXT_BIN_DIR} + @echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)" + @gh release download v${CT_VERSION} --repo https://github.com/helm/chart-testing \ + --pattern "chart-testing_${CT_VERSION}_$$(uname -s | tr '[:upper:]' '[:lower:]')_$$(uname -m).tar.gz" \ + --output "${EXT_TMP_DIR}/chart-testing.tar.gz" --clobber + @tar -xvf ${EXT_TMP_DIR}/chart-testing.tar.gz --directory ${EXT_BIN_DIR} ct &> /dev/null + @chmod +x ${EXT_BIN_DIR}/ct + @${EXT_BIN_DIR}/ct version + +.PHONY: install-bumpversion +install-bumpversion: ${EXT_TMP_DIR} ${EXT_BIN_DIR} + @echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)" + @pip install bump2version + +${BIN_DIR}: + @echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)" + @mkdir -p ${BIN_DIR} + +${EXT_BIN_DIR}: + @echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)" + @mkdir -p ${EXT_BIN_DIR} + +${EXT_TMP_DIR}: + @echo -e "$(ATTN_COLOR)==> $@ $(NO_COLOR)" + @mkdir -p ${EXT_TMP_DIR}