Skip to content

Commit

Permalink
Don't maintain two build scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebazzz committed Nov 12, 2024
1 parent 7e619ff commit f5ddd6b
Showing 1 changed file with 8 additions and 91 deletions.
99 changes: 8 additions & 91 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,96 +1,13 @@
#!/usr/bin/env bash

# Define directories.
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
TOOLS_DIR=$SCRIPT_DIR/tools

# Make sure the tools folder exist.
if [ ! -d "$TOOLS_DIR" ]; then
mkdir "$TOOLS_DIR"
fi

#!/usr/bin/env bash
# Define varibles
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
source $SCRIPT_DIR/build.config
TOOLS_DIR=$SCRIPT_DIR/tools
BROWSERS_DIR=$SCRIPT_DIR/tools/browsers
CAKE_EXE=$TOOLS_DIR/dotnet-cake
CAKE_PATH=$TOOLS_DIR/.store/cake.tool/$CAKE_VERSION

if [ "$CAKE_VERSION" = "" ] || [ "$DOTNET_VERSION" = "" ]; then
echo "An error occured while parsing Cake / .NET Core SDK version."
exit 1
fi

# Make sure the tools folder exist.
if [ ! -d "$TOOLS_DIR" ]; then
mkdir "$TOOLS_DIR"
fi

# Make sure the tools folder exist.
if [ ! -d "$BROWSERS_DIR" ]; then
mkdir "$BROWSERS_DIR"
fi

export PLAYWRIGHT_BROWSERS_PATH=$BROWSERS_DIR

###########################################################################
# INSTALL .NET CORE CLI
###########################################################################

DOTNET_INSTALLED_VERSION=$(dotnet --version 2>&1)

if [ "$DOTNET_VERSION" != "$DOTNET_INSTALLED_VERSION" ]; then
echo "Installing .NET CLI..."
if [ ! -d "$SCRIPT_DIR/.dotnet" ]; then
mkdir "$SCRIPT_DIR/.dotnet"
fi
curl -Lsfo "$SCRIPT_DIR/.dotnet/dotnet-install.sh" https://dot.net/v1/dotnet-install.sh
bash "$SCRIPT_DIR/.dotnet/dotnet-install.sh" --version $DOTNET_VERSION --install-dir .dotnet --no-path
export PATH="$SCRIPT_DIR/.dotnet":$PATH
fi

export DOTNET_CLI_TELEMETRY_OPTOUT=1
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1

export DOTNET_ROOT=$SCRIPT_DIR/.dotnet

# Restore .NET tools
dotnet tool restore

###########################################################################
# INSTALL CAKE
###########################################################################

CAKE_INSTALLED_VERSION=$(dotnet-cake --version 2>&1)

if [ "$CAKE_VERSION" != "$CAKE_INSTALLED_VERSION" ]; then
if [ ! -f "$CAKE_EXE" ] || [ ! -d "$CAKE_PATH" ]; then
if [ -f "$CAKE_EXE" ]; then
dotnet tool uninstall --tool-path $TOOLS_DIR Cake.Tool
fi

echo "Installing Cake $CAKE_VERSION..."
dotnet tool install --tool-path $TOOLS_DIR --version $CAKE_VERSION Cake.Tool
if [ $? -ne 0 ]; then
echo "An error occured while installing Cake."
exit 1
fi
fi

# Make sure that Cake has been installed.
if [ ! -f "$CAKE_EXE" ]; then
echo "Could not find Cake.exe at '$CAKE_EXE'."
exit 1
fi
else
CAKE_EXE="dotnet-cake"
# Check if pwsh is available
if ! command -v pwsh &> /dev/null; then
echo "Error: 'pwsh' command not found. Please install PowerShell to proceed."
exit 1
fi

###########################################################################
# RUN BUILD SCRIPT
###########################################################################
# Run pwsh with all arguments passed to this script
pwsh "$@"

# Start Cake
(exec "$CAKE_EXE" --bootstrap) && (exec "$CAKE_EXE" "$@")
# Pass through the exit code of the pwsh command
exit $?

0 comments on commit f5ddd6b

Please sign in to comment.