Skip to content

Commit

Permalink
feat (github-actions.yml): we now set the sdk-versions and the xcode-…
Browse files Browse the repository at this point in the history
…ide to use for iphoneos-bindings and mac-catalyst-bindings at the top of github-actions.yml
  • Loading branch information
dsidirop committed Jul 10, 2024
1 parent 8dd3c94 commit 5786a07
Show file tree
Hide file tree
Showing 6 changed files with 98 additions and 31 deletions.
39 changes: 25 additions & 14 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ env:
SCL_AZURE_ARTIFACTS_API_KEY: ${{ secrets.SCL_AZURE_ARTIFACTS_API_KEY }}
SCL_GITHUB_NUGET_FEED_USERNAME: ${{ secrets.SCL_GITHUB_NUGET_FEED_USERNAME }}

BINDINGS_IOS___SDK_VERSION: "17.2"
BINDINGS_IOS___XCODE_IDE_DEV_PATH: "/Applications/Xcode_15.2.app/Contents/Developer"

BINDINGS_MACCATALYST___SDK_VERSION: "14.2"
BINDINGS_MACCATALYST___XCODE_IDE_DEV_PATH: "/Applications/Xcode_15.2.app/Contents/Developer"

on:
workflow_call: # so that other workflows can trigger this
Expand Down Expand Up @@ -57,20 +62,26 @@ jobs:
- name: '🏗 📦 Build, Pack & Announce New Release (if appropriate)'
shell: 'bash'
run: |
cd "${{env.BUILD_REPOSITORY_FOLDERPATH}}/Laerdal.Scripts" \
&& \
dotnet \
msbuild \
"Laerdal.Builder.targets" \
-m:1 \
-p:Should_Skip_MacCatalyst="false" \
\
-p:PackageOutputPath="${{env.BUILD_REPOSITORY_FOLDERPATH}}/Artifacts" \
-p:Laerdal_Gradle_Path="/opt/homebrew/opt/gradle@7/bin/gradle" \
-p:Laerdal_Source_Branch="${{env.LAERDAL_SOURCE_BRANCH}}" \
-p:Laerdal_Repository_Path="${{env.LAERDAL_REPOSITORY_PATH}}" \
-p:Laerdal_Github_Access_Token="${{env.SCL_GITHUB_ACCESS_TOKEN}}" \
-p:Laerdal_Test_Results_Folderpath="${{env.BUILD_REPOSITORY_FOLDERPATH}}/TestResults"
cd "${{env.BUILD_REPOSITORY_FOLDERPATH}}/Laerdal.Scripts" \
&& \
dotnet \
msbuild \
"Laerdal.Builder.targets" \
-m:1 \
-p:Should_Skip_MacCatalyst="false" \
\
-p:PackageOutputPath="${{env.BUILD_REPOSITORY_FOLDERPATH}}/Artifacts" \
-p:Laerdal_Gradle_Path="/opt/homebrew/opt/gradle@7/bin/gradle" \
-p:Laerdal_Source_Branch="${{env.LAERDAL_SOURCE_BRANCH}}" \
-p:Laerdal_Repository_Path="${{env.LAERDAL_REPOSITORY_PATH}}" \
-p:Laerdal_Github_Access_Token="${{env.SCL_GITHUB_ACCESS_TOKEN}}" \
-p:Laerdal_Test_Results_Folderpath="${{env.BUILD_REPOSITORY_FOLDERPATH}}/TestResults" \
\
-p:Laerdal_Bindings_iOS___Sdk_Version="${{env.BINDINGS_IOS___SDK_VERSION}}" \
-p:Laerdal_Bindings_iOS___Xcode_Ide_Dev_Path="${{env.BINDINGS_IOS___XCODE_IDE_DEV_PATH}}" \
\
-p:Laerdal_Bindings_MacCatalyst___Sdk_Version="${{env.BINDINGS_MACCATALYST___SDK_VERSION}}" \
-p:Laerdal_Bindings_MacCatalyst___Xcode_Ide_Dev_Path="${{env.BINDINGS_MACCATALYST___XCODE_IDE_DEV_PATH}}"
- name: '📡 Publish Test Results' # https://github.com/marketplace/actions/publish-test-results
uses: 'EnricoMi/publish-unit-test-result-action/macos@v2'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@

<NativeFrameworkParentFolderpath>$([System.IO.Path]::Combine($(MSBuildThisFileDirectory), 'Frameworks'))</NativeFrameworkParentFolderpath>
<NativeFrameworkActualTargetFolderpath>$(NativeFrameworkParentFolderpath)/McuMgrBindingsiOS.framework</NativeFrameworkActualTargetFolderpath>

<Laerdal_Bindings_MacCatalyst___Sdk_Version Condition=" '$(Laerdal_Bindings_MacCatalyst___Sdk_Version)' == '' ">14.2</Laerdal_Bindings_MacCatalyst___Sdk_Version>
<Laerdal_Bindings_MacCatalyst___Xcode_Ide_Dev_Path Condition=" '$(Laerdal_Bindings_MacCatalyst___Xcode_Ide_Dev_Path)' == '' ">/Applications/Xcode_15.2.app/Contents/Developer</Laerdal_Bindings_MacCatalyst___Xcode_Ide_Dev_Path>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -158,7 +161,18 @@

<!-- 1. build and generate the fat libs from the proxy swift project -->
<Exec WorkingDirectory="../Laerdal.McuMgr.Bindings.MacCatalystAndIos.Native" Command=" bash -c &quot; chmod +x ./Laerdal.Mac.CompileAndGenerateFatLibs.sh &quot; "/>
<Exec WorkingDirectory="../Laerdal.McuMgr.Bindings.MacCatalystAndIos.Native" Command=" bash -c &quot; SWIFT_OUTPUT_PATH='$(NativeFrameworkParentFolderpath)' XCODEBUILD_TARGET_SDK='macosx' SUPPORTS_MACCATALYST='YES' ./Laerdal.Mac.CompileAndGenerateFatLibs.sh &quot; "/>

<PropertyGroup>
<!-- in ci we have to specify the path to gradle explicitly so as to ensure we are using gradle 7.6 for smooth compilation of the android java-libs -->
<_CliCommand>$(_Cli) XCODE_IDE_DEV_PATH='$(Laerdal_Bindings_MacCatalyst___Xcode_Ide_Dev_Path)' </_CliCommand>
<_CliCommand>$(_Cli) XCODEBUILD_TARGET_SDK='iphoneos' </_CliCommand>
<_CliCommand>$(_Cli) XCODEBUILD_TARGET_SDK_VERSION='$(Laerdal_Bindings_MacCatalyst___Sdk_Version)' </_CliCommand>
<_CliCommand>$(_Cli) SWIFT_OUTPUT_PATH='$(NativeFrameworkParentFolderpath)' </_CliCommand>
<_CliCommand>$(_Cli) ./Laerdal.Mac.CompileAndGenerateFatLibs.sh </_CliCommand>
<!-- <_CliCommand>$(_Laerdal_Build_Parameters)DeterministicSourcePaths=False;</_CliCommand> -->
</PropertyGroup>

<Exec WorkingDirectory="../Laerdal.McuMgr.Bindings.MacCatalystAndIos.Native" Command=" $(_CliCommand) "/>

<!-- warning its absolutely vital to remove any softlink files as they are causing -->
<!-- warning codesign to fail when using the resulting nuget in maui apps go figure ... -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
#
# Note that all parameters passed to xcodebuild must be in the form of -parameter value instead of --parameter

declare XCODE_IDE_DEV_PATH="${XCODE_IDE_DEV_PATH:-/Applications/Xcode_15.2.app/Contents/Developer}"

declare XCODEBUILD_TARGET_SDK="${XCODEBUILD_TARGET_SDK:-iphoneos}"
declare XCODEBUILD_TARGET_SDK_VERSION="${XCODEBUILD_TARGET_SDK_VERSION}" # xcodebuild -showsdks

Expand Down Expand Up @@ -38,8 +40,8 @@ else
OUTPUT_FOLDER_POSTFIX="$XCODEBUILD_TARGET_SDK"
fi

declare OUTPUT_FOLDER_NAME="$SWIFT_BUILD_CONFIGURATION-$OUTPUT_FOLDER_POSTFIX" # Release-iphoneos or Release-maccatalyst note that we intentionally *omitted* the sdk-version from the folder name
declare OUTPUT_SHARPIE_HEADER_FILES_PATH="SharpieOutput/SwiftFrameworkProxy.Binding" # contains the resulting files ApiDefinitions.cs and StructsAndEnums.cs
declare OUTPUT_FOLDER_NAME="$SWIFT_BUILD_CONFIGURATION-$OUTPUT_FOLDER_POSTFIX" # Release-iphoneos or Release-maccatalyst note that we intentionally *omitted* the sdk-version
declare OUTPUT_SHARPIE_HEADER_FILES_PATH="SharpieOutput/SwiftFrameworkProxy.Binding" # from the folder name contains the resulting files ApiDefinitions.cs and StructsAndEnums.cs

function print_macos_sdks() {
echo "** xcode path : '$( "xcode-select" -p )'"
Expand Down Expand Up @@ -68,6 +70,18 @@ function print_macos_sdks() {
echo
}

function set_system_wide_default_xcode_ide() {
echo "** Set Xcode IDE path to '$XCODE_IDE_DEV_PATH'"

sudo xcode-select -s "$XCODE_IDE_DEV_PATH"
local exitCode=$?

if [ $exitCode -ne 0 ]; then
echo "** [FAILED] Failed to set xcode-select to '$XCODE_IDE_DEV_PATH'"
exit 1
fi
}

function build() {
echo "** Build $OUTPUT_FOLDER_NAME framework for device"

Expand Down Expand Up @@ -326,6 +340,7 @@ function create_fat_binaries() {

function main() {
print_macos_sdks
set_system_wide_default_xcode_ide
build
create_fat_binaries

Expand Down
16 changes: 15 additions & 1 deletion Laerdal.McuMgr.Bindings.iOS/Laerdal.McuMgr.Bindings.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@

<NativeFrameworkParentFolderpath>$([System.IO.Path]::Combine($(MSBuildThisFileDirectory), 'Frameworks'))</NativeFrameworkParentFolderpath>
<NativeFrameworkActualTargetFolderpath>$(NativeFrameworkParentFolderpath)/McuMgrBindingsiOS.framework</NativeFrameworkActualTargetFolderpath>

<Laerdal_Bindings_iOS___Sdk_Version Condition=" '$(Laerdal_Bindings_iOS___Sdk_Version)' == '' ">17.2</Laerdal_Bindings_iOS___Sdk_Version>
<Laerdal_Bindings_iOS___Xcode_Ide_Dev_Path Condition=" '$(Laerdal_Bindings_iOS___Xcode_Ide_Dev_Path)' == '' ">/Applications/Xcode_15.2.app/Contents/Developer</Laerdal_Bindings_iOS___Xcode_Ide_Dev_Path>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -159,7 +162,18 @@

<!-- 1. build and generate the fat libs from the proxy swift project -->
<Exec WorkingDirectory="../Laerdal.McuMgr.Bindings.MacCatalystAndIos.Native" Command=" chmod +x ./Laerdal.Mac.CompileAndGenerateFatLibs.sh "/>
<Exec WorkingDirectory="../Laerdal.McuMgr.Bindings.MacCatalystAndIos.Native" Command=" SWIFT_OUTPUT_PATH='$(NativeFrameworkParentFolderpath)' XCODEBUILD_TARGET_SDK='iphoneos' ./Laerdal.Mac.CompileAndGenerateFatLibs.sh "/>

<PropertyGroup>
<!-- in ci we have to specify the path to gradle explicitly so as to ensure we are using gradle 7.6 for smooth compilation of the android java-libs -->
<_CliCommand>$(_Cli) XCODE_IDE_DEV_PATH='$(Laerdal_Bindings_iOS___Xcode_Ide_Dev_Path)' </_CliCommand>
<_CliCommand>$(_Cli) XCODEBUILD_TARGET_SDK='iphoneos' </_CliCommand>
<_CliCommand>$(_Cli) XCODEBUILD_TARGET_SDK_VERSION='$(Laerdal_Bindings_iOS___Sdk_Version)' </_CliCommand>
<_CliCommand>$(_Cli) SWIFT_OUTPUT_PATH='$(NativeFrameworkParentFolderpath)' </_CliCommand>
<_CliCommand>$(_Cli) ./Laerdal.Mac.CompileAndGenerateFatLibs.sh </_CliCommand>
<!-- <_CliCommand>$(_Laerdal_Build_Parameters)DeterministicSourcePaths=False;</_CliCommand> -->
</PropertyGroup>

<Exec WorkingDirectory="../Laerdal.McuMgr.Bindings.MacCatalystAndIos.Native" Command=" $(_CliCommand) "/>

<!-- warning its absolutely vital to remove any softlink files as they are causing -->
<!-- warning codesign to fail when using the resulting nuget in maui apps go figure ... -->
Expand Down
25 changes: 19 additions & 6 deletions Laerdal.Scripts/Laerdal.Builder.targets
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

<PropertyGroup>
<Newline>%0A</Newline>

<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<ShouldRunTestSuite Condition=" '$(ShouldRunTestSuite)' == '' ">true</ShouldRunTestSuite>

Expand All @@ -42,7 +43,17 @@
<!-- https://learn.microsoft.com/en-us/azure/devops/pipelines/build/variables?view=azure-devops&tabs=yaml&WT.mc_id=DT-MVP-5003978#system-variables -->
<Is_CI_Build Condition=" '$(Is_CI_Build)' == '' and ( '$(TF_BUILD)' == 'true' or '$(GITHUB_ACTIONS)' == 'true' or '$(GITLAB_CI)' == 'true' ) ">true</Is_CI_Build>
<Should_Skip_MacCatalyst Condition=" '$(Should_Skip_MacCatalyst)' == '' ">false</Should_Skip_MacCatalyst>


<!-- in github-ci these variables are provided by the .yml file in localdev you can set them here if you want to experiment just dont commit them -->
<!-- -->
<!-- <Laerdal_Bindings_iOS___Sdk_Version Condition=" '$(Laerdal_Bindings_iOS___Sdk_Version)' == '' ">17.2</Laerdal_Bindings_iOS___Sdk_Version> -->
<!-- <Laerdal_Bindings_iOS___Xcode_Ide_Dev_Path Condition=" '$(Laerdal_Bindings_iOS___Xcode_Ide_Dev_Path)' == '' ">15.2</Laerdal_Bindings_iOS___Xcode_Ide_Dev_Path> -->

<!-- in github-ci these variables are provided by the .yml file in localdev you can set them here if you want to experiment just dont commit them -->
<!-- -->
<!-- <Laerdal_Bindings_MacCatalyst___Sdk_Version Condition=" '$(Laerdal_Bindings_MacCatalyst___Sdk_Version)' == '' ">14.2</Laerdal_Bindings_MacCatalyst___Sdk_Version> -->
<!-- <Laerdal_Bindings_MacCatalyst___Xcode_Ide_Dev_Path Condition=" '$(Laerdal_Bindings_MacCatalyst___Xcode_Ide_Dev_Path)' == '' ">15.2</Laerdal_Bindings_MacCatalyst___Xcode_Ide_Dev_Path> -->

<Laerdal_Gradle_Path Condition=" '$(Laerdal_Gradle_Path)' == '' ">gradle</Laerdal_Gradle_Path>
<Laerdal_Source_Branch Condition=" '$(Laerdal_Source_Branch)' == '' ">$(BUILD_SOURCEBRANCH)</Laerdal_Source_Branch>
<Laerdal_Repository_Path Condition=" '$(Laerdal_Repository_Path)' == '' ">$(BUILD_REPOSITORY_NAME)</Laerdal_Repository_Path>
Expand Down Expand Up @@ -193,6 +204,7 @@
<_Laerdal_Build_Parameters>$(_Laerdal_Build_Parameters)GradlePath=$(Laerdal_Gradle_Path);</_Laerdal_Build_Parameters>
<_Laerdal_Build_Parameters>$(_Laerdal_Build_Parameters)Configuration=$(Configuration);</_Laerdal_Build_Parameters>
<_Laerdal_Build_Parameters>$(_Laerdal_Build_Parameters)PackageOutputPath=$(PackageOutputPath);</_Laerdal_Build_Parameters>
<_Laerdal_Build_Parameters>$(_Laerdal_Build_Parameters)ContinuousIntegrationBuild=$(Is_CI_Build);</_Laerdal_Build_Parameters>
<_Laerdal_Build_Parameters>$(_Laerdal_Build_Parameters)Should_Skip_MacCatalyst=$(Should_Skip_MacCatalyst);</_Laerdal_Build_Parameters>
<!--<_Laerdal_Build_Parameters>$(_Laerdal_Build_Parameters)DeterministicSourcePaths=False;</_Laerdal_Build_Parameters>-->
</PropertyGroup>
Expand All @@ -209,14 +221,15 @@
<MSBuild Projects="$(Laerdal_McuMgrBindings_ProjectFile_Android)" Properties="$(_Laerdal_Build_Parameters)" Targets="Clean"/>
<MSBuild Projects="$(Laerdal_McuMgrBindings_ProjectFile_Android)" Properties="$(_Laerdal_Build_Parameters)" Targets="Restore"/>
<MSBuild Projects="$(Laerdal_McuMgrBindings_ProjectFile_Android)" Properties="$(_Laerdal_Build_Parameters);BuildingProject=true;" Targets="TackleJarDependencies"/>
<MSBuild Projects="$(Laerdal_McuMgrBindings_ProjectFile_Android)" Properties="$(_Laerdal_Build_Parameters);BuildingProject=true;ContinuousIntegrationBuild=$(Is_CI_Build);SourceRoot=$(MSBuildThisFileDirectory)/../Laerdal.McuMgr.Bindings.Android/;" Targets="Build"/>
<MSBuild Projects="$(Laerdal_McuMgrBindings_ProjectFile_Android)" Properties="$(_Laerdal_Build_Parameters);BuildingProject=true;SourceRoot=$(MSBuildThisFileDirectory)/../Laerdal.McuMgr.Bindings.Android/;" Targets="Build"/>

<MSBuild Projects="$(Laerdal_McuMgrBindings_ProjectFile_iOS)" Properties="$(_Laerdal_Build_Parameters);ContinuousIntegrationBuild=$(Is_CI_Build);SourceRoot=$(MSBuildThisFileDirectory)/../Laerdal.McuMgr.Bindings.iOS/;" Targets="Restore;Rebuild"/>
<MSBuild Projects="$(Laerdal_McuMgrBindings_ProjectFile_NetStandard)" Properties="$(_Laerdal_Build_Parameters);ContinuousIntegrationBuild=$(Is_CI_Build);SourceRoot=$(MSBuildThisFileDirectory)/../Laerdal.McuMgr.Bindings.NetStandard/;" Targets="Restore;Rebuild"/>
<MSBuild Projects="$(Laerdal_McuMgrBindings_ProjectFile_MacCatalyst)" Properties="$(_Laerdal_Build_Parameters);ContinuousIntegrationBuild=$(Is_CI_Build);SourceRoot=$(MSBuildThisFileDirectory)/../Laerdal.McuMgr.Bindings.MacCatalyst/;" Targets="Restore;Rebuild" Condition=" '$(Should_Skip_MacCatalyst)' != 'true' "/>
<MSBuild Projects="$(Laerdal_McuMgrBindings_ProjectFile_NetStandard)" Properties="$(_Laerdal_Build_Parameters);SourceRoot=$(MSBuildThisFileDirectory)/../Laerdal.McuMgr.Bindings.NetStandard/;" Targets="Restore;Rebuild"/>

<MSBuild Projects="$(Laerdal_McuMgrBindings_ProjectFile_iOS)" Properties="$(_Laerdal_Build_Parameters);Laerdal_Bindings_iOS___Xcode_Ide_Dev_Path=$(Laerdal_Bindings_iOS___Xcode_Ide_Dev_Path);Laerdal_Bindings_iOS___Sdk_Version=$(Laerdal_Bindings_iOS___Sdk_Version);SourceRoot=$(MSBuildThisFileDirectory)/../Laerdal.McuMgr.Bindings.iOS/;" Targets="Restore;Rebuild"/>
<MSBuild Projects="$(Laerdal_McuMgrBindings_ProjectFile_MacCatalyst)" Properties="$(_Laerdal_Build_Parameters);Laerdal_Bindings_MacCatalyst___Xcode_Ide_Dev_Path=$(Laerdal_Bindings_MacCatalyst___Xcode_Ide_Dev_Path);Laerdal_Bindings_MacCatalyst___Sdk_Version=$(Laerdal_Bindings_MacCatalyst___Sdk_Version);SourceRoot=$(MSBuildThisFileDirectory)/../Laerdal.McuMgr.Bindings.MacCatalyst/;" Targets="Restore;Rebuild" Condition=" '$(Should_Skip_MacCatalyst)' != 'true' "/>

<!-- notice that we are actually rebuilding mcumgr merely building the project doesnt really cut it -->
<MSBuild Projects="$(Laerdal_McuMgr_ProjectFile)" Properties="$(_Laerdal_Build_Parameters);ContinuousIntegrationBuild=$(Is_CI_Build);SourceRoot=$(MSBuildThisFileDirectory)/../Laerdal.McuMgr/;" Targets="Restore;Rebuild" />
<MSBuild Projects="$(Laerdal_McuMgr_ProjectFile)" Properties="$(_Laerdal_Build_Parameters);SourceRoot=$(MSBuildThisFileDirectory)/../Laerdal.McuMgr/;" Targets="Restore;Rebuild" />
</Target>

<!-- TESTS -->
Expand Down
14 changes: 7 additions & 7 deletions Laerdal.Scripts/Laerdal.SetupBuildEnvironment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,13 @@ echo "** XCode Installations:"

ls -ld /Applications/Xcode* || exit 90

sudo xcode-select -s /Applications/Xcode_15.2.app/Contents/Developer
declare exitCode=$?
if [ $exitCode != 0 ]; then
echo "##vso[task.logissue type=error]Failed to apply 'xcode-select'."
exit 90
fi
echo
#sudo xcode-select -s /Applications/Xcode_15.2.app/Contents/Developer
#declare exitCode=$?
#if [ $exitCode != 0 ]; then
# echo "##vso[task.logissue type=error]Failed to apply 'xcode-select'."
# exit 90
#fi
#echo

echo
echo "** XCode SDKs:"
Expand Down

0 comments on commit 5786a07

Please sign in to comment.