This repository has been archived by the owner on Mar 30, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
197 lines (127 loc) · 5.58 KB
/
Makefile
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
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
## This is a Makefile template for code publication on GitHub.
## Repository on GitHub: https://github.com/Paveloom/B1
## Documentation: https://www.notion.so/paveloom/B1-fefcaf42ddf541d4b11cfcab63c2f018
## Release version: 2.1.2
## Documentation version: 2.1.0
## Author: Pavel Sobolev (http://paveloom.tk)
## Make sure that your text editor visually displays a tabulation
## symbol equally to the visual representation of five spaces.
# Makefile settings
## Name of your build tool
make_name := make
## Specifying the shell
SHELL := /bin/bash
## Telling makefile to execute all rules using one instance of the shell
.ONESHELL :
## Special target to make Makefile silent
## (without rules specifications suppresses output from all rules)
.SILENT :
## Phony targets
.PHONY : git, final, new, del, git-am, archive
## Default rule when calling `make`
ALL : git
# Block of the rules for code publication on GitHub
## Username on GitHub
username := Paveloom
## Feature branch name
FEATURE_BRANCH := feature
## Rule for creation and publishing of a commit
git :
# Determining current branch
CURRENT_BRANCH=$$(git status | head -n 1 | cut -d " " -f 3)
# Checking the current branch
if [ "$$CURRENT_BRANCH" = "${FEATURE_BRANCH}" ]; then
# Determining the last tag
LAST_TAG=$$(git describe --tag)
# Determining if last commit has a tag
if echo $$LAST_TAG | grep -qv "-"; then
# Checking if the last commit is a generated one
if echo $$LAST_TAG | grep -q "_"; then
# Determining the number of the last commit
CURRENT_NUMBER=$$(echo $$LAST_TAG | grep -o "_[0-9]\+" | sed 's/_//')
# Iterating the current number
NEXT_NUMBER=$$(( $$CURRENT_NUMBER + 1 ))
# Creating a new tag
NEXT_TAG=$$(echo $$LAST_TAG | sed "s/_$$CURRENT_NUMBER/_$$NEXT_NUMBER/")
# Creating a commit
git add -A
git commit -e
# Checking if a commit was created
if [ $$? -eq 0 ]; then
# Tagging the new tag
git tag -a $$NEXT_TAG -m "$$NEXT_TAG"
# Deleting the previous tag locally and remotely
git tag -d $$LAST_TAG
git push origin :$$LAST_TAG
# Pushing
git push --follow-tags
fi
else
# Creating a new tag
NEXT_TAG=$$(echo "$$LAST_TAG _${FEATURE_BRANCH}_1" | sed "s/\ //")
# Creating a commit
git add -A
git commit -e
# Checking if a commit was created
if [ $$? -eq 0 ]; then
# Tagging the new tag
git tag -a $$NEXT_TAG -m "$$NEXT_TAG"
# Pushing
git push --follow-tags
fi
fi
else
# Creating a commit
git add -A
git commit -e
# Checking if a commit was created
if [ $$? -eq 0 ]; then
# Pushing
git push
fi
fi
else
# Creating a commit
git add -A
git commit -e
# Checking if a commit was created
if [ $$? -eq 0 ]; then
# Pushing
git push
fi
fi
# Rule for deleting the last generated tag
# on the feature branch locally and remotely
final :
# Determining current branch
CURRENT_BRANCH=$$(git status | head -n 1 | cut -d " " -f 3)
# Checking the current branch
if [ "$$CURRENT_BRANCH" = "${FEATURE_BRANCH}" ]; then
# Determining the last tag
LAST_TAG=$$(git describe --tag)
# Deleting the lat tag remotely
git push origin :$$LAST_TAG
# Deleting the last tag locally
git tag -d $$LAST_TAG
fi
## Rule for creating a new feature branch
new :
git checkout -q master
git checkout -b ${FEATURE_BRANCH}
git push -u origin ${FEATURE_BRANCH}
## Rule for deleting current feature branch locally
del :
git checkout -q master
git branch -D ${FEATURE_BRANCH}
## Rule for amending of the last commit
git-am :
git add -A
git commit --amend
git push --force-with-lease
# Rule for creating of archives
archive :
cd Notebooks/ && find Base/ -path '*/.*' -prune -o -type f -print | zip ../Archives/Notebooks/Base.zip -FS -q -@ && cd ../
cd Notebooks/ && find DS/ -path '*/.*' -prune -o -type f -print | zip ../Archives/Notebooks/DS.zip -FS -q -@ && cd ../
cd Notebooks/ && find Kernels/ -path '*/.*' -prune -o -type f -print | zip ../Archives/Notebooks/Kernels.zip -FS -q -@ && cd ../
cd Notebooks/ && find Tests/ -path '*/.*' -prune -o -type f -print | zip ../Archives/Notebooks/Tests.zip -FS -q -@ && cd ../
find Notebooks/ -path '*/.*' -prune -o -type f -print | zip Archives/Notebooks.zip -FS -q -@