This commit is contained in:
aynic.os
2021-05-31 03:45:39 +02:00
parent c9821467de
commit 0996e2a355
24 changed files with 176 additions and 211 deletions
+1 -70
View File
@@ -1,7 +1,7 @@
##
# GIT
## Check if monorepo is up to date with subrepo. subrepo-push saves the parent commit in .gitrepo
## Check if monorepo is up to date with subrepo. subrepo-push saves the parent commit in file subrepo/.gitrepo
.PHONY: git-diff-subrepo
git-diff-subrepo: myos-base subrepo-check
## Get parent commit in .gitrepo : awk '$1 == "parent" {print $3}' subrepo/.gitrepo
@@ -14,72 +14,3 @@ git-diff-subrepo: myos-base subrepo-check
.PHONY: git-fetch-subrepo
git-fetch-subrepo: myos-base subrepo-check
$(call exec,git fetch --prune $(REMOTE))
.PHONY: git-stash
git-stash: myos-base git-status
if [ ! $(STATUS) -eq 0 ]; then \
$(call exec,git stash); \
fi
.PHONY: git-status
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: myos-base
$(eval STATUS ?= 0)
if [ ! $(STATUS) -eq 0 ]; then \
$(call exec,git stash pop); \
fi
# Create branch $(BRANCH) from upstream/$* branch
.PHONY: branch-create-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.)
$(call exec,git checkout $(BRANCH))
# Delete branch $(BRANCH)
.PHONY: branch-delete
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-%: 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))
$(call exec,git push upstream $(BRANCH))
$(call exec,git checkout $*)
$(call exec,git pull --ff-only upstream $*)
$(call exec,git merge --no-ff --no-edit $(BRANCH))
$(call exec,git push upstream $*)
# Create $(TAG) tag to reference upstream/$* branch
.PHONY: tag-create-upstream-%
tag-create-upstream-%: myos-base update-upstream
ifneq ($(words $(TAG)),0)
$(call exec,git checkout $*)
$(call exec,git pull --tags --prune upstream $*)
$(call sed,s/^##\? $(TAG).*/## $(TAG) - $(shell date +%Y-%m-%d)/,CHANGELOG.md)
$(call exec,[ $$(git diff CHANGELOG.md 2>/dev/null |wc -l) -eq 0 ] || git commit -m "$$(cat CHANGELOG.md |sed -n '\''/$(TAG)/,/^$$/{s/##\(.*\)/release\1\n/;p;}'\'')" CHANGELOG.md)
$(call exec,[ $$(git tag -l $(TAG) |wc -l) -eq 0 ] || git tag -d $(TAG))
$(call exec,git tag $(TAG))
$(call exec,[ $$(git ls-remote --tags upstream $(TAG) |wc -l) -eq 0 ] || git push upstream :refs/tags/$(TAG))
$(call exec,git push --tags upstream $*)
endif
# Merge tag $(TAG) into upstream/$* branch
.PHONY: tag-merge-upstream-%
tag-merge-upstream-%: myos-base update-upstream
ifneq ($(words $(TAG)),0)
$(call exec,git fetch --tags -u --prune upstream $*:$*)
$(call exec,git checkout $*)
$(call exec,git merge --ff --no-edit $(TAG))
$(call exec,git push upstream $*)
endif
+6 -6
View File
@@ -2,7 +2,7 @@
# RELEASE
.PHONY: release
release: release-create # Create release [version]
release: release-create ## Create release [version]
.PHONY: release-check
release-check:
@@ -20,16 +20,16 @@ endif
.PHONY: release-create
release-create: release-check git-stash ## Create release [version]
$(call make,branch-create-upstream-develop BRANCH=$(RELEASE_BRANCH))
$(call make,git-branch-create-upstream-develop BRANCH=$(RELEASE_BRANCH))
$(call make,git-unstash,,STATUS)
.PHONY: release-finish
release-finish: release-check git-stash ## Finish release [version]
$(call make,branch-merge-upstream-master BRANCH=$(RELEASE_BRANCH))
$(call make,git-branch-merge-upstream-master BRANCH=$(RELEASE_BRANCH))
$(call make,update-subrepos)
$(call make,tag-create-upstream-master TAG=$(RELEASE_VERSION))
$(call make,git-tag-create-upstream-master TAG=$(RELEASE_VERSION))
$(call make,subrepos-tag-create-master TAG=$(RELEASE_VERSION))
$(call make,tag-merge-upstream-develop TAG=$(RELEASE_VERSION))
$(call make,branch-delete BRANCH=$(RELEASE_BRANCH))
$(call make,git-tag-merge-upstream-develop TAG=$(RELEASE_VERSION))
$(call make,git-branch-delete BRANCH=$(RELEASE_BRANCH))
$(call make,subrepos-branch-delete BRANCH=$(RELEASE_BRANCH))
$(call make,git-unstash,,STATUS)
+1 -1
View File
@@ -12,7 +12,7 @@ endif
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): MAKE_ENV_VARS += SSH_BASTION_HOSTNAME SSH_BASTION_USERNAME SSH_PRIVATE_IP_RANGE SSH_PUBLIC_HOST_KEYS
$(PARAMETERS): myos-base
$(call exec,[ -d $(PARAMETERS) ] && cd $(PARAMETERS) && git pull --quiet || git clone --quiet $(APP_PARAMETERS_REPOSITORY))