简体   繁体   中英

Using a Makefile to get latest git tag

I have a Makefile which I use to build my docker image.

NAME = demo/docker-test

default: build

build:
    docker build -t $(NAME) .

push:
    docker push $(NAME)

I would like to append to the build the latest version from my Git tags ie

build:
    docker build -t $(NAME):$(VERSION) .

So if I have 3 tags in Git v.1.2 , v.1.3 , v.1.4 VERSION would be v.1.4 .

Is this possible in a Makefile? If so how, where do I start?

git describe --tags 

Should give you the output needed

From there you should be able to check out the files in the make script

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM