Skip to content

Commit 287fe2d

Browse files
committed
get PIPECD_VERSION before docker build
1 parent f6b3600 commit 287fe2d

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

Makefile

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,9 @@ else
4242
endif
4343

4444
.PHONY: build/web
45+
build/web: PIPECD_VERSION ?= $(shell git describe --tags --always --abbrev=7 --match 'v[0-9]*.*')
4546
build/web:
46-
yarn --cwd web build
47+
PIPECD_VERSION=$(PIPECD_VERSION) yarn --cwd web build
4748

4849
.PHONY: build/chart
4950
build/chart: VERSION ?= $(shell git describe --tags --always --dirty --abbrev=7 --match 'v[0-9]*.*')
@@ -149,6 +150,7 @@ run/pipecd: $(eval TIMESTAMP = $(shell date +%s))
149150
# NOTE: previously `git describe --tags` was used to determine the version for running locally
150151
# However, this does not work on a forked branch, so the decision was made to hardcode at version 0.0.0
151152
# see: https://github.com/pipe-cd/pipecd/issues/4845
153+
run/pipecd: PIPECD_VERSION ?= $(shell git describe --tags --always --dirty --abbrev=7 --match 'v[0-9]*.*')
152154
run/pipecd: BUILD_VERSION ?= "v0.0.0-$(shell git rev-parse --short HEAD)-$(TIMESTAMP)"
153155
run/pipecd: BUILD_COMMIT ?= $(shell git rev-parse HEAD)
154156
run/pipecd: BUILD_DATE ?= $(shell date -u '+%Y%m%d-%H%M%S')
@@ -157,7 +159,7 @@ run/pipecd: BUILD_OPTS ?= -ldflags "$(BUILD_LDFLAGS_PREFIX).version=$(BUILD_VERS
157159
run/pipecd: CONTROL_PLANE_VALUES ?= ./quickstart/control-plane-values.yaml
158160
run/pipecd:
159161
@echo "Building docker image and pushing it to local registry..."
160-
docker build -f cmd/pipecd/Dockerfile -t localhost:5001/pipecd:$(BUILD_VERSION) .
162+
PIPECD_VERSION=$(PIPECD_VERSION) docker build -f cmd/pipecd/Dockerfile -t localhost:5001/pipecd:$(BUILD_VERSION) .
161163
docker push localhost:5001/pipecd:$(BUILD_VERSION)
162164

163165
@echo "Installing Control Plane in kind..."
@@ -188,8 +190,9 @@ else
188190
endif
189191

190192
.PHONY: run/web
193+
run/web: PIPECD_VERSION ?= $(shell git describe --tags --always --abbrev=7 --match 'v[0-9]*.*')
191194
run/web:
192-
yarn --cwd web dev
195+
PIPECD_VERSION=$(PIPECD_VERSION) yarn --cwd web dev
193196

194197
.PHONY: run/site
195198
run/site:

web/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
"private": true,
66
"license": "Apache-2.0",
77
"scripts": {
8-
"build": "PIPECD_VERSION=`git describe --tags --always --dirty --abbrev=7 --match 'v[0-9]*.*'` webpack build --mode production --env htmlTemplate=./base.html --config ./webpack.config.js",
9-
"dev": "PIPECD_VERSION=`git describe --tags --always --dirty --abbrev=7 --match 'v[0-9]*.*'` webpack serve --env htmlTemplate=./base.html --config ./webpack.config.dev.js",
8+
"build": "webpack build --mode production --env htmlTemplate=./base.html --config ./webpack.config.js",
9+
"dev": "webpack serve --env htmlTemplate=./base.html --config ./webpack.config.dev.js",
1010
"test": "TZ=Asia/Tokyo jest --config jest.config.local.js",
1111
"test:coverage": "yarn test --coverage",
1212
"lint": "eslint --ext .ts,.tsx ./src",

0 commit comments

Comments
 (0)