-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommit-git-repos.sh
executable file
·142 lines (113 loc) · 3.48 KB
/
commit-git-repos.sh
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
#!/bin/bash
#
# epaper-idf
#
# Copyright (c) 2021 Jeremy Carter <jeremy@jeremycarter.ca>
#
# This code is released under the license terms contained in the
# file named LICENSE, which is found in the top-level folder in
# this project. You must agree to follow those license terms,
# otherwise you aren't allowed to copy, distribute, or use any
# part of this project in any way.
epaper_idf_commit_git_repo_adafruit() {
msg="$1"
git_branch="$2"
adafruit_ver_branch="$3"
adafruit_ver_tag="$4"
cd components/Adafruit-GFX-Component/
git add .
git commit -m "$msg" || \
return $?
git push -u all $git_branch || \
git push -u origin $git_branch
git checkout $adafruit_ver_branch
git merge $git_branch
git push -u all $adafruit_ver_branch || \
git push -u origin $adafruit_ver_branch
git checkout $git_branch
if [ ! -z "$adafruit_ver_tag" ]; then
git tag $adafruit_ver_tag && \
git push origin $adafruit_ver_tag
fi
return 0
}
epaper_idf_commit_git_repo_epaper_idf_component() {
msg="$1"
git_branch="$2"
ver_branch="$3"
ver_tag="$4"
cd ../epaper-idf-component/
git add .
git commit -m "$msg" || \
return $?
git push -u all $git_branch || \
git push -u origin $git_branch
git checkout $ver_branch
git merge $git_branch
git push -u all $ver_branch || \
git push -u origin $ver_branch
git checkout $git_branch
if [ ! -z "$ver_tag" ]; then
git tag $ver_tag && \
git push origin $ver_tag
fi
return 0
}
epaper_idf_commit_git_repo_epaper_idf() {
msg="$1"
git_branch="$2"
ver_branch="$3"
ver_tag="$4"
cd ../..
git add .
git commit -m "$msg" || \
return $?
git push -u all $git_branch || \
git push -u origin $git_branch
git checkout $ver_branch
git merge $git_branch
git push -u all $ver_branch || \
git push -u origin $ver_branch
git checkout $git_branch
if [ ! -z "$ver_tag" ]; then
git tag $ver_tag && \
git push origin $ver_tag
fi
return 0
}
epaper_idf_commit_git_repos_handle_return() {
ret=$1
if [ $ret -ne 0 ]; then
printf '%b\n' "info: git commit skipped with exit code:\n$ret\n"
fi
return 0
}
epaper_idf_commit_git_repos() {
GIT_REPO_BRANCH=${GIT_REPO_BRANCH:-"master"}
GIT_REPO_VERSION_BRANCH=${GIT_REPO_VERSION_BRANCH:-"v0.1"}
GIT_REPO_VERSION_BRANCH_ADAFRUIT=${GIT_REPO_VERSION_BRANCH_ADAFRUIT:-"1.10"}
GIT_REPO_VERSION_TAG=${GIT_REPO_VERSION_TAG:-""}
GIT_REPO_VERSION_TAG_ADAFRUIT=${GIT_REPO_VERSION_TAG_ADAFRUIT:-""}
GIT_REPO_COMMIT_MSG=${GIT_REPO_COMMIT_MSG:-"$@"}
# Copy the main project README.md file into the
# component repo so it's the same on both repos:
cp README.md components/epaper-idf-component/
# Build latest version of config site:
cd components/epaper-idf-component
./build-web.sh
cd ../..
# Copy sites for GitHub:
rm -rf docs/
cp -r public/ docs/
cd components/epaper-idf-component
rm -rf docs/
cp -r public/ docs/
cd ../..
epaper_idf_commit_git_repo_adafruit "$GIT_REPO_COMMIT_MSG" "$GIT_REPO_BRANCH" "$GIT_REPO_VERSION_BRANCH_ADAFRUIT" "$GIT_REPO_VERSION_TAG_ADAFRUIT"
epaper_idf_commit_git_repos_handle_return $?
epaper_idf_commit_git_repo_epaper_idf_component "$GIT_REPO_COMMIT_MSG" "$GIT_REPO_BRANCH" "$GIT_REPO_VERSION_BRANCH" "$GIT_REPO_VERSION_TAG"
epaper_idf_commit_git_repos_handle_return $?
epaper_idf_commit_git_repo_epaper_idf "$GIT_REPO_COMMIT_MSG" "$GIT_REPO_BRANCH" "$GIT_REPO_VERSION_BRANCH" "$GIT_REPO_VERSION_TAG"
epaper_idf_commit_git_repos_handle_return $?
}
epaper_idf_commit_git_repos $@