Commit 5e2d6315 by Chavee Issariyapat

update Makefile

parent 7f260c0e
# a helper shell script # a helper shell script
# version 1.1 MAKE_VERSION=1.1.2
define MAKEFUNCTIONCODE define MAKEFUNCTIONCODE
function hasChanges() { function hasChanges() {
...@@ -106,8 +106,8 @@ TAG=$(shell . $(RELEASE_SUPPORT); getTag) ...@@ -106,8 +106,8 @@ TAG=$(shell . $(RELEASE_SUPPORT); getTag)
RELEASE_SUPPORT := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))/.make-function RELEASE_SUPPORT := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))/.make-function
export MAKEFUNCTIONCODE export MAKEFUNCTIONCODE
.PHONY: pre-build docker-build post-build build release patch-release minor-release major-release tag check-status check-release showtag \ .PHONY: pre-build docker-build post-build build release patch-release minor-release major-release tag check-status check-release showtag show-tag \
push do-push post-push post-init push do-push post-push post-init update-make
init: init:
@echo "$$MAKEFUNCTIONCODE" > ./.make-function @echo "$$MAKEFUNCTIONCODE" > ./.make-function
...@@ -147,6 +147,10 @@ do-push: ...@@ -147,6 +147,10 @@ do-push:
snapshot: build push snapshot: build push
show-tag: init release.conf
@. $(RELEASE_SUPPORT); getVersion
@rm .make-function
showtag: init release.conf showtag: init release.conf
@. $(RELEASE_SUPPORT); getVersion @. $(RELEASE_SUPPORT); getVersion
@rm .make-function @rm .make-function
...@@ -188,3 +192,11 @@ check-status: init ...@@ -188,3 +192,11 @@ check-status: init
check-release: init release.conf post-init check-release: init release.conf post-init
@. $(RELEASE_SUPPORT) ; tagExists $(TAG) || (echo "ERROR: version not yet tagged in git. make [minor,major,patch]-release." >&2 && exit 1) ; @. $(RELEASE_SUPPORT) ; tagExists $(TAG) || (echo "ERROR: version not yet tagged in git. make [minor,major,patch]-release." >&2 && exit 1) ;
@. $(RELEASE_SUPPORT) ; ! differsFromRelease $(TAG) || (echo "ERROR: current directory differs from tagged $(TAG). make [minor,major,patch]-release." ; exit 1) @. $(RELEASE_SUPPORT) ; ! differsFromRelease $(TAG) || (echo "ERROR: current directory differs from tagged $(TAG). make [minor,major,patch]-release." ; exit 1)
update-make: init
@rm Makefile
wget https://dev.nexpie.com/sample/docker-makefile-sample/raw/master/Makefile
@rm .make-function
make-version:
@echo $(MAKE_VERSION)
# a helper shell script # a helper shell script
MAKE_VERSION=1.1.2
define MAKEFUNCTIONCODE define MAKEFUNCTIONCODE
function hasChanges() { function hasChanges() {
test -n "$$(git status -s .)" # old version, just track uncommited + untracked files
# test -n "$$(git status -s .)"
# expect 1 to be normal so the untracked file .make-funcition will be ignored
test 1 -ne "$$(git status -s . | wc -l )"
} }
function getRelease() { function getRelease() {
...@@ -101,8 +106,8 @@ TAG=$(shell . $(RELEASE_SUPPORT); getTag) ...@@ -101,8 +106,8 @@ TAG=$(shell . $(RELEASE_SUPPORT); getTag)
RELEASE_SUPPORT := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))/.make-function RELEASE_SUPPORT := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))/.make-function
export MAKEFUNCTIONCODE export MAKEFUNCTIONCODE
.PHONY: pre-build docker-build post-build build release patch-release minor-release major-release tag check-status check-release showver \ .PHONY: pre-build docker-build post-build build release patch-release minor-release major-release tag check-status check-release showtag show-tag \
push do-push post-push push do-push post-push post-init update-make
init: init:
@echo "$$MAKEFUNCTIONCODE" > ./.make-function @echo "$$MAKEFUNCTIONCODE" > ./.make-function
...@@ -117,6 +122,9 @@ post-build: ...@@ -117,6 +122,9 @@ post-build:
post-push: post-push:
@rm .make-function @rm .make-function
post-init:
@rm .make-function
docker-build: docker-build:
docker build -t $(IMAGE):$(VERSION) . docker build -t $(IMAGE):$(VERSION) .
@DOCKER_MAJOR=$(shell docker -v | sed -e 's/.*version //' -e 's/,.*//' | cut -d\. -f1) ; \ @DOCKER_MAJOR=$(shell docker -v | sed -e 's/.*version //' -e 's/,.*//' | cut -d\. -f1) ; \
...@@ -139,8 +147,13 @@ do-push: ...@@ -139,8 +147,13 @@ do-push:
snapshot: build push snapshot: build push
showver: init release.conf show-tag: init release.conf
@. $(RELEASE_SUPPORT); getVersion @. $(RELEASE_SUPPORT); getVersion
@rm .make-function
showtag: init release.conf
@. $(RELEASE_SUPPORT); getVersion
@rm .make-function
tag-patch-release: init tag-patch-release: init
VERSION := $(shell . $(RELEASE_SUPPORT); nextPatchLevel) VERSION := $(shell . $(RELEASE_SUPPORT); nextPatchLevel)
...@@ -173,8 +186,17 @@ tag: check-status ...@@ -173,8 +186,17 @@ tag: check-status
@ if [ -n "$(shell git remote -v)" ] ; then git push --tags ; else echo 'no remote to push tags to' ; fi @ if [ -n "$(shell git remote -v)" ] ; then git push --tags ; else echo 'no remote to push tags to' ; fi
check-status: init check-status: init
@. $(RELEASE_SUPPORT) ; ! hasChanges || (echo "ERROR: there are still outstanding changes" >&2 && exit 1) ; @. $(RELEASE_SUPPORT) ; ! hasChanges || (echo "ERROR: there are still outstanding changes" >&2) ;
@rm .make-function
check-release: init release.conf check-release: init release.conf post-init
@. $(RELEASE_SUPPORT) ; tagExists $(TAG) || (echo "ERROR: version not yet tagged in git. make [minor,major,patch]-release." >&2 && exit 1) ; @. $(RELEASE_SUPPORT) ; tagExists $(TAG) || (echo "ERROR: version not yet tagged in git. make [minor,major,patch]-release." >&2 && exit 1) ;
@. $(RELEASE_SUPPORT) ; ! differsFromRelease $(TAG) || (echo "ERROR: current directory differs from tagged $(TAG). make [minor,major,patch]-release." ; exit 1) @. $(RELEASE_SUPPORT) ; ! differsFromRelease $(TAG) || (echo "ERROR: current directory differs from tagged $(TAG). make [minor,major,patch]-release." ; exit 1)
update-make: init
@rm Makefile
wget https://dev.nexpie.com/sample/docker-makefile-sample/raw/master/Makefile
@rm .make-function
make-version:
@echo $(MAKE_VERSION)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment