Skip to content

Commit f350878

Browse files
authored
Merge pull request #12 from numberly/build/versionning
build(Makefile): use a proper script to retrieve the version
2 parents 97b5387 + 9410cd4 commit f350878

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

Makefile

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.DEFAULT_GOAL := build
22

3+
VERSION ?= $(shell ./hack/get-version.sh)
4+
35
.PHONY:fmt vet build
46
fmt:
57
go fmt ./...
@@ -11,7 +13,7 @@ build: vet
1113
go build
1214

1315
build-docker: vet
14-
docker build -t numberly/vault-db-injector:2.0.1 .
16+
docker build -t numberly/vault-db-injector:${VERSION} .
1517

1618
push-docker: build-docker
17-
docker push numberly/vault-db-injector:2.0.1
19+
docker push numberly/vault-db-injector:${VERSION}

hack/get-version.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/usr/bin/env bash
2+
# Copyright 2022 The Kubernetes Authors.
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
if [[ "${GIT_TAG}" == "" ]]; then
17+
GIT_TAG="$(git describe --tags --dirty --always)"
18+
fi
19+
20+
# The value passed by gcr's cloudbuild will have this prefix by default
21+
# https://github.com/kubernetes/k8s.io/blob/aa5a1f164aece8f116196c40ac7b937be479cd41/images/codesearch/cs-fetch-repos/Makefile#L19
22+
if [[ "${GIT_TAG}" =~ ^v[0-9]{8}- ]]; then
23+
GIT_TAG="${GIT_TAG:10}"
24+
fi
25+
26+
echo "${GIT_TAG}"

0 commit comments

Comments
 (0)