@@ -5,20 +5,22 @@ NEXT_VERSION := $(shell printf "%02d" "$$(($(VERSION_NOZERO) + 1))")
55PREV_VERSION := $(shell printf "% 02d" "$$(($(VERSION_NOZERO ) - 1 ) ) ")
66SBASE := $(patsubst draft-% ,% ,$(BASE ) )
77# DTYPE := $(word 2,$(subst -, ,$(BASE)))
8- PBRANCH : = publish-$(SBASE ) -$(VERSION )
8+ PBRANCH ? = publish-$(SBASE ) -$(VERSION )
99PBASE := publish/$(BASE ) -$(VERSION )
1010VBASE := draft/$(BASE ) -$(VERSION )
1111LBASE := draft/$(BASE ) -latest
1212SHELL := /bin/bash
1313MAIN_BRANCH ?= main # older repos set to master
14- PUSH_TO_REMOTE ?= yes
14+ PUSH_TO_REMOTE ?= origin
1515
1616# If you have docker you can avoid having to install anything by leaving this.
1717ifeq ($(CIRCLECI ) ,)
1818export DOCKRUN ?= docker run --user $(shell id -u) --network=host -v $$(pwd ) :/work labn/org-rfc
1919endif
2020EMACSCMD := $(DOCKRUN ) emacs -Q --batch --debug-init --eval '(setq-default indent-tabs-mode nil)' --eval '(setq org-confirm-babel-evaluate nil)' -l ./ox-rfc.el
2121
22+ BRANCH_EXISTS := $(shell git rev-parse --verify $(MAIN_BRANCH ) 2>/dev/null)
23+
2224all : $(LBASE ) .xml $(LBASE ) .txt $(LBASE ) .html # $(LBASE).pdf
2325
2426clean :
3638 git push $(PUSH_TO_REMOTE) -f --tags
3739endif
3840
41+
42+ .PHONY : main-branch-check
43+ main-branch-check :
44+ ifeq ($(BRANCH_EXISTS ) ,)
45+ $(error Branch '$(MAIN_BRANCH)' does not exist. Exiting.)
46+ endif
47+
3948.PHONY : publish
40- publish : git-clean-check $(VBASE ) .xml $(VBASE ) .txt $(VBASE ) .html
49+ publish : main-branch-check git-clean-check $(VBASE ) .xml $(VBASE ) .txt $(VBASE ) .html
4150 if [ -f $( PBASE) .xml ]; then echo " $( PBASE) .xml already present, increment version?" ; exit 1; fi
4251 @mkdir -p publish
4352 cp $(VBASE ) .xml $(VBASE ) .txt $(VBASE ) .html publish
@@ -46,11 +55,12 @@ publish: git-clean-check $(VBASE).xml $(VBASE).txt $(VBASE).html
4655 git add $(PBASE ) .xml $(PBASE ) .txt $(PBASE ) .html
4756 git commit -m " yank.mk: publish-$( SBASE) -$( VERSION) "
4857 git tag -m " yank.mk: published-$( SBASE) -$( VERSION) " published-$(SBASE ) -$(VERSION )
49- $(MAKE ) push_to_remote
58+ $(MAKE ) PBRANCH= $( PBRANCH ) push_to_remote
5059 git checkout $(MAIN_BRANCH )
5160 git merge --ff-only $(PBRANCH )
5261 sed -i -e ' s/\#+RFC_VERSION: *\([0-9]*\)/\#+RFC_VERSION: $(NEXT_VERSION)/' $(ORG )
5362 git commit -am " yank.mk: new version -$( NEXT_VERSION) post-publish $( SBASE) -$( VERSION) "
63+ $(MAKE ) PBRANCH=$(MAIN_BRANCH ) push_to_remote
5464
5565# republish:
5666# sed -i -e 's/\#+RFC_VERSION: *\([0-9]*\)/\#+RFC_VERSION: $(PREV_VERSION)/' $(ORG)
0 commit comments