From 48a32d50fdc9aced9497d3740c3f072c5e609c9c Mon Sep 17 00:00:00 2001 From: Egor Pozharov Date: Tue, 5 May 2026 14:40:27 +0600 Subject: [PATCH] add commit SHA build argument to frontend Docker builds in pre-push hook and Makefile, and introduce version bumping targets for release workflow --- .githooks/pre-push | 3 ++- Makefile | 24 ++++++++++++++++++++---- frontend/package-lock.json | 4 ++-- frontend/package.json | 2 +- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/.githooks/pre-push b/.githooks/pre-push index edf11e7..0b2060c 100755 --- a/.githooks/pre-push +++ b/.githooks/pre-push @@ -4,6 +4,7 @@ REGISTRY="gitea.chedius.ru/chedius" PLATFORM="linux/amd64" +COMMIT_SHA=$(git rev-parse --short=12 HEAD 2>/dev/null || echo dev) echo "🔨 Building Docker images..." @@ -14,7 +15,7 @@ docker build --platform $PLATFORM -t $REGISTRY/delivery-tracker/backend:latest . } # Build frontend -docker build --platform $PLATFORM -t $REGISTRY/delivery-tracker/frontend:latest ./frontend || { +docker build --platform $PLATFORM --build-arg GITEA_SHA=$COMMIT_SHA -t $REGISTRY/delivery-tracker/frontend:latest ./frontend || { echo "❌ Frontend build failed" exit 1 } diff --git a/Makefile b/Makefile index 84ab2cd..0c38ffc 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,17 @@ # Delivery Tracker - Local Build & Deploy REGISTRY = gitea.chedius.ru/chedius PLATFORM = linux/amd64 +COMMIT_SHA := $(shell git rev-parse --short=12 HEAD 2>/dev/null || echo dev) +VERSION_PART ?= patch # Build and push both services -.PHONY: all build push deploy install-hooks +.PHONY: all build push deploy install-hooks version version-patch version-minor version-major check-release-message release all: build push build: docker build --platform $(PLATFORM) -t $(REGISTRY)/delivery-tracker/backend:latest ./backend - docker build --platform $(PLATFORM) -t $(REGISTRY)/delivery-tracker/frontend:latest ./frontend + docker build --platform $(PLATFORM) --build-arg GITEA_SHA=$(COMMIT_SHA) -t $(REGISTRY)/delivery-tracker/frontend:latest ./frontend push: docker push $(REGISTRY)/delivery-tracker/backend:latest @@ -36,9 +38,23 @@ install-hooks: chmod +x .githooks/* @echo "✅ Git hooks installed from .githooks/" -# Full release: commit, push, and auto-build via hook -release: +version: + @node -p "require('./frontend/package.json').version" + +version-patch: + cd frontend && npm version patch --no-git-tag-version + +version-minor: + cd frontend && npm version minor --no-git-tag-version + +version-major: + cd frontend && npm version major --no-git-tag-version + +check-release-message: @if [ -z "$(MSG)" ]; then echo "Usage: make release MSG='commit message'"; exit 1; fi + +# Full release: commit, push, and auto-build via hook +release: check-release-message version-$(VERSION_PART) git add -A git commit -m "$(MSG)" || true git push diff --git a/frontend/package-lock.json b/frontend/package-lock.json index 2f54ff8..c460379 100644 --- a/frontend/package-lock.json +++ b/frontend/package-lock.json @@ -1,12 +1,12 @@ { "name": "delivery-tracker", - "version": "0.0.0", + "version": "0.0.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "delivery-tracker", - "version": "0.0.0", + "version": "0.0.1", "dependencies": { "@tailwindcss/vite": "^4.2.2", "date-fns": "^4.1.0", diff --git a/frontend/package.json b/frontend/package.json index 8f63c6c..a0261f7 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,7 +1,7 @@ { "name": "delivery-tracker", "private": true, - "version": "0.0.0", + "version": "0.0.1", "type": "module", "scripts": { "dev": "vite",