feat: enhance VITE_APP_VERSION handling in Taskfile for frontend, backend, and Docker builds
This commit is contained in:
37
Taskfile.yml
37
Taskfile.yml
@@ -19,7 +19,19 @@ tasks:
|
||||
build:frontend:
|
||||
desc: Build frontend only
|
||||
cmds:
|
||||
- pnpm run build
|
||||
- |
|
||||
if [ -z "$VITE_APP_VERSION" ]; then
|
||||
if git rev-parse --git-dir > /dev/null 2>&1; then
|
||||
if git describe --tags --exact-match HEAD > /dev/null 2>&1; then
|
||||
VITE_APP_VERSION=$(git describe --tags --exact-match HEAD)
|
||||
else
|
||||
VITE_APP_VERSION=$(git rev-parse --short HEAD)
|
||||
fi
|
||||
else
|
||||
VITE_APP_VERSION=$(node -p "require('./package.json').version")
|
||||
fi
|
||||
fi
|
||||
VITE_APP_VERSION="$VITE_APP_VERSION" pnpm run build
|
||||
|
||||
build:backend:
|
||||
desc: Build backend binary only
|
||||
@@ -31,7 +43,19 @@ tasks:
|
||||
desc: Build the single binary web server
|
||||
cmds:
|
||||
- pnpm install
|
||||
- pnpm run build
|
||||
- |
|
||||
if [ -z "$VITE_APP_VERSION" ]; then
|
||||
if git rev-parse --git-dir > /dev/null 2>&1; then
|
||||
if git describe --tags --exact-match HEAD > /dev/null 2>&1; then
|
||||
VITE_APP_VERSION=$(git describe --tags --exact-match HEAD)
|
||||
else
|
||||
VITE_APP_VERSION=$(git rev-parse --short HEAD)
|
||||
fi
|
||||
else
|
||||
VITE_APP_VERSION=$(node -p "require('./package.json').version")
|
||||
fi
|
||||
fi
|
||||
VITE_APP_VERSION="$VITE_APP_VERSION" pnpm run build
|
||||
- mkdir -p {{.BUILD_DIR}}
|
||||
- CGO_ENABLED=0 go build -ldflags="-s -w" -o {{.BUILD_DIR}}/{{.BINARY_NAME}} main.go
|
||||
|
||||
@@ -93,9 +117,14 @@ tasks:
|
||||
- GOOS=freebsd GOARCH=amd64 go build -o {{.BUILD_DIR}}/{{.BINARY_NAME}}-freebsd-amd64 main.go
|
||||
|
||||
docker-build:
|
||||
desc: Build Docker image
|
||||
desc: Build Docker image (VITE_APP_VERSION env var will be passed as build arg if set)
|
||||
cmds:
|
||||
- docker build -f docker/Dockerfile -t {{.BINARY_NAME}} .
|
||||
- |
|
||||
if [ -n "$VITE_APP_VERSION" ]; then
|
||||
docker build --build-arg VITE_APP_VERSION="$VITE_APP_VERSION" -f docker/Dockerfile -t {{.BINARY_NAME}} .
|
||||
else
|
||||
docker build -f docker/Dockerfile -t {{.BINARY_NAME}} .
|
||||
fi
|
||||
|
||||
docker-run:
|
||||
desc: Run Docker container
|
||||
|
||||
Reference in New Issue
Block a user