|
1 |
| -define nl |
2 |
| - |
3 |
| - |
4 |
| -endef |
5 |
| - |
6 |
| -subtree-preflight: |
7 |
| - @if ! grep -q -e 'has_been_added' $$(PATH=$$(git --exec-path):$$PATH which git-subtree 2>/dev/null) /dev/null; then \ |
8 |
| - printf '$(RED)Please upgrade your git-subtree:$(END)\n'; \ |
9 |
| - printf '$(BLD) sudo curl -fL https://raw.githubusercontent.com/LukeShu/git/lukeshu/next/2021-05-15/contrib/subtree/git-subtree.sh -o $$(git --exec-path)/git-subtree && sudo chmod 755 $$(git --exec-path)/git-subtree$(END)\n'; \ |
10 |
| - false; \ |
11 |
| - else \ |
12 |
| - printf '$(GRN)git-subtree OK$(END)\n'; \ |
| 1 | +# Ensure that the telepresence remote is up-to-date. |
| 2 | +telepresence-remote: |
| 3 | + @if [ "$$(git remote | grep -E '^telepresence$$')" = 'telepresence' ]; then\ |
| 4 | + git remote update telepresence;\ |
| 5 | + else\ |
| 6 | + git remote add -f telepresence [email protected]:telepresenceio/telepresence.git ;\ |
13 | 7 | fi
|
14 |
| - git gc |
15 |
| -.PHONY: subtree-preflight |
| 8 | +.PHONY: telepresence-remote |
16 | 9 |
|
17 |
| -PULL_PREFIX ?= |
18 |
| -PUSH_PREFIX ?= $(USER)/from-telepresence.io-$(shell date +%Y-%m-%d)/ |
| 10 | +# MATCH_TAGS is the regexp matching the tags that we expect will have docs. |
| 11 | +MATCH_TAGS ?= ^v2\.[2-9][0-9]+\.[0-9]+(-(rc|test)\.[0-9]+)$$ |
19 | 12 |
|
20 |
| -dir2branch = $(patsubst docs/%,release/%,$(subst pre-release,v2,$1)) |
| 13 | +# EXCLUDE_TAGS is used when we want to exclude some of the matching tags from the telepresence repository |
| 14 | +EXCLUDE_TAGS ?= |
21 | 15 |
|
22 |
| -# Used when syncing from telepresenceio since that repo doesn't |
23 |
| -# have docs for v1. |
24 |
| -EXCLUDE_DIR ?= "" |
25 |
| -pull-docs: ## Update ./docs from https://github.com/telepresenceio/docs |
26 |
| -pull-docs: subtree-preflight |
27 |
| - $(foreach subdir,$(shell find docs -mindepth 1 -maxdepth 1 -type d -not -name $(EXCLUDE_DIR)|sort -V),\ |
28 |
| - git subtree pull --squash --prefix=$(subdir) https://github.com/telepresenceio/docs $(PULL_PREFIX)$(call dir2branch,$(subdir))$(nl)) |
| 16 | +# Update the docs at docs/v<major>.<minor> from the found tags. |
| 17 | +pull-docs: |
| 18 | + $(foreach release,$(shell git tag -l | grep -E '$(MATCH_TAGS)' | (test -n '$(EXCLUDE_TAGS)' && grep -vE '$(EXCLUDE_TAGS)' || cat) | sort -V),\ |
| 19 | + dir=$$(expr '$(release)' : '\(v[0-9]\.[0-9][0-9]*\)');\ |
| 20 | + echo $$dir;\ |
| 21 | + rm -rf docs/$$dir;\ |
| 22 | + git add docs;\ |
| 23 | + git read-tree --prefix docs/$$dir -u $(release):docs) |
29 | 24 | .PHONY: pull-docs
|
30 |
| - |
31 |
| -PUSH_BRANCH ?= $(USER)/from-telepresence.io-$(shell date +%Y-%m-%d) |
32 |
| -push-docs: ## Publish ./ambassador to https://github.com/telepresenceio/docs |
33 |
| -push-docs: subtree-preflight |
34 |
| - @PS4=; set -x; { \ |
35 |
| - git remote add --no-tags remote-docs https://github.com/telepresenceio/docs && \ |
36 |
| - git remote set-url --push remote-docs [email protected]:telepresenceio/docs && \ |
37 |
| - :; } || true |
38 |
| - git fetch --prune remote-docs |
39 |
| - $(foreach subdir,$(shell find docs -mindepth 1 -maxdepth 1 -type d|sort -V),\ |
40 |
| - git subtree push --rejoin --squash --prefix=$(subdir) remote-docs $(PUSH_PREFIX)$(call dir2branch,$(subdir))$(nl)) |
41 |
| -.PHONY: push-docs |
0 commit comments