-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
83 lines (69 loc) · 2.35 KB
/
build.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env bash
##########################################################################
# This is the modified Cake bootstrapper script for Linux and OS X.
##########################################################################
echo "Starting build.sh"
DEVOPS_VERSION=1.11.0
NUGET_URL=https://api.nuget.org/v3/index.json
NUGET_BETA_URL=https://www.myget.org/F/micro-elements/api/v3/index.json
# Define directories.
SCRIPT_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
TOOLS_DIR=$SCRIPT_DIR/tools
# Script to run.
SCRIPT=$TOOLS_DIR/microelements.devops/$DEVOPS_VERSION/scripts/main.cake
CAKE_PROPS_PATH=$TOOLS_DIR/cake.props
CAKE_VERSION="0.38.0"
CAKE_ARGUMENTS=()
# Parse arguments.
for i in "$@"; do
case $1 in
-s|--script) SCRIPT="$2"; shift ;;
--cake-version) CAKE_VERSION="--version=$2"; shift ;;
--) shift; CAKE_ARGUMENTS+=("$@"); break ;;
*) CAKE_ARGUMENTS+=("$1") ;;
esac
shift
done
CAKE_ARGUMENTS+=("--rootDir=$SCRIPT_DIR");
CAKE_ARGUMENTS+=("--devOpsVersion=$DEVOPS_VERSION");
CAKE_ARGUMENTS+=("--devOpsRoot=$TOOLS_DIR/microelements.devops/$DEVOPS_VERSION");
echo "===========VARIABLES============"
echo "SCRIPT_DIR: $SCRIPT_DIR"
echo "SCRIPT: $SCRIPT"
echo "TOOLS_DIR: $TOOLS_DIR"
echo "NUGET_URL: $NUGET_URL"
echo "NUGET_BETA_URL: $NUGET_BETA_URL"
echo "CAKE_PROPS_PATH: $CAKE_PROPS_PATH"
echo "CAKE_ARGUMENTS: ${CAKE_ARGUMENTS[*]}"
###########################################################################
# RESTORE CAKE AND LIBS
###########################################################################
# Make sure the tools folder exist.
if [ ! -d "$TOOLS_DIR" ]; then
mkdir "$TOOLS_DIR"
fi
# Write cake.props to tools folder.
if [ ! -f "$CAKE_PROPS_PATH" ]
then
echo "cake.props doesnot exists"
cat > "$CAKE_PROPS_PATH" <<EOL
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MicroElements.DevOps" Version="$DEVOPS_VERSION" />
</ItemGroup>
</Project>
EOL
echo "cake.props written to $CAKE_PROPS_PATH"
cat "$CAKE_PROPS_PATH"
fi
# Restore Cake and Packages
dotnet restore $CAKE_PROPS_PATH --packages $TOOLS_DIR --source "$NUGET_URL" --source "$NUGET_BETA_URL"
dotnet tool restore
# Start Cake
echo "Running build script..."
CMD="dotnet cake $SCRIPT ${CAKE_ARGUMENTS[@]}"
echo $CMD
exec $CMD