mirror of
https://github.com/thomiceli/opengist.git
synced 2024-12-22 20:42:40 +00:00
Set Opengist version from git tags (#261)
* Set Opengist version from git tags * Add volume for docker dev container
This commit is contained in:
parent
785d89d6ab
commit
3551fd745a
4 changed files with 10 additions and 7 deletions
8
Makefile
8
Makefile
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
# Specify the name of your Go binary output
|
# Specify the name of your Go binary output
|
||||||
BINARY_NAME := opengist
|
BINARY_NAME := opengist
|
||||||
|
GIT_TAG := $(shell git describe --tags)
|
||||||
|
VERSION_PKG := github.com/thomiceli/opengist/internal/config.OpengistVersion
|
||||||
|
|
||||||
all: clean install build
|
all: clean install build
|
||||||
|
|
||||||
|
@ -20,7 +22,7 @@ build_frontend:
|
||||||
|
|
||||||
build_backend:
|
build_backend:
|
||||||
@echo "Building Opengist binary..."
|
@echo "Building Opengist binary..."
|
||||||
go build -tags fs_embed -o $(BINARY_NAME) .
|
go build -tags fs_embed -ldflags "-X $(VERSION_PKG)=$(GIT_TAG)" -o $(BINARY_NAME) .
|
||||||
|
|
||||||
build: build_frontend build_backend
|
build: build_frontend build_backend
|
||||||
|
|
||||||
|
@ -36,7 +38,7 @@ build_dev_docker:
|
||||||
docker build -t $(BINARY_NAME)-dev:latest --target dev .
|
docker build -t $(BINARY_NAME)-dev:latest --target dev .
|
||||||
|
|
||||||
run_dev_docker:
|
run_dev_docker:
|
||||||
docker run -v .:/opengist -p 6157:6157 -p 16157:16157 $(BINARY_NAME)-dev:latest
|
docker run -v .:/opengist -p 6157:6157 -p 16157:16157 -v $(HOME)/.opengist-dev:/root/.opengist --rm $(BINARY_NAME)-dev:latest
|
||||||
|
|
||||||
watch_frontend:
|
watch_frontend:
|
||||||
@echo "Building frontend assets..."
|
@echo "Building frontend assets..."
|
||||||
|
@ -44,7 +46,7 @@ watch_frontend:
|
||||||
|
|
||||||
watch_backend:
|
watch_backend:
|
||||||
@echo "Building Opengist binary..."
|
@echo "Building Opengist binary..."
|
||||||
OG_DEV=1 npx nodemon --watch '**/*' -e html,yml,go,js --signal SIGTERM --exec 'go run . --config config.yml'
|
OG_DEV=1 npx nodemon --watch '**/*' -e html,yml,go,js --signal SIGTERM --exec 'go run -ldflags "-X $(VERSION_PKG)=$(GIT_TAG)" . --config config.yml'
|
||||||
|
|
||||||
watch:
|
watch:
|
||||||
@sh ./scripts/watch.sh
|
@sh ./scripts/watch.sh
|
||||||
|
|
|
@ -20,7 +20,7 @@ var CmdVersion = cli.Command{
|
||||||
Name: "version",
|
Name: "version",
|
||||||
Usage: "Print the version of Opengist",
|
Usage: "Print the version of Opengist",
|
||||||
Action: func(c *cli.Context) error {
|
Action: func(c *cli.Context) error {
|
||||||
fmt.Println("Opengist v" + config.OpengistVersion)
|
fmt.Println("Opengist " + config.OpengistVersion)
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ func App() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func Initialize(ctx *cli.Context) {
|
func Initialize(ctx *cli.Context) {
|
||||||
fmt.Println("Opengist v" + config.OpengistVersion)
|
fmt.Println("Opengist " + config.OpengistVersion)
|
||||||
|
|
||||||
if err := config.InitConfig(ctx.String("config"), os.Stdout); err != nil {
|
if err := config.InitConfig(ctx.String("config"), os.Stdout); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
|
|
|
@ -17,7 +17,7 @@ import (
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var OpengistVersion = "1.7.1"
|
var OpengistVersion = ""
|
||||||
|
|
||||||
var C *config
|
var C *config
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ CHECKSUMS_FILE="build/checksums.txt"
|
||||||
BINARY_NAME="opengist"
|
BINARY_NAME="opengist"
|
||||||
TARGETS="darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 linux/armv6 linux/armv7 linux/386 windows/amd64"
|
TARGETS="darwin/amd64 darwin/arm64 linux/amd64 linux/arm64 linux/armv6 linux/armv7 linux/386 windows/amd64"
|
||||||
VERSION=$(git describe --tags | sed 's/^v//')
|
VERSION=$(git describe --tags | sed 's/^v//')
|
||||||
|
VERSION_PKG="github.com/thomiceli/opengist/internal/config.OpengistVersion"
|
||||||
|
|
||||||
if [ -z "$VERSION" ]; then
|
if [ -z "$VERSION" ]; then
|
||||||
echo "Error: Could not retrieve version from git tags. Exiting..."
|
echo "Error: Could not retrieve version from git tags. Exiting..."
|
||||||
|
@ -38,7 +39,7 @@ for TARGET in $TARGETS; do
|
||||||
|
|
||||||
echo "Building version $VERSION for $GOOS/$GOARCH${GOARM:+v$GOARM}..."
|
echo "Building version $VERSION for $GOOS/$GOARCH${GOARM:+v$GOARM}..."
|
||||||
mkdir -p $OUTPUT_DIR
|
mkdir -p $OUTPUT_DIR
|
||||||
env GOOS=$GOOS GOARCH=$GOARCH GOARM=$GOARM CGO_ENABLED=0 go build -tags fs_embed -o $OUTPUT_FILE
|
env GOOS=$GOOS GOARCH=$GOARCH GOARM=$GOARM CGO_ENABLED=0 go build -tags fs_embed -ldflags "-X $VERSION_PKG=v$VERSION" -o $OUTPUT_FILE
|
||||||
cp README.md $OUTPUT_DIR
|
cp README.md $OUTPUT_DIR
|
||||||
cp LICENSE $OUTPUT_DIR
|
cp LICENSE $OUTPUT_DIR
|
||||||
cp config.yml $OUTPUT_DIR
|
cp config.yml $OUTPUT_DIR
|
||||||
|
|
Loading…
Reference in a new issue