-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.sh
More file actions
151 lines (136 loc) · 3.92 KB
/
build.sh
File metadata and controls
151 lines (136 loc) · 3.92 KB
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
#!/usr/bin/env bash
# Selena Build Script for Unix/Linux/macOS
set -e
# Default values
CONFIGURATION="Release"
VERSION="1.0.0"
RUN_TESTS=false
RUN_PACK=false
RUN_BENCHMARK=false
RUN_CLEAN=false
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# Parse arguments
while [[ $# -gt 0 ]]; do
case $1 in
--configuration|-c)
CONFIGURATION="$2"
shift 2
;;
--version|-v)
VERSION="$2"
shift 2
;;
--test|-t)
RUN_TESTS=true
shift
;;
--pack|-p)
RUN_PACK=true
shift
;;
--benchmark|-b)
RUN_BENCHMARK=true
shift
;;
--clean)
RUN_CLEAN=true
shift
;;
--help|-h)
echo "Usage: ./build.sh [options]"
echo "Options:"
echo " -c, --configuration Build configuration (Debug/Release) [default: Release]"
echo " -v, --version Version number [default: 1.0.0]"
echo " -t, --test Run tests"
echo " -p, --pack Create NuGet package"
echo " -b, --benchmark Run benchmarks"
echo " --clean Clean build artifacts"
echo " -h, --help Show this help message"
exit 0
;;
*)
echo "Unknown option: $1"
echo "Use --help for usage information"
exit 1
;;
esac
done
function print_header {
echo ""
echo -e "${CYAN}========================================"
echo -e " $1"
echo -e "========================================${NC}"
echo ""
}
# Clean
if [ "$RUN_CLEAN" = true ]; then
print_header "Cleaning Solution"
dotnet clean --configuration $CONFIGURATION
if [ -d "artifacts" ]; then
rm -rf artifacts
fi
echo -e "${GREEN}Clean completed!${NC}"
fi
# Build
print_header "Building Selena"
echo -e "${YELLOW}Configuration: $CONFIGURATION${NC}"
echo -e "${YELLOW}Version: $VERSION${NC}"
dotnet build --configuration $CONFIGURATION -p:Version=$VERSION
if [ $? -ne 0 ]; then
echo -e "${RED}Build failed!${NC}"
exit 1
fi
echo -e "${GREEN}Build completed successfully!${NC}"
# Test
if [ "$RUN_TESTS" = true ]; then
print_header "Running Tests"
dotnet test --configuration $CONFIGURATION --no-build \
--logger "console;verbosity=normal" \
--collect:"XPlat Code Coverage" \
--results-directory "./artifacts/TestResults"
if [ $? -ne 0 ]; then
echo -e "${RED}Tests failed!${NC}"
exit 1
fi
echo -e "${GREEN}All tests passed!${NC}"
fi
# Benchmark
if [ "$RUN_BENCHMARK" = true ]; then
print_header "Running Benchmarks"
pushd tests/Selena.Benchmarks > /dev/null
dotnet run --configuration Release
if [ $? -ne 0 ]; then
echo -e "${RED}Benchmarks failed!${NC}"
exit 1
fi
popd > /dev/null
echo -e "${GREEN}Benchmarks completed!${NC}"
fi
# Pack
if [ "$RUN_PACK" = true ]; then
print_header "Creating NuGet Package"
dotnet pack src/Selena/Selena.csproj \
--configuration $CONFIGURATION \
--no-build \
-p:Version=$VERSION \
--output "./artifacts/packages"
if [ $? -ne 0 ]; then
echo -e "${RED}Pack failed!${NC}"
exit 1
fi
PACKAGE_FILE=$(ls artifacts/packages/*.nupkg | head -n 1)
PACKAGE_SIZE=$(du -h "$PACKAGE_FILE" | cut -f1)
echo -e "${GREEN}Package created: $(basename $PACKAGE_FILE)${NC}"
echo -e "${YELLOW}Package size: $PACKAGE_SIZE${NC}"
fi
print_header "Build Complete!"
echo -e "${YELLOW}Next steps:${NC}"
echo " - Run examples: dotnet run --project examples/Selena.Examples"
echo " - Run tests: ./build.sh --test"
echo " - Create package: ./build.sh --pack"
echo " - Run benchmarks: ./build.sh --benchmark"