@@ -35,20 +35,50 @@ readonly REPOSITORY
35
35
36
36
# define flags
37
37
FLAG_COMMIT=0
38
+ FLAG_DRY_RUN=0
38
39
39
40
usage () {
40
41
cat << EOF
41
- Generate supported tags.
42
+ Bump supported tags.
42
43
43
44
Usage:
44
45
$PROGRAM [flags]
45
46
46
47
Flags:
47
- -c, --commit commit changes
48
- -h, --help help for $PROGRAM
48
+ -c, --commit commit changes
49
+ -d, --dry-run only check and don't apply or commit any changes
50
+ -h, --help help for $PROGRAM
49
51
EOF
50
52
}
51
53
54
+ print_bold () {
55
+ local value=" $1 "
56
+ local output=" ${3:- 1} "
57
+
58
+ if [ " $DISABLE_COLORS " = ' 1' ] || ! [ -t 1 ]; then
59
+ printf ' %s' " $value " >& " $output "
60
+ else
61
+ printf " $( tput bold) %s$( tput sgr0) " " $value " >& " $output "
62
+ fi
63
+ }
64
+
65
+ print_bold_color () {
66
+ local color=" $1 "
67
+ local value=" $2 "
68
+ local output=" ${3:- 1} "
69
+
70
+ if [ " $DISABLE_COLORS " = ' 1' ] || ! [ -t 1 ]; then
71
+ printf ' %s' " $value " >& " $output "
72
+ else
73
+ printf " $( tput bold) $( tput setaf " $color " ) %s$( tput sgr0) " " $value " >& " $output "
74
+ fi
75
+ }
76
+
77
+ print_error () {
78
+ print_bold_color 1 " error: $1 " 2
79
+ echo ' ' >&2
80
+ }
81
+
52
82
print_url () {
53
83
local tags=" $1 "
54
84
local commit=" $2 "
@@ -154,6 +184,9 @@ while [ $# -gt 0 ]; do
154
184
-c|--commit)
155
185
FLAG_COMMIT=1
156
186
;;
187
+ -d|--dry-run)
188
+ FLAG_DRY_RUN=1
189
+ ;;
157
190
-h|--help)
158
191
usage
159
192
exit 0
@@ -170,30 +203,32 @@ done
170
203
171
204
# define extra constants
172
205
readonly FLAG_COMMIT
206
+ readonly FLAG_DRY_RUN
173
207
174
208
printf " %s\n\n" " $HEADING_FOR_TAGS "
175
209
176
- if [ " $FLAG_COMMIT " -eq 1 ]; then
210
+ if [ " $FLAG_DRY_RUN " -eq 1 ]; then
211
+ print_latest_tags
212
+ print_official_tags
213
+ exit 0
214
+ else
177
215
latest_tags=" $( print_latest_tags) "
178
216
official_tags=" $( print_official_tags) "
179
217
echo " $latest_tags "
180
218
echo " $official_tags "
219
+
181
220
echo ' ---'
221
+ printf ' Replacing...'
222
+ replace " $HEADING_FOR_TAGS " $' \n ' $' \n ' " $latest_tags " $' \n ' " $official_tags " $' \n '
223
+ printf ' Done\n'
224
+
182
225
if [ " $FLAG_COMMIT " -eq 1 ]; then
183
- replace " $HEADING_FOR_TAGS " $' \n ' $' \n ' " $latest_tags " $' \n ' " $official_tags " $' \n '
184
226
printf ' Committing...'
185
- git add \
186
- DOCKERHUB.md \
187
- README.md
227
+ git add ./DOCKERHUB.md ./README.md
188
228
if [ -n " $( git diff --cached --name-only) " ]; then
189
229
printf ' \n'
190
230
echo ' ---'
191
231
git commit -m " $COMMIT_MESSAGE "
192
- else
193
- printf ' Skipped\n'
194
232
fi
195
233
fi
196
- else
197
- print_latest_tags
198
- print_official_tags
199
234
fi
0 commit comments