1010# If any of these are not satisfied, the operation may fail
1111# in an unpredictable way and result in an incomplete output.
1212
13- # TODO: Re-enable MPF building after figuring out how to build Windows desktop applications on Linux
14- # This may require an additional package to be installed?
13+ # Optional parameters
14+ USE_ALL=false
15+ INCLUDE_PROGRAMS=false # TODO: Figure out how to exclude folders with `zip`
16+ NO_BUILD=false
17+ NO_ARCHIVE=false
18+ while getopts " upba" OPTION
19+ do
20+ case $OPTION in
21+ u)
22+ USE_ALL=true
23+ ;;
24+ p)
25+ INCLUDE_PROGRAMS=true
26+ ;;
27+ b)
28+ NO_BUILD=true
29+ ;;
30+ a)
31+ NO_ARCHIVE=true
32+ ;;
33+ * )
34+ echo " Invalid option provided"
35+ exit 1
36+ ;;
37+ esac
38+ done
1539
1640# Set the current directory as a variable
1741BUILD_FOLDER=$PWD
1842
1943# Set the current commit hash
2044COMMIT=` git log --pretty=%H -1`
2145
22- # Restore Nuget packages for all builds
23- echo " Restoring Nuget packages"
24- dotnet restore
46+ # Create the build matrix arrays
47+ UI_FRAMEWORKS=(" net6.0-windows" " net8.0-windows" )
48+ UI_RUNTIMES=(" win-x64" )
49+ CHECK_FRAMEWORKS=(" net6.0" " net8.0" )
50+ CHECK_RUNTIMES=(" win-x64" " linux-x64" " osx-x64" )
2551
26- # .NET 6.0 Debug
27- echo " Building .NET 6.0 debug"
28- # dotnet publish MPF/MPF.csproj -f net6.0-windows -r win-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
29- dotnet publish MPF.Check/MPF.Check.csproj -f net6.0 -r win-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
30- dotnet publish MPF.Check/MPF.Check.csproj -f net6.0 -r linux-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
31- dotnet publish MPF.Check/MPF.Check.csproj -f net6.0 -r osx-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
52+ # Use expanded lists, if requested
53+ if [ $USE_ALL = true ]
54+ then
55+ UI_FRAMEWORKS=(" net40" " net452" " net462" " net472" " net48" " netcoreapp3.1" " net5.0-windows" " net6.0-windows" " net7.0-windows" " net8.0-windows" )
56+ UI_RUNTIMES=(" win-x86" " win-x64" )
57+ CHECK_FRAMEWORKS=(" net20" " net35" " net40" " net452" " net462" " net472" " net48" " netcoreapp3.1" " net5.0" " net6.0" " net7.0" " net8.0" )
58+ CHECK_RUNTIMES=(" win-x86" " win-x64" " win-arm64" " linux-x64" " linux-arm64" " osx-x64" )
59+ fi
3260
33- # .NET 6.0 Release
34- echo " Building .NET 6.0 release"
35- # dotnet publish MPF/MPF.csproj -f net6.0-windows -r win-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
36- dotnet publish MPF.Check/MPF.Check.csproj -f net6.0 -r win-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
37- dotnet publish MPF.Check/MPF.Check.csproj -f net6.0 -r linux-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
38- dotnet publish MPF.Check/MPF.Check.csproj -f net6.0 -r osx-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
61+ # Create the filter arrays
62+ SINGLE_FILE_CAPABLE=(" net5.0" " net5.0-windows" " net6.0" " net6.0-windows" " net7.0" " net7.0-windows" " net8.0" " net8.0-windows" )
63+ VALID_CROSS_PLATFORM_FRAMEWORKS=(" netcoreapp3.1" " net5.0" " net6.0" " net7.0" " net8.0" )
64+ VALID_CROSS_PLATFORM_RUNTIMES=(" win-arm64" " linux-x64" " linux-arm64" " osx-x64" )
3965
40- # .NET 8.0 Debug
41- echo " Building .NET 8.0 debug "
42- # dotnet publish MPF/MPF.csproj -f net8.0-windows -r win-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
43- dotnet publish MPF.Check/MPF.Check.csproj -f net8.0 -r win-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
44- dotnet publish MPF.Check/MPF.Check.csproj -f net8.0 -r linux-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
45- dotnet publish MPF.Check/MPF.Check.csproj -f net8.0 -r osx-x64 -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
66+ # Only build if requested
67+ if [ $NO_BUILD = false ]
68+ then
69+ # Restore Nuget packages for all builds
70+ echo " Restoring Nuget packages "
71+ dotnet restore
4672
47- # .NET 8.0 Release
48- echo " Building .NET 8.0 release"
49- # dotnet publish MPF/MPF.csproj -f net8.0-windows -r win-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
50- dotnet publish MPF.Check/MPF.Check.csproj -f net8.0 -r win-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
51- dotnet publish MPF.Check/MPF.Check.csproj -f net8.0 -r linux-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
52- dotnet publish MPF.Check/MPF.Check.csproj -f net8.0 -r osx-x64 -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:PublishTrimmed=true -p:DebugType=None -p:DebugSymbols=false
73+ # Build UI
74+ for FRAMEWORK in " ${UI_FRAMEWORKS[@]} "
75+ do
76+ for RUNTIME in " ${UI_RUNTIMES[@]} "
77+ do
78+ # Only .NET 5 and above can publish to a single file
79+ if [[ $( echo ${SINGLE_FILE_CAPABLE[@]} | fgrep -w $FRAMEWORK ) ]]
80+ then
81+ dotnet publish MPF/MPF.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
82+ dotnet publish MPF/MPF.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
83+ else
84+ dotnet publish MPF/MPF.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT
85+ dotnet publish MPF/MPF.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:DebugType=None -p:DebugSymbols=false
86+ fi
87+ done
88+ done
5389
54- # Create MPF Debug archives
55- # cd $BUILD_FOLDER/MPF/bin/Debug/net6.0-windows/win-x64/publish/
56- # zip -r $BUILD_FOLDER/MPF_net6.0_win-x64_debug.zip .
57- # cd $BUILD_FOLDER/MPF/bin/Debug/net8.0-windows/win-x64/publish/
58- # zip -r $BUILD_FOLDER/MPF_net8.0_win-x64_debug.zip .
90+ # Build Check
91+ for FRAMEWORK in " ${CHECK_FRAMEWORKS[@]} "
92+ do
93+ for RUNTIME in " ${CHECK_RUNTIMES[@]} "
94+ do
95+ # If we have an invalid combination of framework and runtime
96+ if [[ ! $( echo ${VALID_CROSS_PLATFORM_FRAMEWORKS[@]} | fgrep -w $FRAMEWORK ) ]]
97+ then
98+ if [[ $( echo ${VALID_CROSS_PLATFORM_RUNTIMES[@]} | fgrep -w $RUNTIME ) ]]
99+ then
100+ continue
101+ fi
102+ fi
59103
60- # Create MPF Release archives
61- # cd $BUILD_FOLDER/MPF/bin/Release/net6.0-windows/win-x64/publish/
62- # zip -r $BUILD_FOLDER/MPF_net6.0_win-x64_release.zip .
63- # cd $BUILD_FOLDER/MPF/bin/Release/net8.0-windows/win-x64/publish/
64- # zip -r $BUILD_FOLDER/MPF_net8.0_win-x64_release.zip .
104+ # Only .NET 5 and above can publish to a single file
105+ if [[ $( echo ${SINGLE_FILE_CAPABLE[@]} | fgrep -w $FRAMEWORK ) ]]
106+ then
107+ dotnet publish MPF.Check/MPF.Check.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true
108+ dotnet publish MPF.Check/MPF.Check.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:PublishSingleFile=true -p:DebugType=None -p:DebugSymbols=false
109+ else
110+ dotnet publish MPF.Check/MPF.Check.csproj -f $FRAMEWORK -r $RUNTIME -c Debug --self-contained true --version-suffix $COMMIT
111+ dotnet publish MPF.Check/MPF.Check.csproj -f $FRAMEWORK -r $RUNTIME -c Release --self-contained true --version-suffix $COMMIT -p:DebugType=None -p:DebugSymbols=false
112+ fi
113+ done
114+ done
115+ fi
65116
66- # Create MPF.Check Debug archives
67- cd $BUILD_FOLDER /MPF.Check/bin/Debug/net6.0/win-x64/publish/
68- zip -r $BUILD_FOLDER /MPF.Check_net6.0_win-x64_debug.zip .
69- cd $BUILD_FOLDER /MPF.Check/bin/Debug/net6.0/linux-x64/publish/
70- zip -r $BUILD_FOLDER /MPF.Check_net6.0_linux-x64_debug.zip .
71- cd $BUILD_FOLDER /MPF.Check/bin/Debug/net6.0/osx-x64/publish/
72- zip -r $BUILD_FOLDER /MPF.Check_net6.0_osx-x64_debug.zip .
73- cd $BUILD_FOLDER /MPF.Check/bin/Debug/net8.0/win-x64/publish/
74- zip -r $BUILD_FOLDER /MPF.Check_net8.0_win-x64_debug.zip .
75- cd $BUILD_FOLDER /MPF.Check/bin/Debug/net8.0/linux-x64/publish/
76- zip -r $BUILD_FOLDER /MPF.Check_net8.0_linux-x64_debug.zip .
77- cd $BUILD_FOLDER /MPF.Check/bin/Debug/net8.0/osx-x64/publish/
78- zip -r $BUILD_FOLDER /MPF.Check_net8.0_osx-x64_debug.zip .
117+ # Only create archives if requested
118+ if [ $NO_ARCHIVE = false ]
119+ then
120+ # Create UI archives
121+ for FRAMEWORK in " ${UI_FRAMEWORKS[@]} "
122+ do
123+ echo " Framework: $FRAMEWORK "
124+ for RUNTIME in " ${UI_RUNTIMES[@]} "
125+ do
126+ echo " Runtime: $RUNTIME "
127+ cd $BUILD_FOLDER /MPF/bin/Debug/${FRAMEWORK} /${RUNTIME} /publish/
128+ echo " PWD: $PWD "
129+ if [ $INCLUDE_PROGRAMS = true ]
130+ then
131+ zip -r $BUILD_FOLDER /MPF_${FRAMEWORK} _${RUNTIME} _debug.zip .
132+ else
133+ zip -r $BUILD_FOLDER /MPF_${FRAMEWORK} _${RUNTIME} _debug.zip . -x ' Programs/\*'
134+ fi
135+ cd $BUILD_FOLDER /MPF/bin/Release/${FRAMEWORK} /${RUNTIME} /publish/
136+ echo " PWD: $PWD "
137+ if [ $INCLUDE_PROGRAMS = true ]
138+ then
139+ zip -r $BUILD_FOLDER /MPF_${FRAMEWORK} _${RUNTIME} _release.zip .
140+ else
141+ zip -r $BUILD_FOLDER /MPF_${FRAMEWORK} _${RUNTIME} _release.zip . -x ' Programs/\*'
142+ fi
143+ done
144+ done
79145
80- # Create MPF.Check Release archives
81- cd $BUILD_FOLDER /MPF.Check/bin/Release/net6.0/win-x64/publish/
82- zip -r $BUILD_FOLDER /MPF.Check_net6.0_win-x64_release.zip .
83- cd $BUILD_FOLDER /MPF.Check/bin/Release/net6.0/linux-x64/publish/
84- zip -r $BUILD_FOLDER /MPF.Check_net6.0_linux-x64_release.zip .
85- cd $BUILD_FOLDER /MPF.Check/bin/Release/net6.0/osx-x64/publish/
86- zip -r $BUILD_FOLDER /MPF.Check_net6.0_osx-x64_release.zip .
87- cd $BUILD_FOLDER /MPF.Check/bin/Release/net8.0/win-x64/publish/
88- zip -r $BUILD_FOLDER /MPF.Check_net8.0_win-x64_release.zip .
89- cd $BUILD_FOLDER /MPF.Check/bin/Release/net8.0/linux-x64/publish/
90- zip -r $BUILD_FOLDER /MPF.Check_net8.0_linux-x64_release.zip .
91- cd $BUILD_FOLDER /MPF.Check/bin/Release/net8.0/osx-x64/publish/
92- zip -r $BUILD_FOLDER /MPF.Check_net8.0_osx-x64_release.zip .
146+ # Create Check archives
147+ for FRAMEWORK in " ${CHECK_FRAMEWORKS[@]} "
148+ do
149+ for RUNTIME in " ${CHECK_RUNTIMES[@]} "
150+ do
151+ # If we have an invalid combination of framework and runtime
152+ if [[ ! $( echo ${VALID_CROSS_PLATFORM_FRAMEWORKS[@]} | fgrep -w $FRAMEWORK ) ]]
153+ then
154+ if [[ $( echo ${VALID_CROSS_PLATFORM_RUNTIMES[@]} | fgrep -w $RUNTIME ) ]]
155+ then
156+ continue
157+ fi
158+ fi
159+
160+ cd $BUILD_FOLDER /MPF.Check/bin/Debug/${FRAMEWORK} /${RUNTIME} /publish/
161+ zip -r $BUILD_FOLDER /MPF.Check_${FRAMEWORK} _${RUNTIME} _debug.zip .
162+ cd $BUILD_FOLDER /MPF.Check/bin/Release/${FRAMEWORK} /${RUNTIME} /publish/
163+ zip -r $BUILD_FOLDER /MPF.Check_${FRAMEWORK} _${RUNTIME} _release.zip .
164+ done
165+ done
166+
167+ # Reset the directory
168+ cd $BUILD_FOLDER
169+ fi
0 commit comments