generated from mmistakes/mm-github-pages-starter
-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathGNUmakefile
175 lines (147 loc) · 5.86 KB
/
GNUmakefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
SHELL := /bin/bash
PWD ?= pwd_unknown
THIS_FILE := $(lastword $(MAKEFILE_LIST))
export THIS_FILE
TIME := $(shell date +%s)
export TIME
ARCH :=$(shell uname -m)
export ARCH
ifeq ($(ARCH),x86_64)
TRIPLET :=x86_64-linux-gnu
export TRIPLET
endif
ifeq ($(ARCH),arm64)
TRIPLET :=aarch64-linux-gnu
export TRIPLET
endif
PYTHON := $(shell which python)
export PYTHON
PYTHON2 := $(shell which python2)
export PYTHON2
PYTHON3 := $(shell which python3)
export PYTHON3
PIP := $(shell which pip)
export PIP
PIP2 := $(shell which pip2)
export PIP2
PIP3 := $(shell which pip3)
export PIP3
python_version_full := $(wordlist 2,4,$(subst ., ,$(shell python3 --version 2>&1)))
python_version_major := $(word 1,${python_version_full})
python_version_minor := $(word 2,${python_version_full})
python_version_patch := $(word 3,${python_version_full})
my_cmd.python.3 := $(PYTHON3) some_script.py3
my_cmd := ${my_cmd.python.${python_version_major}}
PYTHON_VERSION := ${python_version_major}.${python_version_minor}.${python_version_patch}
PYTHON_VERSION_MAJOR := ${python_version_major}
PYTHON_VERSION_MINOR := ${python_version_minor}
export python_version_major
export python_version_minor
export python_version_patch
export PYTHON_VERSION
PORT:=8000
#GIT CONFIG
GIT_USER_NAME := $(shell git config user.name)
export GIT_USER_NAME
GIT_USER_EMAIL := $(shell git config user.email)
export GIT_USER_EMAIL
GIT_SERVER := https://github.com
export GIT_SERVER
PROJECT_NAME := $(notdir $(PWD))
GIT_REPO_NAME := $(PROJECT_NAME)
export GIT_REPO_NAME
#Usage
#make package-all profile=rsafier
#make package-all profile=asherp
#note on GH_TOKEN.txt file below
GIT_PROFILE := pgp-guide
export GIT_PROFILE
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
export GIT_BRANCH
GIT_HASH := $(shell git rev-parse --short HEAD)
export GIT_HASH
GIT_PREVIOUS_HASH := $(shell git rev-parse --short HEAD^1)
export GIT_PREVIOUS_HASH
GIT_REPO_ORIGIN := $(shell git remote get-url origin)
export GIT_REPO_ORIGIN
GIT_REPO_PATH := $(HOME)/$(GIT_REPO_NAME)
export GIT_REPO_PATH
.PHONY: - help init build serve push signin git-add
-:
#NOTE: 2 hashes are detected as 1st column output with color
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?##/ {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
help:## print verbose help
## test
## test
## test
## test
help:
@sed -n 's/^## //p' ${MAKEFILE_LIST} | column -t -s ':' | sed -e 's/^/ /'
.PHONY: report
report:## report
@echo ''
@echo ' [ARGUMENTS] '
@echo ' args:'
@echo ' - THIS_FILE=${THIS_FILE}'
@echo ' - TIME=${TIME}'
@echo ' - PROJECT_NAME=${PROJECT_NAME}'
@echo ' - HOME=${HOME}'
@echo ' - PWD=${PWD}'
@echo ' - PYTHON=${PYTHON}'
@echo ' - PYTHON3=${PYTHON3}'
@echo ' - PYTHON_VERSION=${PYTHON_VERSION}'
@echo ' - PYTHON_VERSION_MAJOR=${PYTHON_VERSION_MAJOR}'
@echo ' - PYTHON_VERSION_MINOR=${PYTHON_VERSION_MINOR}'
@echo ' - PIP=${PIP}'
@echo ' - PIP3=${PIP3}'
@echo ' - ARCH=${ARCH}'
@echo ' - TRIPLET=${TRIPLET}'
@echo ' - PORT=${PORT}'
@echo ' - GIT_USER_NAME=${GIT_USER_NAME}'
@echo ' - GIT_USER_EMAIL=${GIT_USER_EMAIL}'
@echo ' - GIT_SERVER=${GIT_SERVER}'
@echo ' - GIT_PROFILE=${GIT_PROFILE}'
@echo ' - GIT_BRANCH=${GIT_BRANCH}'
@echo ' - GIT_HASH=${GIT_HASH}'
@echo ' - GIT_PREVIOUS_HASH=${GIT_PREVIOUS_HASH}'
@echo ' - GIT_REPO_ORIGIN=${GIT_REPO_ORIGIN}'
@echo ' - GIT_REPO_NAME=${GIT_REPO_NAME}'
@echo ' - GIT_REPO_PATH=${GIT_REPO_PATH}'
init:## init
python3 -m pip install -U -r requirements.txt
docs:build## build docs (no serve)
build:
mkdocs build
serve:build## build and serve docs
mkdocs serve & open http://127.0.0.1:$(PORT) || open http://127.0.0.1:$(PORT)
#$(PYTHON3) -m http.server $(PORT) --bind 127.0.0.1 -d $(PWD)/docs > /dev/null 2>&1 || open http://127.0.0.1:$(PORT)
.PHONY: venv
venv:## create python3 virtualenv .venv
test -d .venv || $(PYTHON3) -m virtualenv .venv
( \
source .venv/bin/activate; pip install -r requirements.txt; \
);
@echo "To activate (venv)"
@echo "try:"
@echo ". .venv/bin/activate"
@echo "or:"
@echo "make test-venv"
##: test-venv source .venv/bin/activate; pip install -r requirements.txt;
test-venv:## test virutalenv .venv
# insert test commands here
test -d .venv || $(PYTHON3) -m virtualenv .venv
( \
source .venv/bin/activate; pip install -r requirements.txt; \
);
push:
@echo 'push'
#bash -c "git reset --soft HEAD~1 || echo failed to add docs..."
#bash -c "git add README.md docker/README.md docker/DOCKER.md *.md docker/*.md || echo failed to add docs..."
#bash -c "git commit --amend --no-edit --allow-empty -m '$(GIT_HASH)' || echo failed to commit --amend --no-edit"
#bash -c "git commit --no-edit --allow-empty -m '$(GIT_PREVIOUS_HASH)' || echo failed to commit --amend --no-edit"
bash -c "git push -f --all [email protected]:$(GIT_PROFILE)/$(PROJECT_NAME).git || echo failed to push docs"
SIGNIN=randymcmillan
export SIGNIN
signin:
#Place a file named GH_TOKEN.txt in your $HOME - create in https://github.com/settings/tokens (Personal access tokens)
bash -c 'cat ~/GH_TOKEN.txt | docker login ghcr.io -u $(GIT_PROFILE) --password-stdin'