Skip to content

Instantly share code, notes, and snippets.

@Klubuntu
Forked from DemwE/build.sh
Last active September 22, 2023 17:27
Show Gist options
  • Save Klubuntu/0a05593b7567f90a9e5d371ab4cb9d52 to your computer and use it in GitHub Desktop.
Save Klubuntu/0a05593b7567f90a9e5d371ab4cb9d52 to your computer and use it in GitHub Desktop.
Build release for Tauri Apps support Windows, Linux, MacOS
#!/bin/bash
if [ ! -f build.conf ]; then
echo "File build.conf does not exist, creating it."
echo "UpdateRustTargets=true" >>build.conf
echo "BuildWindows=true" >>build.conf
echo "BuildLinux=true" >>build.conf
echo "BuildMac=true" >>build.conf
exit 0
fi
UpdateRustTargets=$(cat build.conf | grep UpdateRustTargets | cut -d "=" -f 2)
BuildWindows=$(cat build.conf | grep BuildWindows | cut -d "=" -f 2)
BuildLinux=$(cat build.conf | grep BuildLinux | cut -d "=" -f 2)
BuildMac=$(cat build.conf | grep BuildMac | cut -d "=" -f 2)
if [ "$UpdateRustTargets" == "true" ]; then
echo -e "\e[94mUpdating rust targets\e[0m"
if [ "$BuildWindows" == "true" ]; then
rustup target add x86_64-pc-windows-gnu
elif [ "$BuildLinux" == "true" ]; then
rustup target add x86_64-unknown-linux-gnu
elif [ "$BuildMac" == "true" ]; then
rustup target add x86_64-apple-darwin
fi
if [ $? -ne 0 ]; then
echo -e "\e[31mError: Failed to update rust targets\e[0m"
else
echo -e "\e[92mRust targets updated\e[0m"
fi
elif [ "$UpdateRustTargets" == "false" ]; then
echo -e "\e[94mSkipping rust target update.\e[0m"
else
echo -e "\e[31mError: Invalid value for UpdateRustTargets: $UpdateRustTargets\e[0m"
fi
if [ "$BuildWindows" == "true" ]; then
echo -e "\e[94mBuilding for Windows\e[0m"
tauri build --target x86_64-pc-windows-gnu
if [ $? -ne 0 ]; then
echo -e "\e[31mError: Failed to build for Windows\e[0m"
else
echo -e "\e[92mDone!\e[0m"
fi
elif [ "$BuildWindows" == "false" ]; then
echo -e "\e[94mSkipping Windows build.\e[0m"
else
echo -e "\e[31mError: Invalid value for BuildWindows: $BuildWindows\e[0m"
fi
if [ "$BuildLinux" == "true" ]; then
echo -e "\e[94mBuilding for Linux\e[0m"
tauri build --target x86_64-unknown-linux-gnu
if [ $? -ne 0 ]; then
echo -e "\e[31mError: Failed to build for Linux\e[0m"
else
echo -e "\e[92mDone!\e[0m"
fi
elif [ "$BuildLinux" == "false" ]; then
echo -e "\e[94mSkipping Linux build.\e[0m"
else
echo -e "\e[31mError: Invalid value for BuildLinux: $BuildLinux\e[0m"
fi
if [ "$BuildMac" == "true" ]; then
echo -e "\e[94mBuilding for Mac\e[0m"
tauri build --target x86_64-apple-darwin
if [ $? -ne 0 ]; then
echo -e "\e[31mError: Failed to build for Mac\e[0m"
else
echo -e "\e[92mDone!\e[0m"
fi
elif [ "$BuildMac" == "false" ]; then
echo -e "\e[94mSkipping Mac build.\e[0m"
else
echo -e "\e[31mError: Invalid value for BuildMac: $BuildMac\e[0m"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment