Skip to content

Instantly share code, notes, and snippets.

@AnalogFeelings
Last active November 15, 2023 11:30
Show Gist options
  • Save AnalogFeelings/7969c2af2f87d606b3fd8b72cd8c6432 to your computer and use it in GitHub Desktop.
Save AnalogFeelings/7969c2af2f87d606b3fd8b72cd8c6432 to your computer and use it in GitHub Desktop.
Tiny build script for Samm-Bot. Used in my Raspberry Pi that I'm hosting it in.
#!/bin/bash
#Flags
configuration="Debug"
execute=false
rebuild=false
path="$HOME/Projects/SammBot"
#Script name.
script_name="$(basename $0)"
function print_usage()
{
echo "Usage: ${script_name} [-c BUILD_CONFIG] [-e] [-r] [-p BOT_PATH] [-h]"
echo " -c BUILD_CONFIG : Sets the target config for dotnet. For example, Debug or Release. Default value is Debug."
echo " -e : Add this flag to tell the script to execute the bot after building."
echo " -r : Add this flag to tell the script to not pull from the git repository."
echo " -p BOT_PATH : Sets the path where the bot is located. Default is $HOME/Projects/SammBot."
echo " -h : Prints this usage text and exits."
}
while getopts "c:erp:h" flag
do
case "${flag}" in
c) configuration=${OPTARG};;
e) execute=true;;
r) rebuild=true;;
p) path=${OPTARG};;
h) print_usage; exit;;
esac
done
echo "Attempting to build Samm-Bot on \"${configuration}\" configuration."
cd $path
if [ "$rebuild" = false ] ; then
echo "Pulling from git..."
git pull
fi
dotnet build --configuration $configuration
if [ "$execute" = true ] ; then
cd ./bin/$configuration/net8.0
./SammBot.Bot
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment