Last active
January 20, 2018 12:42
-
-
Save ludeeus/0c5d28aa33a37d187b5fd05fbcede8ef to your computer and use it in GitHub Desktop.
build_and_dist_hassbian_config.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Helper script to build and distribute hassbian-scripts. | |
# | |
# Reprepro needs to be installed | |
# sudo apt-get install reprepro | |
# | |
# git need to be set up for both repos | |
# git needs to be configured for you user | |
# you need write/push access to hassbian-repository | |
# | |
# These three lines need to match your environment | |
USER=debian | |
REPODIR=/home/$USER/git/hassbian-repository | |
PACKAGEDIR=/home/$USER/git/hassbian-scripts | |
echo "Pulling repos from Github..." | |
chown -R $USER $PACKAGEDIR | |
chown -R $USER $REPODIR | |
cd $REPODIR | |
git fetch --all && git reset --hard origin/master | |
cd $PACKAGEDIR | |
git fetch --all && git reset --hard origin/master | |
echo "Getting current version from package..." | |
CURRENTVERSION=$(cat $PACKAGEDIR/package/DEBIAN/control | grep 'Version' | awk -F ' ' '{print $2}') | |
echo "Current version is set to: $CURRENTVERSION" | |
read -p "Is this correct? ($CURRENTVERSION) [Y/n] : " CORRECT | |
if [ "$CORRECT" == "n" ] || [ "$CORRECT" == "N" ]; then | |
read -p "Enter the correct version: " NEW_VERSION | |
if [ ! "$NEW_VERSION" ]; then | |
NEW_VERSION=$CURRENTVERSION | |
fi | |
sed -i 's/'$CURRENTVERSION'/'$NEW_VERSION'/g' $PACKAGEDIR/package/DEBIAN/control | |
fi | |
VERSION=$(cat $PACKAGEDIR/package/DEBIAN/control | grep 'Version' | awk -F ' ' '{print $2}') | |
echo "Verifying milestones..." | |
MILESTONES=$(curl https://api.github.com/search/issues\?q\=milestone:v$VERSION+type:pr+repo:home-assistant/hassbian-scripts | jq -r '.items[]| "[#" +(.number|tostring) +"](" + .html_url + ") " + .title + " [@" + (.user | .login + "](" + .html_url + ") ")') | |
if [ ! "$MILESTONES" ]; then | |
echo "No milestones... aborting..." | |
exit | |
fi | |
echo "Creating .deb file for distribution..." | |
dpkg-deb --build package/ | |
echo "Adding package to repo..." | |
cd $REPODIR | |
reprepro --keepunreferencedfiles -S utils includedeb stretch $PACKAGEDIR/package.deb | |
echo "Adding release notes..." | |
mv $REPODIR/CHANGELOG.md $REPODIR/CHANGELOG_old.md | |
echo "**$VERSION** " | tee -a $REPODIR/CHANGELOG.md | |
echo "$MILESTONES" | tee -a $REPODIR/CHANGELOG.md | |
echo " " | tee -a CHANGELOG.md | |
cat CHANGELOG_old.md | tee -a $REPODIR/CHANGELOG.md | |
rm $REPODIR/CHANGELOG_old.md | |
git add -A | |
git commit -a -m "$VERSION - See CHANGELOG.md." | |
git push -u origin master | |
echo "Distribution complete..." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment