wip
This commit is contained in:
@@ -59,7 +59,7 @@ up: $(APPS) ## Create application dockers
|
||||
.PHONY: $(APPS)
|
||||
$(APPS):
|
||||
$(if $(wildcard $@/Makefile), \
|
||||
$(call make,-o install-infra $(patsubst apps-%,%,$(MAKECMDGOALS)) STATUS=0,$(patsubst %/,%,$@),ENV_SUFFIX), \
|
||||
$(call make,-o install-myos $(patsubst apps-%,%,$(MAKECMDGOALS)) STATUS=0,$(patsubst %/,%,$@),ENV_SUFFIX), \
|
||||
printf "${COLOR_BROWN}WARNING${COLOR_RESET}: ${COLOR_GREEN}no app available in folder${COLOR_RESET} $@.\n" >&2)
|
||||
|
||||
# run targets in $(APPS)
|
||||
|
||||
@@ -9,7 +9,7 @@ COMMIT_AFTER := $(DRONE_TAG)
|
||||
COMMIT_BEFORE := $(shell git describe --abbrev=0 --tags $(DRONE_TAG)^)
|
||||
endif
|
||||
APPS_IMPACTED := $(shell git diff --name-only $(COMMIT_BEFORE) $(COMMIT_AFTER) 2>/dev/null |awk -F '/' 'NF>1 && !seen[$$1]++ {print $$1}')
|
||||
# prevent drone to make down in infra
|
||||
APPS := $(if $(filter-out down,$(MAKECMDGOALS)),$(filter $(INFRA),$(APPS_IMPACTED))) $(sort $(filter-out $(DIRS) $(INFRA),$(APPS_IMPACTED)))
|
||||
# prevent drone to make down myos
|
||||
APPS := $(if $(filter-out down,$(MAKECMDGOALS)),$(filter $(MYOS),$(APPS_IMPACTED))) $(sort $(filter-out $(DIRS) $(MYOS),$(APPS_IMPACTED)))
|
||||
CONTEXT += DRONE_BRANCH DRONE_BUILD_EVENT DRONE_BUILD_NUMBER DRONE_COMMIT_AFTER DRONE_COMMIT_AUTHOR DRONE_COMMIT_AUTHOR_EMAIL DRONE_COMMIT_BEFORE DRONE_COMMIT_REF GIT_AUTHOR_EMAIL GIT_AUTHOR_NAME
|
||||
endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
APPS ?= $(INFRA) $(sort $(filter-out $(DIRS) $(INFRA), $(patsubst %/,%,$(wildcard */)) ))
|
||||
APPS ?= $(MYOS) $(sort $(filter-out $(DIRS) $(MYOS), $(patsubst %/,%,$(wildcard */)) ))
|
||||
APPS_NAME ?= $(foreach app,$(APPS),$(or $(shell awk -F '=' '$$1 == "APP" {print $$2}' $(or $(wildcard $(app)/.env),$(wildcard $(app)/.env.$(ENV)),$(app)/.env.dist) 2>/dev/null),$(app)))
|
||||
CMDS += copy master-tag release release-check release-create release-finish subrepo-push update-subrepo
|
||||
CONTEXT += APPS APPS_NAME ENV RELEASE_INSTALL
|
||||
|
||||
+10
-10
@@ -3,7 +3,7 @@
|
||||
|
||||
## Check if monorepo is up to date with subrepo. subrepo-push saves the parent commit in .gitrepo
|
||||
.PHONY: git-diff-subrepo
|
||||
git-diff-subrepo: infra-base subrepo-check
|
||||
git-diff-subrepo: 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
|
||||
@@ -12,23 +12,23 @@ git-diff-subrepo: infra-base subrepo-check
|
||||
$(eval DRYRUN_IGNORE := false)
|
||||
|
||||
.PHONY: git-fetch-subrepo
|
||||
git-fetch-subrepo: infra-base subrepo-check
|
||||
git-fetch-subrepo: myos-base subrepo-check
|
||||
$(call exec,git fetch --prune $(REMOTE))
|
||||
|
||||
.PHONY: git-stash
|
||||
git-stash: infra-base git-status
|
||||
git-stash: myos-base git-status
|
||||
if [ ! $(STATUS) -eq 0 ]; then \
|
||||
$(call exec,git stash); \
|
||||
fi
|
||||
|
||||
.PHONY: git-status
|
||||
git-status: infra-base
|
||||
git-status: myos-base
|
||||
$(eval DRYRUN_IGNORE := true)
|
||||
$(eval STATUS := $(shell $(call exec,git status -uno --porcelain 2>/dev/null |wc -l)))
|
||||
$(eval DRYRUN_IGNORE := false)
|
||||
|
||||
.PHONY: git-unstash
|
||||
git-unstash: infra-base
|
||||
git-unstash: myos-base
|
||||
$(eval STATUS ?= 0)
|
||||
if [ ! $(STATUS) -eq 0 ]; then \
|
||||
$(call exec,git stash pop); \
|
||||
@@ -36,7 +36,7 @@ git-unstash: infra-base
|
||||
|
||||
# Create branch $(BRANCH) from upstream/$* branch
|
||||
.PHONY: branch-create-upstream-%
|
||||
branch-create-upstream-%: infra-base update-upstream
|
||||
branch-create-upstream-%: myos-base update-upstream
|
||||
$(call exec,git fetch --prune upstream)
|
||||
$(call exec,git rev-parse --verify $(BRANCH) >/dev/null 2>&1 && echo Unable to create $(BRANCH). || git branch $(BRANCH) upstream/$*)
|
||||
$(call exec,[ $$(git ls-remote --heads upstream $(BRANCH) |wc -l) -eq 0 ] && git push upstream $(BRANCH) || echo Unable to create branch $(BRANCH) on remote upstream.)
|
||||
@@ -44,13 +44,13 @@ branch-create-upstream-%: infra-base update-upstream
|
||||
|
||||
# Delete branch $(BRANCH)
|
||||
.PHONY: branch-delete
|
||||
branch-delete: infra-base update-upstream
|
||||
branch-delete: myos-base update-upstream
|
||||
$(call exec,git rev-parse --verify $(BRANCH) >/dev/null 2>&1 && git branch -d $(BRANCH) || echo Unable to delete branch $(BRANCH).)
|
||||
$(foreach remote,upstream, $(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).) &&) true
|
||||
|
||||
# Merge branch $(BRANCH) into upstream/$* branch
|
||||
.PHONY: branch-merge-upstream-%
|
||||
branch-merge-upstream-%: infra-base update-upstream
|
||||
branch-merge-upstream-%: myos-base update-upstream
|
||||
$(call exec,git rev-parse --verify $(BRANCH) >/dev/null 2>&1)
|
||||
$(call exec,git checkout $(BRANCH))
|
||||
$(call exec,git pull --ff-only upstream $(BRANCH))
|
||||
@@ -62,7 +62,7 @@ branch-merge-upstream-%: infra-base update-upstream
|
||||
|
||||
# Create $(TAG) tag to reference upstream/$* branch
|
||||
.PHONY: tag-create-upstream-%
|
||||
tag-create-upstream-%: infra-base update-upstream
|
||||
tag-create-upstream-%: myos-base update-upstream
|
||||
ifneq ($(words $(TAG)),0)
|
||||
$(call exec,git checkout $*)
|
||||
$(call exec,git pull --tags --prune upstream $*)
|
||||
@@ -76,7 +76,7 @@ endif
|
||||
|
||||
# Merge tag $(TAG) into upstream/$* branch
|
||||
.PHONY: tag-merge-upstream-%
|
||||
tag-merge-upstream-%: infra-base update-upstream
|
||||
tag-merge-upstream-%: myos-base update-upstream
|
||||
ifneq ($(words $(TAG)),0)
|
||||
$(call exec,git fetch --tags -u --prune upstream $*:$*)
|
||||
$(call exec,git checkout $*)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
##
|
||||
# INSTALL
|
||||
|
||||
.PHONY: install-infra
|
||||
install-infra: infra-install
|
||||
.PHONY: install-myos
|
||||
install-myos: myos-install
|
||||
|
||||
.PHONY: install-$(SHARED)
|
||||
install-$(SHARED): $(SHARED)
|
||||
|
||||
@@ -13,13 +13,13 @@ endif
|
||||
|
||||
## Delete branch $(BRANCH) on $(SUBREPO) remote
|
||||
.PHONY: subrepo-branch-delete
|
||||
subrepo-branch-delete: infra-base subrepo-check
|
||||
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
|
||||
|
||||
.PHONY: subrepo-tag-create-%
|
||||
subrepo-tag-create-%: infra-base subrepo-check git-fetch-subrepo ## Create $(TAG) tag to reference $(REMOTE)/$* branch
|
||||
subrepo-tag-create-%: myos-base subrepo-check git-fetch-subrepo ## Create $(TAG) tag to reference $(REMOTE)/$* branch
|
||||
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))
|
||||
@@ -27,7 +27,7 @@ endif
|
||||
|
||||
## Push to subrepo.
|
||||
.PHONY: subrepo-push
|
||||
subrepo-push: infra-base subrepo-check git-fetch-subrepo git-diff-subrepo
|
||||
subrepo-push: myos-base subrepo-check git-fetch-subrepo git-diff-subrepo
|
||||
# update .gitrepo only on master branch
|
||||
ifeq ($(BRANCH),master)
|
||||
$(eval UPDATE_SUBREPO_OPTIONS += -u)
|
||||
|
||||
@@ -13,7 +13,7 @@ update-$(PARAMETERS): $(PARAMETERS)
|
||||
|
||||
$(PARAMETERS): SSH_PUBLIC_HOST_KEYS := $(PARAMETERS_REMOTE_HOST) $(SSH_BASTION_HOSTNAME) $(SSH_REMOTE_HOSTS)
|
||||
$(PARAMETERS): MAKE_VARS += SSH_BASTION_HOSTNAME SSH_BASTION_USERNAME SSH_PRIVATE_IP_RANGE SSH_PUBLIC_HOST_KEYS
|
||||
$(PARAMETERS): infra-base
|
||||
$(PARAMETERS): myos-base
|
||||
$(call exec,[ -d $(PARAMETERS) ] && cd $(PARAMETERS) && git pull --quiet || git clone --quiet $(GIT_PARAMETERS_REPOSITORY))
|
||||
|
||||
## Update release version number in .env
|
||||
@@ -23,16 +23,16 @@ update-release:
|
||||
|
||||
## Update remotes
|
||||
.PHONY: update-remotes
|
||||
update-remotes: infra-base
|
||||
update-remotes: myos-base
|
||||
$(call exec,git fetch --all --prune --tags -u)
|
||||
|
||||
.PHONY: update-remote-%
|
||||
update-remote-%: infra-base
|
||||
update-remote-%: myos-base
|
||||
$(call exec,git fetch --prune --tags -u $*)
|
||||
|
||||
## Update subrepos
|
||||
.PHONY: update-subrepos
|
||||
update-subrepos: infra-base git-stash $(APPS) git-unstash ## Update subrepos
|
||||
update-subrepos: myos-base git-stash $(APPS) git-unstash ## Update subrepos
|
||||
$(call exec,git push upstream $(BRANCH))
|
||||
|
||||
.PHONY: update-subrepo-%
|
||||
@@ -40,8 +40,8 @@ update-subrepo-%:
|
||||
$(if $(wildcard $*/Makefile),$(call make,update-subrepo,$*))
|
||||
|
||||
.PHONY: update-upstream
|
||||
update-upstream: infra-base .git/refs/remotes/upstream/master
|
||||
update-upstream: myos-base .git/refs/remotes/upstream/master
|
||||
$(call exec,git fetch --tags upstream)
|
||||
|
||||
.git/refs/remotes/upstream/master: infra-base
|
||||
.git/refs/remotes/upstream/master: myos-base
|
||||
$(call exec,git remote add upstream $(GIT_UPSTREAM_REPOSITORY) 2>/dev/null ||:)
|
||||
|
||||
Reference in New Issue
Block a user