Verbose mode

This commit is contained in:
Alexandre
2021-02-08 13:13:36 +01:00
committed by GitHub
parent b14465c695
commit f540df9e84

View File

@@ -15,8 +15,7 @@ git config --system user.password ${GITPASS}
git config --system user.email ${GITMAIL}
if bashio::config.has_value 'gitapi'; then
LOGINFO="... setting github API"
if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
LOGINFO="... setting github API" && if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
export GITHUB_API_TOKEN=$(bashio::config 'gitapi')
fi
@@ -32,56 +31,46 @@ for addons in $(bashio::config "addon|keys"); do
#Create or update local version
if [ ! -d /data/$BASENAME ]; then
LOGINFO="... $SLUG : cloning ${REPOSITORY}"
if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
LOGINFO="... $SLUG : cloning ${REPOSITORY}" && if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
cd /data/
git clone "https://github.com/${REPOSITORY}"
else
LOGINFO="... $SLUG : updating ${REPOSITORY}"
if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
LOGINFO="... $SLUG : updating ${REPOSITORY}" && if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
cd "/data/$BASENAME"
git pull --rebase
fi
#Define the folder addon
LOGINFO="... $SLUG : checking slug exists in repo"
if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
LOGINFO="... $SLUG : checking slug exists in repo" && if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
cd /data/${BASENAME}/${SLUG} || bashio::log.error "$SLUG addon not found in this repository. Exiting." exit
#Find current version
LOGINFO="... $SLUG : get current version"
if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
LOGINFO="... $SLUG : get current version" && if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
CURRENT=$(jq .version config.json) || bashio::log.error "$SLUG addon version in config.json not found. Exiting." exit
#Prepare tag flag
if [ ${FULLTAG} = true ]; then
LOGINFO="... $SLUG : fulltag is on"
if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
LOGINFO="... $SLUG : fulltag is on" && if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
FULLTAG="--format tag"
else
LOGINFO="... $SLUG : fulltag is off"
if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
LOGINFO="... $SLUG : fulltag is off" && if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
FULLTAG=""
fi
#If beta flag, select beta version
if [ ${BETA} = true ]; then
LOGINFO="... $SLUG : beta is on"
if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
LOGINFO="... $SLUG : beta is on" && if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
LASTVERSION='"'$(lastversion --pre "https://github.com/$UPSTREAM" $FULLTAG)'"'
else
LOGINFO="... $SLUG : beta is off"
if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
LOGINFO="... $SLUG : beta is off" && if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
LASTVERSION='"'$(lastversion "https://github.com/$UPSTREAM" $FULLTAG)'"'
fi
if [ ${CURRENT} != ${LASTVERSION} ]; then
LOGINFO="... $SLUG : update from $CURRENT to $LASTVERSION"
if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
LOGINFO="... $SLUG : update from $CURRENT to $LASTVERSION" && if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
#Change all instances of version
LOGINFO="... $SLUG : updating files"
if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
LOGINFO="... $SLUG : updating files" && if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
files=$(grep -rl ${CURRENT} /data/${BASENAME}/${SLUG}) && echo $files | xargs sed -i "s/${CURRENT}/${LASTVERSION}/g"
#Update changelog
@@ -95,8 +84,7 @@ if [ $files != null ]; then
git commit -m "Update to $LASTVERSION" /data/${BASENAME}/${SLUG}/CHANGELOG.md || true
#Git commit and push
LOGINFO="... $SLUG : push to github
if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
LOGINFO="... $SLUG : push to github && if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
git remote set-url origin "https://${GITUSER}:${GITPASS}@github.com/${REPOSITORY}" | echo
git push | echo "No changes"
@@ -107,7 +95,6 @@ bashio::log.error "... $SLUG : couldn't update"
fi
else
LOGINFO="Addon $SLUG is already up-to-date."
if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
LOGINFO="Addon $SLUG is already up-to-date." && if [ $VERBOSE = true ]; then bashio::log.info $LOGINFO; fi
fi
done