Skip to content

Commit 637b119

Browse files
authored
Merge pull request #6 from dstmodders/victorpopkov/feature-3
Replace generate-supported-tags.sh with bump-supported-tags.sh
2 parents 483e7aa + 4187ee3 commit 637b119

File tree

1 file changed

+48
-13
lines changed

1 file changed

+48
-13
lines changed

bin/generate-supported-tags.sh renamed to bin/bump-supported-tags.sh

+48-13
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,50 @@ readonly REPOSITORY
3535

3636
# define flags
3737
FLAG_COMMIT=0
38+
FLAG_DRY_RUN=0
3839

3940
usage() {
4041
cat <<EOF
41-
Generate supported tags.
42+
Bump supported tags.
4243
4344
Usage:
4445
$PROGRAM [flags]
4546
4647
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
4951
EOF
5052
}
5153

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+
5282
print_url() {
5383
local tags="$1"
5484
local commit="$2"
@@ -154,6 +184,9 @@ while [ $# -gt 0 ]; do
154184
-c|--commit)
155185
FLAG_COMMIT=1
156186
;;
187+
-d|--dry-run)
188+
FLAG_DRY_RUN=1
189+
;;
157190
-h|--help)
158191
usage
159192
exit 0
@@ -170,30 +203,32 @@ done
170203

171204
# define extra constants
172205
readonly FLAG_COMMIT
206+
readonly FLAG_DRY_RUN
173207

174208
printf "%s\n\n" "$HEADING_FOR_TAGS"
175209

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
177215
latest_tags="$(print_latest_tags)"
178216
official_tags="$(print_official_tags)"
179217
echo "$latest_tags"
180218
echo "$official_tags"
219+
181220
echo '---'
221+
printf 'Replacing...'
222+
replace "$HEADING_FOR_TAGS"$'\n'$'\n'"$latest_tags"$'\n'"$official_tags"$'\n'
223+
printf ' Done\n'
224+
182225
if [ "$FLAG_COMMIT" -eq 1 ]; then
183-
replace "$HEADING_FOR_TAGS"$'\n'$'\n'"$latest_tags"$'\n'"$official_tags"$'\n'
184226
printf 'Committing...'
185-
git add \
186-
DOCKERHUB.md \
187-
README.md
227+
git add ./DOCKERHUB.md ./README.md
188228
if [ -n "$(git diff --cached --name-only)" ]; then
189229
printf '\n'
190230
echo '---'
191231
git commit -m "$COMMIT_MESSAGE"
192-
else
193-
printf ' Skipped\n'
194232
fi
195233
fi
196-
else
197-
print_latest_tags
198-
print_official_tags
199234
fi

0 commit comments

Comments
 (0)