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