Compare commits
1 Commits
0.1.1
...
67108511c1
| Author | SHA1 | Date | |
|---|---|---|---|
| 67108511c1 |
@@ -1,5 +1,5 @@
|
|||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 0.1.1
|
current_version = 0.1.0
|
||||||
commit = True
|
commit = True
|
||||||
tag = True
|
tag = True
|
||||||
tag_name = {new_version}
|
tag_name = {new_version}
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ steps:
|
|||||||
path: /var/run/docker.sock
|
path: /var/run/docker.sock
|
||||||
settings:
|
settings:
|
||||||
dockerfile: Dockerfile
|
dockerfile: Dockerfile
|
||||||
tags: 0.1.1
|
tags: 0.1.0
|
||||||
force_tag: true
|
force_tag: true
|
||||||
registry: registry.halfakop.ru
|
registry: registry.halfakop.ru
|
||||||
repo: registry.halfakop.ru/golang/bumpversion
|
repo: registry.halfakop.ru/golang/bumpversion
|
||||||
|
|||||||
46
Makefile
46
Makefile
@@ -1,28 +1,11 @@
|
|||||||
NAMESPACE ?= golang
|
EXEC=bumpversion.run
|
||||||
PACKAGE := bumpversion
|
|
||||||
SHELL := /bin/bash
|
|
||||||
REGISTRY := registry.halfakop.ru
|
|
||||||
REPOSITORY := $(NAMESPACE)/$(PACKAGE)
|
|
||||||
|
|
||||||
SOURCE_VERSION ?= $(shell cat VERSION)
|
all: build
|
||||||
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:
|
fix:
|
||||||
@go fix ./...
|
@go fix ./...
|
||||||
|
|
||||||
app: fix
|
build: fix
|
||||||
@go build -o ./${EXEC} ./src
|
@go build -o ./${EXEC} ./src
|
||||||
|
|
||||||
tests: build
|
tests: build
|
||||||
@@ -34,24 +17,5 @@ run:
|
|||||||
clean:
|
clean:
|
||||||
@rm -rf ./${EXEC}%
|
@rm -rf ./${EXEC}%
|
||||||
|
|
||||||
release: title clean build login push
|
image:
|
||||||
|
docker build --compress -t rad/bumpversion:latest -f Dockerfile .
|
||||||
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
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
# BumpVersion v0.1.1
|
# BumpVersion v0.1.0
|
||||||
|
|
||||||
[](https://drone.halfakop.ru/rad/bumpversion)
|
[](https://drone.halfakop.ru/rad/bumpversion)
|
||||||
|
|
||||||
|
|||||||
12
src/main.go
12
src/main.go
@@ -130,13 +130,9 @@ func updateFiles(filePaths []string, oldVersion, newVersion string) {
|
|||||||
func updateConfigFile(configPath string, newVersion string) error {
|
func updateConfigFile(configPath string, newVersion string) error {
|
||||||
cfg, err := ini.Load(configPath)
|
cfg, err := ini.Load(configPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to load config: %w", err)
|
return err
|
||||||
}
|
}
|
||||||
sec, err := cfg.GetSection("bumpversion")
|
cfg.Section("bumpversion").Key("current_version").SetValue(newVersion)
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("section [bumpversion] not found: %w", err)
|
|
||||||
}
|
|
||||||
sec.Key("current_version").SetValue(newVersion)
|
|
||||||
return cfg.SaveTo(configPath)
|
return cfg.SaveTo(configPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -162,7 +158,7 @@ func resolveFlag(positive, negative *bool, defaultValue bool) bool {
|
|||||||
// Версия приложения
|
// Версия приложения
|
||||||
const (
|
const (
|
||||||
AppName = "BumpVersion"
|
AppName = "BumpVersion"
|
||||||
AppVersion = "0.1.1"
|
AppVersion = "0.1.0"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -229,7 +225,5 @@ func main() {
|
|||||||
// Обновляем конфигурационный файл
|
// Обновляем конфигурационный файл
|
||||||
if err := updateConfigFile(cfg_name, newVersion); err != nil {
|
if err := updateConfigFile(cfg_name, newVersion); err != nil {
|
||||||
log.Printf("Error updating config file: %v", err)
|
log.Printf("Error updating config file: %v", err)
|
||||||
} else {
|
|
||||||
log.Printf("Config file %s updated to version %s", cfg_name, newVersion)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user