Skip to content

Commit

Permalink
chore: rename Chart.yaml template to Chart.template.yaml for clarity
Browse files Browse the repository at this point in the history
* chore: rename Chart.yaml template to Chart.template.yaml for clarity
* feat: add make gen target to generate Chart.yaml from Chart.template.yaml
* chore: add Chart.yaml to .gitignore

Signed-off-by: lvlcn-t <[email protected]>
  • Loading branch information
lvlcn-t committed Nov 19, 2024
1 parent f24a810 commit a4375b1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
1 change: 1 addition & 0 deletions chart/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Chart.yaml
File renamed without changes.
25 changes: 13 additions & 12 deletions chart/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,38 +2,39 @@

WITH_V ?= 0

BASE_VERSION = $(shell (git describe --tags --abbrev=0 2>/dev/null || echo "v0.0.0") | sed 's/^v//')
CHART_VERSION ?= $(shell $(MAKE) -s version)
CHART_APP_VERSION ?= $(shell $(MAKE) -s WITH_V=1 version)

.PHONY: package
package: lint build

.PHONY: gen
gen:
@cp -f Chart.template.yaml Chart.yaml
@sed -i "/^version:.*/c\version: $(BASE_VERSION)" Chart.yaml || echo "version: $(BASE_VERSION)" >> Chart.yaml
@sed -i "/^appVersion:.*/c\appVersion: \"v$(BASE_VERSION)\"" Chart.yaml || echo "appVersion: \"v$(BASE_VERSION)\"" >> Chart.yaml

.PHONY: lint
lint:
lint: gen
@helm lint .

.PHONY: build
build:
build: gen
@helm package . --version $(CHART_VERSION) --app-version $(CHART_APP_VERSION)

.PHONY: docs
docs:
@VERSION=$$(git describe --tags --abbrev=0 2>/dev/null || echo "0.0.0"); \
VERSION=$${VERSION#v}; \
cp -f Chart.yaml Chart.yaml.bak; \
sed -i "s/^version:.*/version: $${VERSION}/" Chart.yaml; \
sed -i "s/^appVersion:.*/appVersion: \"v$${VERSION}\"/" Chart.yaml; \
echo "Generating docs for version $${VERSION} (appVersion: v$${VERSION})"; \
helm-docs; \
mv -f Chart.yaml.bak Chart.yaml
docs: gen
@echo "Generating docs for version $(BASE_VERSION) (appVersion: v$(BASE_VERSION))"
@helm-docs

.PHONY: version
version:
@TAG=$$(git describe --tags --exact-match 2>/dev/null); \
if [ -n "$$TAG" ]; then \
VERSION="$$TAG"; \
else \
VERSION="$$(git describe --tags --abbrev=0 2>/dev/null)-commit-$$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")"; \
VERSION="v$(BASE_VERSION)-commit-$$(git rev-parse --short HEAD 2>/dev/null || echo "unknown")"; \
fi; \
if [ "$(WITH_V)" = "1" ]; then \
echo "$$VERSION"; \
Expand Down

0 comments on commit a4375b1

Please sign in to comment.