Improve development

This commit is contained in:
2025-04-04 00:38:28 +03:00
parent 93abb9158d
commit e5be089935
2 changed files with 42 additions and 6 deletions

View File

@@ -1,11 +1,28 @@
EXEC=bumpversion.run
NAMESPACE ?= golang
PACKAGE := bumpversion
SHELL := /bin/bash
REGISTRY := registry.halfakop.ru
REPOSITORY := $(NAMESPACE)/$(PACKAGE)
all: build
SOURCE_VERSION ?= $(shell cat VERSION)
SOURCE_COMMIT ?= $(shell git rev-parse --short=8 HEAD)
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD | sed s,feature/,,g)
IMAGE_NAME_TAGGED = $(REPOSITORY):$(SOURCE_VERSION)
EXEC=$(PACKAGE).run
all: help
help:
@echo "app - build the application"
@echo "tests - run tests"
@echo "run - run application locally"
@echo "clean - clean build environment"
fix:
@go fix ./...
build: fix
app: fix
@go build -o ./${EXEC} ./src
tests: build
@@ -17,5 +34,24 @@ run:
clean:
@rm -rf ./${EXEC}%
image:
docker build --compress -t rad/bumpversion:latest -f Dockerfile .
release: title clean build login push
build:
docker build --compress \
-t $(IMAGE_NAME_TAGGED) \
-t $(REGISTRY)/$(IMAGE_NAME_TAGGED) \
--build-arg SOURCE_VERSION=$(SOURCE_VERSION) \
--build-arg SOURCE_COMMIT=$(SOURCE_COMMIT) \
${DOCKER_OPTS} \
-f Dockerfile .
login:
$(call check-var-defined,DOCKER_USERNAME)
$(call check-var-defined,DOCKER_PASSWORD)
@echo ${DOCKER_PASSWORD} | \
docker login -u ${DOCKER_USERNAME} --password-stdin $(REGISTRY)
push:
docker push $(REGISTRY)/$(IMAGE_NAME_TAGGED)
.PHONY: tests release build login push

2
go.mod
View File

@@ -1,4 +1,4 @@
module src
module bumpversion
go 1.24.0