doc
This commit is contained in:
+39
-4
@@ -1,67 +1,102 @@
|
||||
##
|
||||
# COMMON
|
||||
|
||||
# target build: Fire APPS target
|
||||
.PHONY: build
|
||||
build: $(APPS) ## Build applications
|
||||
|
||||
# target build@%: Fire APPS target
|
||||
.PHONY: build@%
|
||||
build@%: $(APPS);
|
||||
|
||||
# target clean: Fire APPS target
|
||||
.PHONY: clean
|
||||
clean: $(APPS) ## Clean applications
|
||||
|
||||
# target clean@%: Fire APPS target
|
||||
.PHONY: clean@%
|
||||
clean@%: $(APPS);
|
||||
|
||||
# target config: Fire APPS target
|
||||
.PHONY: config
|
||||
config: $(APPS)
|
||||
|
||||
# target copy: Copy files and folders to all APPS
|
||||
.PHONY: copy
|
||||
copy:
|
||||
$(foreach app,$(APPS),$(foreach file,$(ARGS),$(if $(wildcard $(file)),$(ECHO) $(if $(filter LINUX,$(HOST_SYSTEM)),cp -a --parents $(file) $(app)/,rsync -a $(file) $(app)/$(file)) &&)) true &&) true
|
||||
|
||||
# target deploy: Fire APPS target
|
||||
.PHONY: deploy
|
||||
deploy: $(APPS) ## Deploy applications
|
||||
|
||||
# target deploy@%: Fire APPS target
|
||||
.PHONY: deploy@%
|
||||
deploy@%: $(APPS);
|
||||
|
||||
# target down: Fire APPS target
|
||||
.PHONY: down
|
||||
down: $(APPS) ## Remove application dockers
|
||||
down: $(APPS) ## Remove applications dockers
|
||||
|
||||
# target install: Fire APPS target
|
||||
.PHONY: install
|
||||
install: $(APPS) ## Install applications
|
||||
|
||||
# target ps: Fire APPS target
|
||||
.PHONY: ps
|
||||
ps: $(APPS)
|
||||
|
||||
# target rebuild: Fire APPS target
|
||||
.PHONY: rebuild
|
||||
rebuild: $(APPS) ## Rebuild applications
|
||||
|
||||
# target recreate: Fire APPS target
|
||||
.PHONY: recreate
|
||||
recreate: $(APPS) ## Recreate applications
|
||||
|
||||
# target reinstall: Fire APPS target
|
||||
.PHONY: reinstall
|
||||
reinstall: $(APPS) ## Reinstall applications
|
||||
|
||||
# target release: Fire release-create target
|
||||
.PHONY: release
|
||||
release: release-create ## Create release VERSION
|
||||
|
||||
# target restart: Fire APPS target
|
||||
.PHONY: restart
|
||||
restart: $(APPS) ## Restart applications
|
||||
|
||||
# target start: Fire APPS target
|
||||
.PHONY: start
|
||||
start: $(APPS) ## Start applications
|
||||
|
||||
# target stop: Fire APPS target
|
||||
.PHONY: stop
|
||||
stop: $(APPS) ## Stop applications
|
||||
|
||||
# target tests: Fire APPS target
|
||||
.PHONY: tests
|
||||
tests: $(APPS) ## Test applications
|
||||
|
||||
# target up: Fire APPS target
|
||||
.PHONY: up
|
||||
up: $(APPS) ## Create application dockers
|
||||
up: $(APPS) ## Create applications dockers
|
||||
|
||||
# target update: Fire update-apps target
|
||||
.PHONY: update
|
||||
update: update-apps ## Update applications files
|
||||
|
||||
# target upgrade: Fire upgrade-apps and release-upgrade targets
|
||||
.PHONY: upgrade
|
||||
upgrade: upgrade-apps release-upgrade ## Upgrade applications
|
||||
|
||||
# target $(APPS): Call targets MAKECMDGOALS in folder $@
|
||||
.PHONY: $(APPS)
|
||||
$(APPS):
|
||||
$(if $(wildcard $@/Makefile), \
|
||||
$(call make,$(patsubst apps-%,%,$(MAKECMDGOALS)) STATUS=0,$(patsubst %/,%,$@),APP_PATH_PREFIX), \
|
||||
printf "${COLOR_BROWN}WARNING${COLOR_RESET}: ${COLOR_GREEN}no app available in folder${COLOR_RESET} $@.\n" >&2)
|
||||
|
||||
# run targets in $(APPS)
|
||||
# target apps-%: Fire $(APPS) target to call target % in $(APPS)
|
||||
.PHONY: apps-%
|
||||
apps-%: $(APPS) ; ## run % targets in $(APPS)
|
||||
apps-%: $(APPS) ;
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
##
|
||||
# RELEASE
|
||||
|
||||
.PHONY: release
|
||||
release: release-create ## Create release [version]
|
||||
|
||||
# target release-check: Define RELEASE_BRANCH and RELEASE_VERSION
|
||||
.PHONY: release-check
|
||||
release-check:
|
||||
ifneq ($(words $(ARGS)),0)
|
||||
@@ -18,13 +16,15 @@ endif
|
||||
$(if $(filter VERSION=%,$(MAKEFLAGS)), $(eval RELEASE_VERSION:=$(VERSION)) $(eval RELEASE_BRANCH := release/$(RELEASE_VERSION)))
|
||||
$(if $(findstring $(firstword $(subst /, ,$(RELEASE_BRANCH))),release),,$(error Please provide a VERSION or a release BRANCH))
|
||||
|
||||
# target release-create: Create release VERSION from upstream/develop branch
|
||||
.PHONY: release-create
|
||||
release-create: release-check git-stash ## Create release [version]
|
||||
release-create: release-check git-stash
|
||||
$(call make,git-branch-create-upstream-develop BRANCH=$(RELEASE_BRANCH))
|
||||
$(call make,git-unstash,,STATUS)
|
||||
|
||||
# target release-finish: Merge release VERSION in master branch
|
||||
.PHONY: release-finish
|
||||
release-finish: release-check git-stash ## Finish release [version]
|
||||
release-finish: release-check git-stash
|
||||
$(call make,git-branch-merge-upstream-master BRANCH=$(RELEASE_BRANCH))
|
||||
$(call make,subrepos-update)
|
||||
$(call make,git-tag-create-upstream-master TAG=$(RELEASE_VERSION))
|
||||
@@ -34,16 +34,16 @@ release-finish: release-check git-stash ## Finish release [version]
|
||||
$(call make,subrepos-branch-delete BRANCH=$(RELEASE_BRANCH))
|
||||
$(call make,git-unstash,,STATUS)
|
||||
|
||||
## Update release version number in .env
|
||||
# target release-update: Update RELEASE with RELEASE_VERSION in .env
|
||||
.PHONY: release-update
|
||||
release-update:
|
||||
$(ECHO) awk -v s=RELEASE=$(RELEASE_VERSION) '/^RELEASE=/{$$0=s;f=1} {a[++n]=$$0} END{if(!f)a[++n]=s;for(i=1;i<=n;i++)print a[i]>ARGV[1]}' .env
|
||||
|
||||
## Run migration targets to upgrade specific releases
|
||||
# target release-upgrade: Run migration targets to upgrade specific releases
|
||||
.PHONY: release-upgrade
|
||||
release-upgrade: $(patsubst %,release-upgrade-from-%,$(RELEASE_UPGRADE)) release-update ## Update monorepo version
|
||||
release-upgrade: $(patsubst %,release-upgrade-from-%,$(RELEASE_UPGRADE)) release-update ## Upgrade release
|
||||
|
||||
## Sample of release migration target
|
||||
# target release-upgrade-from-%: Sample of catch-all release migration target
|
||||
.PHONY: release-upgrade-from-%
|
||||
release-upgrade-from-%:
|
||||
echo "Upgrading from release: $*"
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
##
|
||||
# SUBREPO
|
||||
|
||||
## Delete branch $(BRANCH) on $(SUBREPO) remote
|
||||
# target subrepo-branch-delete: Delete branch $(BRANCH) on remote $(SUBREPO)
|
||||
.PHONY: subrepo-branch-delete
|
||||
subrepo-branch-delete: myos-base subrepo-check
|
||||
ifneq ($(words $(BRANCH)),0)
|
||||
$(call exec,[ $$(git ls-remote --heads $(REMOTE) $(BRANCH) |wc -l) -eq 1 ] && git push $(REMOTE) :$(BRANCH) || echo Unable to delete branch $(BRANCH) on remote $(REMOTE).)
|
||||
endif
|
||||
|
||||
# target subrepo-check: Define SUBREPO and REMOTE
|
||||
.PHONY: subrepo-check
|
||||
subrepo-check:
|
||||
ifeq ($(words $(ARGS)), 0)
|
||||
@@ -18,28 +19,31 @@ endif
|
||||
$(eval SUBREPO ?= $(word 1, $(ARGS)))
|
||||
$(eval REMOTE := subrepo/$(SUBREPO))
|
||||
|
||||
## Check if monorepo is up to date with subrepo. subrepo-push saves the parent commit in file subrepo/.gitrepo
|
||||
# target subrepo-git-diff: Check if monorepo is up to date with subrepo
|
||||
# subrepo-push saves the parent commit in file subrepo/.gitrepo
|
||||
## it gets parent commit in .gitrepo : awk '$1 == "parent" {print $3}' subrepo/.gitrepo
|
||||
## it gets child of parent commit : git rev-list --ancestry-path parent..HEAD |tail -n 1
|
||||
## it compares child commit with our tree : git diff --quiet child -- subrepo
|
||||
.PHONY: subrepo-git-diff
|
||||
subrepo-git-diff: myos-base subrepo-check
|
||||
## Get parent commit in .gitrepo : awk '$1 == "parent" {print $3}' subrepo/.gitrepo
|
||||
## Get child of parent commit : git rev-list --ancestry-path parent..HEAD |tail -n 1
|
||||
## Compare child commit with our tree : git diff --quiet child -- subrepo
|
||||
$(eval DRYRUN_IGNORE := true)
|
||||
$(eval DIFF = $(shell $(call exec,git diff --quiet $(shell $(call exec,git rev-list --ancestry-path $(shell awk '$$1 == "parent" {print $$3}' $(SUBREPO)/.gitrepo)..HEAD |tail -n 1)) -- $(SUBREPO); echo $$?)) )
|
||||
$(eval DRYRUN_IGNORE := false)
|
||||
|
||||
# target subrepo-git-fetch: Fetch git remote
|
||||
.PHONY: subrepo-git-fetch
|
||||
subrepo-git-fetch: myos-base subrepo-check
|
||||
$(call exec,git fetch --prune $(REMOTE))
|
||||
|
||||
# target subrepo-tag-create-%: Create tag TAG to reference branch REMOTE/%
|
||||
.PHONY: subrepo-tag-create-%
|
||||
subrepo-tag-create-%: myos-base subrepo-check subrepo-git-fetch ## Create $(TAG) tag to reference $(REMOTE)/$* branch
|
||||
subrepo-tag-create-%: myos-base subrepo-check subrepo-git-fetch
|
||||
ifneq ($(words $(TAG)),0)
|
||||
$(call exec,[ $$(git ls-remote --tags $(REMOTE) $(TAG) |wc -l) -eq 0 ] || git push $(REMOTE) :refs/tags/$(TAG))
|
||||
$(call exec,git push $(REMOTE) refs/remotes/subrepo/$(SUBREPO)/$*:refs/tags/$(TAG))
|
||||
endif
|
||||
|
||||
## Push to subrepo.
|
||||
# target subrepo-push: Push to subrepo
|
||||
.PHONY: subrepo-push
|
||||
subrepo-push: myos-base subrepo-check subrepo-git-fetch subrepo-git-diff
|
||||
# update .gitrepo only on master branch
|
||||
@@ -66,16 +70,20 @@ endif
|
||||
$(call exec,git subrepo clean $(SUBREPO)); \
|
||||
fi
|
||||
|
||||
# target subrepos-branch-delete: Fire APPS target
|
||||
.PHONY: subrepos-branch-delete
|
||||
subrepos-branch-delete: $(APPS) ;
|
||||
|
||||
# target subrepos-tag-create-%: Fire APPS target
|
||||
.PHONY: subrepos-tag-create-%
|
||||
subrepos-tag-create-%: $(APPS) ;
|
||||
|
||||
# target subrepos-update: Fire APPS target and push updates to upstream
|
||||
.PHONY: subrepos-update
|
||||
subrepos-update: myos-base git-stash $(APPS) git-unstash ## Update subrepos
|
||||
$(call exec,git push upstream $(BRANCH))
|
||||
|
||||
# target subrepo-update-%: Call subrepo-update target in folder %
|
||||
.PHONY: subrepo-update-%
|
||||
subrepo-update-%:
|
||||
$(if $(wildcard $*/Makefile),$(call make,subrepo-update,$*))
|
||||
|
||||
Reference in New Issue
Block a user