Compare commits
4 Commits
67108511c1
...
0.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 210ed25805 | |||
| e5be089935 | |||
| 93abb9158d | |||
| 052cd0edf3 |
@@ -1,5 +1,5 @@
|
||||
[bumpversion]
|
||||
current_version = 0.1.0
|
||||
current_version = 0.1.1
|
||||
commit = True
|
||||
tag = True
|
||||
tag_name = {new_version}
|
||||
|
||||
@@ -15,7 +15,7 @@ steps:
|
||||
path: /var/run/docker.sock
|
||||
settings:
|
||||
dockerfile: Dockerfile
|
||||
tags: 0.1.0
|
||||
tags: 0.1.1
|
||||
force_tag: true
|
||||
registry: registry.halfakop.ru
|
||||
repo: registry.halfakop.ru/golang/bumpversion
|
||||
|
||||
46
Makefile
46
Makefile
@@ -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
|
||||
@@ -1,4 +1,4 @@
|
||||
# BumpVersion v0.1.0
|
||||
# BumpVersion v0.1.1
|
||||
|
||||
[](https://drone.halfakop.ru/rad/bumpversion)
|
||||
|
||||
|
||||
12
src/main.go
12
src/main.go
@@ -130,9 +130,13 @@ func updateFiles(filePaths []string, oldVersion, newVersion string) {
|
||||
func updateConfigFile(configPath string, newVersion string) error {
|
||||
cfg, err := ini.Load(configPath)
|
||||
if err != nil {
|
||||
return err
|
||||
return fmt.Errorf("failed to load config: %w", err)
|
||||
}
|
||||
cfg.Section("bumpversion").Key("current_version").SetValue(newVersion)
|
||||
sec, err := cfg.GetSection("bumpversion")
|
||||
if err != nil {
|
||||
return fmt.Errorf("section [bumpversion] not found: %w", err)
|
||||
}
|
||||
sec.Key("current_version").SetValue(newVersion)
|
||||
return cfg.SaveTo(configPath)
|
||||
}
|
||||
|
||||
@@ -158,7 +162,7 @@ func resolveFlag(positive, negative *bool, defaultValue bool) bool {
|
||||
// Версия приложения
|
||||
const (
|
||||
AppName = "BumpVersion"
|
||||
AppVersion = "0.1.0"
|
||||
AppVersion = "0.1.1"
|
||||
)
|
||||
|
||||
func main() {
|
||||
@@ -225,5 +229,7 @@ func main() {
|
||||
// Обновляем конфигурационный файл
|
||||
if err := updateConfigFile(cfg_name, newVersion); err != nil {
|
||||
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