This commit is contained in:
admju 2024-09-18 19:31:18 +00:00
parent 0c35993122
commit 981ee7dce4
5 changed files with 28 additions and 19 deletions

View File

@ -23,6 +23,7 @@ help:
.PHONY: publish .PHONY: publish
publish: publish:
@echo Publication de : ${OC_VERSION} @echo Publication de : ${OC_VERSION}
@(cd src && make --quiet build VERSION=$(OC_VERSION))
@(cd publish && \ @(cd publish && \
PUBLISH_REPO=${PUBLISH_REPO} \ PUBLISH_REPO=${PUBLISH_REPO} \
PUBLISH_TOKEN=${PUBLISH_TOKEN} \ PUBLISH_TOKEN=${PUBLISH_TOKEN} \

View File

@ -12,12 +12,12 @@ PLUGINS := $(wildcard ../plugins/*/*.go)
OBJS := ${PLUGINS:.go=.so} OBJS := ${PLUGINS:.go=.so}
################## ##################
DATE := $(shell date) DATE := $(shell date --iso-8601)
GOVERSION := $(shell go version) GOVERSION := $(shell go version)
VERSION := $(shell git describe --tags --abbrev=8 --dirty --always --long) VERSION := $(shell git describe --tags --abbrev=8 --dirty --always --long)
PREFIX := "oc-deploy/version" PREFIX := oc-deploy/occonst
LDFLAGS := -X '${PREFIX}.Version=${VERSION}' LDFLAGS := "-X '${PREFIX}.Version=${VERSION}' -X '${PREFIX}.Date=${DATE}' -X '${PREFIX}.GoVersion=${GOVERSION}'"
################## ##################
@ -49,7 +49,7 @@ help:
@echo @echo
${BIN_DIR}/${BIN_NAME}: ${SOURCES} $(OBJS) ${BIN_DIR}/${BIN_NAME}: ${SOURCES} $(OBJS)
go build -o ${BIN_DIR}/${BIN_NAME} -ldflags "${LDFLAGS}" go build -o ${BIN_DIR}/${BIN_NAME} -ldflags ${LDFLAGS}
get-deps: get-deps:
@go mod tidy @go mod tidy

19
src/cmd/versionCmd.go Normal file
View File

@ -0,0 +1,19 @@
package cmd
import (
"fmt"
"oc-deploy/occonst"
log "oc-deploy/log_wrapper"
)
func VersionCmd() error {
version := occonst.Version
date := occonst.Date
goversion := occonst.GoVersion
log.Log().Debug().Msg(fmt.Sprintf("Version : %s (%s) ; GoVersion : %s", version, date, goversion))
fmt.Println(version)
return nil
}

View File

@ -1,15 +0,0 @@
package cmd
import (
"fmt"
log "oc-deploy/log_wrapper"
)
func VersionCmd() error {
version := "0.1.0"
log.Log().Debug().Msg(fmt.Sprintf("Version : %s", version))
fmt.Println(version)
return nil
}

View File

@ -9,6 +9,10 @@ var OCDEPLOY_ONLINE_REPO = getenv("OCDEPLOY_ONLINE_REPO", "core/oc-version")
var OCDEPLOY_OFFLINE_DIR = getenv("OCDEPLOY_OFFLINE_DIR", "../../offline") var OCDEPLOY_OFFLINE_DIR = getenv("OCDEPLOY_OFFLINE_DIR", "../../offline")
var Version = "dev"
var Date = "now"
var GoVersion = ""
func getenv(key string, defaut string) string { func getenv(key string, defaut string) string {
value := os.Getenv(key) value := os.Getenv(key)
if len(value) == 0 { if len(value) == 0 {