Skip to content

Commit a0a6dfc

Browse files
committed
feat: add dev-tag Makefile target
- Add dev-tag target to Makefile for consistent dev image tagging - Format: v{VERSION}-dev.{COMMIT_COUNT}.{SHORT_SHA} - This provides consistent dev image tagging across all projects - Makes dev tag generation more maintainable and easier to understand
1 parent b9514fd commit a0a6dfc

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

Makefile

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: help build test lint clean fmt lint-only
1+
.PHONY: help build test lint clean fmt lint-only dev-tag
22

33
# Docker image versions
44
GOLANGCI_LINT_VERSION := v2.5.0
@@ -12,6 +12,7 @@ help:
1212
@echo " fmt - Format code using golangci-lint"
1313
@echo " lint-only - Run golangci-lint without formatting"
1414
@echo " clean - Clean build artifacts"
15+
@echo " dev-tag - Generate dev tag for Docker image"
1516

1617
# Build the application
1718
build:
@@ -68,3 +69,17 @@ lint-only:
6869
# Clean build artifacts
6970
clean:
7071
rm -f ghcr-exporter coverage.txt
72+
73+
# Generate dev tag for Docker image
74+
dev-tag:
75+
@SHORT_SHA=$$(git rev-parse --short HEAD 2>/dev/null || echo "unknown"); \
76+
LAST_TAG=$$(git describe --tags --abbrev=0 --match="v[0-9]*.[0-9]*.[0-9]*" 2>/dev/null || echo ""); \
77+
if [ -z "$$LAST_TAG" ]; then \
78+
VERSION="0.0.0"; \
79+
COMMIT_COUNT=$$(git rev-list --count HEAD); \
80+
else \
81+
VERSION=$${LAST_TAG#v}; \
82+
COMMIT_COUNT=$$(git rev-list --count $${LAST_TAG}..HEAD); \
83+
fi; \
84+
DEV_TAG="v$${VERSION}-dev.$${COMMIT_COUNT}.$${SHORT_SHA}"; \
85+
echo "$$DEV_TAG"

0 commit comments

Comments
 (0)