11#! /usr/bin/env bash
22cReset=" [0m"
33cBold=" [1m"
4- colorGreen=2
4+ colorBlack=0
55colorRed=1
6+ colorGreen=2
67colorYellow=3
78colorBlue=4
9+ colorMagenta=5
10+ colorCyan=6
11+ colorWhite=7
12+ colorDefault=9
813cGreen=" [0;3${colorGreen} m" ${cBold}
914cRed=" [1;3${colorRed} m" ${cBold}
1015cYellow=" [1;3${colorYellow} m" ${cBold}
1116cBlue=" [1;3${colorBlue} m" ${cBold}
17+ cMagenta=" [1;3${colorMagenta} m" ${cBold}
18+
19+ function update_brew_link(){
20+ local INSERT
21+ local MACOS_FILE
22+ echo -n ' Updating brew link ... '
23+ INSERT=$( curl -s https://brew.sh/ | grep ' <figure class="highlight"><pre>' | sed ' 2,$d' | sed ' s/<[^>]*>//g' )
24+
25+ # Check if INSERT is not empty
26+ if [ -z " $INSERT " ]; then
27+ echo -e " ${cRed} failed${cReset} "
28+ else
29+ # Define the MACOS file path
30+ MACOS_FILE=" macos.md"
31+
32+ # Use
33+ awk -v insert=" $INSERT " '
34+ /<!-- START OF BREW LINK -->/ {
35+ print;
36+ print "```";
37+ getline;
38+ print insert;
39+ while (getline > 0 && !/<!-- END OF BREW LINK -->/) {}
40+ print "```";
41+ print
42+ next
43+ }
44+ {print}
45+ ' " $MACOS_FILE " > " $MACOS_FILE .tmp" && \
46+ mv " $MACOS_FILE .tmp" " $MACOS_FILE " && \
47+ echo -e " ${cGreen} done${cReset} "
48+ # sed -i '/<!-- START OF BREW LINK -->/ a \
49+ # ```' "$MACOS_FILE"
50+ fi
51+ }
1252
1353function images_to_links(){
1454awk ' {if($0 ~ /img src=/){
@@ -31,6 +71,18 @@ awk '{if($0 ~ /img src=/){
3171print $0}' " $1 " | sed ' s/<figcaption.*figcaption>//' | sed ' /figure>$/d' > " $1 " .tmp && mv " $1 " .tmp " $1 "
3272}
3373
74+ while getopts " :ah" opt; do
75+ case ${opt} in
76+ a )
77+ RUN_ALL_PROGRAMS=1
78+ ;;
79+ h )
80+ echo " Usage: $0 [-a/-h]"
81+ exit
82+ ;;
83+ esac
84+ done
85+
3486mkdir pyradio/__pycache__ 2> /dev/null
3587rm -rf pyradio/__pycache__/*
3688echo " This directory is here for pep 517 integration...
62114sed -i ' s/\t/ /g' Changelog
63115
64116
117+ [ -z " $RUN_ALL_PROGRAMS " ] || ./devel/update_win_players
118+
65119cd docs
120+ # update brew link in macos.md
121+ [ -z " $RUN_ALL_PROGRAMS " ] || update_brew_link
122+
123+ echo -ne " Updating files ... "
124+
66125# Create HTML file from md files
67126for afile in index.md \
68127 build.md windows.md \
@@ -71,7 +130,8 @@ for afile in index.md \
71130 radio-browser.md \
72131 desktop-notification.md \
73132 server.md linux.md \
74- linux-pipx.md macos.md \
133+ linux-pipx.md \
134+ macos.md \
75135 pip-error.md \
76136 recording.md \
77137 packaging.md \
@@ -251,10 +311,12 @@ cd ..
251311# git add devel/update_win_mplayer
252312# }
253313
314+ echo -e " ${cGreen} done${sReset}
315+ "
254316
255317echo -e " ${cBlue} Version:${cReset} "
256318AVER=$( grep version pyproject.toml | sed -e ' s/"//' g -e ' s/version = //' )
257- echo -en " pyproject.toml: ${cGreen} "
319+ echo -en " ${cBlue} pyproject.toml${cReset} : ${cGreen} "
258320echo " version = \" $AVER \" "
259321
260322# update version string in __init__.py
@@ -264,19 +326,19 @@ sed -i "s/version_info =.*/version_info = ($XVER)/" pyradio/__init__.py
264326# update version in install.py
265327sed -i " s/PyRadioInstallPyReleaseVersion = .*/PyRadioInstallPyReleaseVersion = '$AVER '/" pyradio/install.py
266328
267- echo -en " ${cReset } __init__.py: ${cRed} "
329+ echo -en " ${cMagenta } __init__.py${cReset} : ${cRed} "
268330grep ' ^version_info ' pyradio/__init__.py
269- echo -en " ${cReset } install.py: ${cYellow} "
331+ echo -en " ${cMagenta } install.py${cReset} : ${cYellow} "
270332grep ' ^PyRadioInstallPyReleaseVersion ' pyradio/install.py
271333
272334echo -e " ${cReset} To change the version, just change the version in ${cGreen} pyproject.toml${cReset}
273335and all version strings will be updated automatically."
274336
275-
276- echo -e " ${cReset}
337+ if [ -z " $RUN_ALL_PROGRAMS " ]
338+ then
339+ echo -e " ${cReset}
277340You should also run
278- ${cGreen} devel/update_win_players${cReset}
279- at this point, if you are ready to
280- publish a new release"
281-
341+ ${cGreen}${0} -a${cReset}
342+ when you are ready to publish a new release"
343+ fi
282344
0 commit comments