Compare commits
4 Commits
67108511c1
...
0.1.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 210ed25805 | |||
| e5be089935 | |||
| 93abb9158d | |||
| 052cd0edf3 |
@@ -1,5 +1,5 @@
|
|||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 0.1.0
|
current_version = 0.1.1
|
||||||
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.0
|
tags: 0.1.1
|
||||||
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
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ WORKDIR /app
|
|||||||
COPY go.mod go.sum ./
|
COPY go.mod go.sum ./
|
||||||
RUN go mod download
|
RUN go mod download
|
||||||
COPY . .
|
COPY . .
|
||||||
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bumpversion src/main.go
|
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bumpversion ./src
|
||||||
|
|
||||||
FROM alpine/git
|
FROM gcr.io/distroless/static
|
||||||
|
|
||||||
WORKDIR /
|
WORKDIR /
|
||||||
COPY --from=builder /app/bumpversion .
|
COPY --from=builder /app/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:
|
fix:
|
||||||
@go fix ./...
|
@go fix ./...
|
||||||
|
|
||||||
build: fix
|
app: fix
|
||||||
@go build -o ./${EXEC} ./src
|
@go build -o ./${EXEC} ./src
|
||||||
|
|
||||||
tests: build
|
tests: build
|
||||||
@@ -17,5 +34,24 @@ run:
|
|||||||
clean:
|
clean:
|
||||||
@rm -rf ./${EXEC}%
|
@rm -rf ./${EXEC}%
|
||||||
|
|
||||||
image:
|
release: title clean build login push
|
||||||
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.0
|
# BumpVersion v0.1.1
|
||||||
|
|
||||||
[](https://drone.halfakop.ru/rad/bumpversion)
|
[](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 {
|
func updateConfigFile(configPath string, newVersion string) error {
|
||||||
cfg, err := ini.Load(configPath)
|
cfg, err := ini.Load(configPath)
|
||||||
if err != nil {
|
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)
|
return cfg.SaveTo(configPath)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +162,7 @@ func resolveFlag(positive, negative *bool, defaultValue bool) bool {
|
|||||||
// Версия приложения
|
// Версия приложения
|
||||||
const (
|
const (
|
||||||
AppName = "BumpVersion"
|
AppName = "BumpVersion"
|
||||||
AppVersion = "0.1.0"
|
AppVersion = "0.1.1"
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
@@ -225,5 +229,7 @@ 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