Skip to content

Commit

Permalink
Merge pull request #26
Browse files Browse the repository at this point in the history
[MAN-442] Add support for maccatalyst
  • Loading branch information
ksidirop-laerdal authored Nov 12, 2024
2 parents 84f39b6 + 1972832 commit f9b3c0f
Show file tree
Hide file tree
Showing 8 changed files with 431 additions and 199 deletions.
36 changes: 25 additions & 11 deletions .github/workflows/github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ env:
SCL_NUGET_ORG_FEED_API_KEY: ${{ secrets.NUGET_ORG_FEED_API_KEY }}
SCL_GITHUB_NUGET_FEED_USERNAME: ${{ secrets.SCL_GITHUB_NUGET_FEED_USERNAME }}

SCL_DEPENDENCY_TRACKER_API_KEY: ${{ secrets.SCL_DEPENDENCY_TRACKER_API_KEY }}
SCL_DEPENDENCY_TRACKER_SERVER_URL: ${{ secrets.SCL_DEPENDENCY_TRACKER_SERVER_URL }}
SCL_DEPENDENCY_TRACKER_SIGNING_PRIVATE_KEY: ${{ secrets.SCL_DEPENDENCY_TRACKER_SIGNING_PRIVATE_KEY }}

DOTNET_TARGET_WORKLOAD_VERSION: "8.0.402" # dont upgrade this lightheartedly the workload snapshot implicitly defines which versions of Android/iOS/MacCatalyst SDKs are supported


Expand Down Expand Up @@ -70,16 +74,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" \
\
-p:PackageOutputPath="${{ env.BUILD_REPOSITORY_FOLDERPATH }}/Artifacts" \
-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 }}"
cd "${{env.BUILD_REPOSITORY_FOLDERPATH}}/Laerdal.Scripts" \
&& \
echo "${{env.SCL_DEPENDENCY_TRACKER_API_KEY}}" > "./dependency_tracker_api_key.ppk" \
&& \
echo "${{env.SCL_DEPENDENCY_TRACKER_SIGNING_PRIVATE_KEY}}" > "./dependency_tracker_private_signing_key.ppk" \
&& \
dotnet \
msbuild \
"Laerdal.Builder.targets" \
-m:1 \
-p:PackageOutputPath="${{ env.BUILD_REPOSITORY_FOLDERPATH }}/Artifacts" \
-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_Dependency_Tracker_Server_Url="${{ env.SCL_DEPENDENCY_TRACKER_SERVER_URL }}" \
-p:Laerdal_Dependency_Tracker_Api_Key_File_Path="${{ env.BUILD_REPOSITORY_FOLDERPATH }}/Laerdal.Scripts/dependency_tracker_api_key.ppk" \
-p:Laerdal_Dependency_Tracker_Private_Signing_Key_File_Path="${{ env.BUILD_REPOSITORY_FOLDERPATH }}/Laerdal.Scripts/dependency_tracker_private_signing_key.ppk" \
&& \
rm "./dependency_tracker_private_signing_key.ppk" "./dependency_tracker_api_key.ppk"
- name: '⬆️ Upload Artifacts' # to share with other workflows https://stackoverflow.com/a/77663335/863651
uses: 'actions/upload-artifact@v4'
Expand All @@ -90,7 +104,7 @@ jobs:

- name: '🚀 Publish to the Laerdal Nuget Server on Github' # https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-nuget-registry
shell: 'bash'
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || github.ref == 'refs/heads/ksidirop/MAN-335-ios-runtime-error-fix-about-you-should-not-call-this-method'
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
run: |
cd "${{env.BUILD_REPOSITORY_FOLDERPATH}}/Artifacts/" \
&& \
Expand Down
2 changes: 1 addition & 1 deletion Laerdal.Dfu.Bindings.iOS.sln
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "_Misc", "_Misc", "{DB8D9BFF
.github\workflows\github-actions.yml = .github\workflows\github-actions.yml
Laerdal.Scripts\Laerdal.SetupBuildEnvironment.sh = Laerdal.Scripts\Laerdal.SetupBuildEnvironment.sh
Laerdal.Scripts\Laerdal.CreateNewReleaseInGithub.sh = Laerdal.Scripts\Laerdal.CreateNewReleaseInGithub.sh
Laerdal.Scripts\Laerdal.Changelog.sh = Laerdal.Scripts\Laerdal.Changelog.sh
Laerdal.Scripts\Laerdal.Builder.targets = Laerdal.Scripts\Laerdal.Builder.targets
.gitignore = .gitignore
Laerdal.Scripts\Laerdal.GenerateSignAndUploadSbom.sh = Laerdal.Scripts\Laerdal.GenerateSignAndUploadSbom.sh
EndProjectSection
EndProject
Global
Expand Down
21 changes: 16 additions & 5 deletions Laerdal.Dfu.Bindings.iOS/Laerdal.Dfu.Bindings.iOS.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,15 @@
</PropertyGroup>

<PropertyGroup>
<TargetFramework>net8.0-ios</TargetFramework>
<IsBindingProject>true</IsBindingProject>

<TargetFrameworks>$(TargetFrameworks)net8.0-ios;</TargetFrameworks>
<TargetFrameworks>$(TargetFrameworks)net8.0-maccatalyst</TargetFrameworks>

<IsOSX Condition=" '$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX)))' == 'true' ">true</IsOSX>

<IsNet8IOS Condition=" $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios' ">true</IsNet8IOS>
<IsNet8MacCatalyst Condition=" $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst' ">true</IsNet8MacCatalyst>
</PropertyGroup>

<PropertyGroup>
Expand Down Expand Up @@ -41,10 +46,16 @@

<!-- ==================== TARGET PLATFORM VERSION ======================= -->
<PropertyGroup>
<!-- ios you will need specific workloads though dotnet workload install maui -/-version 8.0.402 -->
<TargetPlatformVersion>17.0</TargetPlatformVersion>
<TargetPlatformMinVersion>14.2</TargetPlatformMinVersion>
<SupportedOSPlatformVersion>14.2</SupportedOSPlatformVersion>
<!-- you will need to be specific when it comes to workloads -> dotnet workload install maui -/-version 8.0.402 -->

<!-- #1 these properties must be kept in sync between this file and laerdal.mcumgr.bindings.[android|ios|maccatalyst].csproj -->
<!-- #2 even though this is library is pure csharp we still have to specify the target-plaform-version for each target because -->
<!-- if we dont dont the build system throws a tantrum from oct 2024 onwards -->
<TargetPlatformVersion Condition=" '$(IsNet8IOS)' == 'true' ">17.0</TargetPlatformVersion>
<SupportedOSPlatformVersion Condition=" '$(IsNet8IOS)' == 'true' ">11.0</SupportedOSPlatformVersion>

<TargetPlatformVersion Condition=" '$(IsNet8MacCatalyst)' == 'true' ">17.0</TargetPlatformVersion>
<SupportedOSPlatformVersion Condition=" '$(IsNet8MacCatalyst)' == 'true' ">13.1</SupportedOSPlatformVersion>
</PropertyGroup>

<Import Project="Laerdal.targets"/>
Expand Down
56 changes: 56 additions & 0 deletions Laerdal.Scripts/Laerdal.Builder.targets
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<!-- Laerdal.Scripts/Laerdal.Builder.targets \ -->
<!-- '"/p:Laerdal_Version_Full=1.0.x.0"' \ -->
<!-- '"/p:Laerdal_Github_Access_Token=<place your github access token here - its needed by carthage>"' -->
<!-- '"/m:1"' -->
<!-- -->

<Project DefaultTargets="BuildProjects">
Expand All @@ -31,13 +32,27 @@

<Laerdal_Script_FolderPath>$(MSBuildThisFileDirectory)</Laerdal_Script_FolderPath>

<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>
<Laerdal_Dependency_Tracker_Server_Url Condition=" '$(Laerdal_Dependency_Tracker_Server_Url)' == '' ">https://dep-tracker.laerdal.com/api/api/v1/bom</Laerdal_Dependency_Tracker_Server_Url>

<!-- https://docs.gitlab.com/ee/ci/variables/predefined_variables.html -->
<!-- https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables -->
<!-- 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=" '$(TF_BUILD)' == 'true' or '$(GITHUB_ACTIONS)' == 'true' or '$(GITLAB_CI)' == 'true' ">true</Is_CI_Build>
<Is_Core_Branch Condition=" '$(Laerdal_Source_Branch)' == 'refs/heads/main' or '$(Laerdal_Source_Branch)' == 'refs/heads/master' or '$(Laerdal_Source_Branch)' == 'refs/heads/develop' ">true</Is_Core_Branch>
<Is_Pull_Request Condition=" '$(Laerdal_Source_Branch.StartsWith(refs/pull))' == 'true' and '$(Laerdal_Source_Branch.EndsWith(/merge))' == 'true' ">true</Is_Pull_Request>

<!-- version -->
<Nordic_Package_Version Condition=" '$(Nordic_Package_Version)' == '' ">4.15.3</Nordic_Package_Version>
<Laerdal_Revision Condition=" '$(Laerdal_Revision)' == '' and '$(BUILD_BUILDID)' != '' ">$(BUILD_BUILDID)</Laerdal_Revision> <!-- Azure DevOps, Last build was 43857 -->
<Laerdal_Revision Condition=" '$(Laerdal_Revision)' == '' and '$(GITHUB_RUN_NUMBER)' != '' ">$([MSBuild]::Add(43857, $(GITHUB_RUN_NUMBER)))</Laerdal_Revision> <!-- GitHub Actions, auto-increment from 0 -->
<Laerdal_Revision Condition=" '$(Laerdal_Revision)' == '' and '$(CI_PIPELINE_IID)' != '' ">$([MSBuild]::Add(43857, $(CI_PIPELINE_IID)))</Laerdal_Revision> <!-- GitLab, auto-increment from 0 -->
<Laerdal_Revision Condition=" '$(Laerdal_Revision)' == '' ">0</Laerdal_Revision> <!-- Fallback value -->

<Laerdal_Should_Tag_And_Release Condition=" '$(Laerdal_Should_Tag_And_Release)' == '' and '$(Is_Core_Branch)' == 'true' ">True</Laerdal_Should_Tag_And_Release>
<Laerdal_Should_Generate_and_Upload_Sbom Condition=" '$(Laerdal_Should_Generate_and_Upload_Sbom)' == '' and ( '$(Is_Core_Branch)' == 'true' or '$(Is_Pull_Request)' == 'true' ) ">True</Laerdal_Should_Generate_and_Upload_Sbom>

<Laerdal_Version_Full Condition=" '$(Laerdal_Version_Full)' == '' ">$(Nordic_Package_Version).$(Laerdal_Revision)</Laerdal_Version_Full>
</PropertyGroup>

Expand Down Expand Up @@ -90,4 +105,45 @@
WorkingDirectory="$(MSBuildThisFileDirectory)/.."/>
</Target>

<!-- GENERATE + UPLOAD SBOM -->
<Target Name="GenerateSBOM"
Condition=" '$(Laerdal_Should_Generate_and_Upload_Sbom)' == 'True' "
AfterTargets="CreateGithubReleaseWithTag">

<Error Condition=" '$(PackageOutputPath)' == '' " Text="'PackageOutputPath' has to be set. Please call this script again with the argument '/p:PackageOutputPath=...'"/>
<Error Condition=" '$(Laerdal_Project)' == '' " Text="'Laerdal_Project' has to be set. Please call this script again with the argument '/p:Laerdal_Project=...'"/>
<Error Condition=" '$(Laerdal_Version_Full)' == '' " Text="'Laerdal_Version_Full' has to be set. Please call this script again with the argument '/p:Laerdal_Version_Full=...'"/>
<Error Condition=" '$(Laerdal_Version_Assembly)' == '' " Text="'Laerdal_Version_Assembly' has to be set. Please call this script again with the argument '/p:Laerdal_Version_Assembly=...'"/>
<Error Condition=" '$(Laerdal_Dependency_Tracker_Api_Key_File_Path)' == '' " Text="'Laerdal_Dependency_Tracker_Api_Key_File_Path' has to be set. Please call this script again with the argument '/p:Laerdal_Dependency_Tracker_Api_Key_File_Path=...'"/>
<Error Condition=" '$(Laerdal_Dependency_Tracker_Private_Signing_Key_File_Path)' == '' " Text="'Laerdal_Dependency_Tracker_Private_Signing_Key_File_Path' has to be set. Please call this script again with the argument '/p:Laerdal_Dependency_Tracker_Private_Signing_Key_File_Path=...'"/>

<PropertyGroup>
<!-- notice that we intentionally use $(Laerdal_Version_Assembly) instead of $(Laerdal_Version_Full) -->
<!-- because cyclonedx inherently ear-tags sboms with the former rather than the later -->

<_Laerdal_Project_Name>$([System.IO.Path]::GetFileName('$(Laerdal_Project)').Replace('.csproj', ''))</_Laerdal_Project_Name>

<_Laerdal_Sbom_Script_Parameters>$(_Laerdal_Sbom_Script_Parameters) --project-version &quot;$(Laerdal_Version_Assembly)&quot;</_Laerdal_Sbom_Script_Parameters>
<_Laerdal_Sbom_Script_Parameters>$(_Laerdal_Sbom_Script_Parameters) --output-directory-path &quot;$(PackageOutputPath)&quot;</_Laerdal_Sbom_Script_Parameters>
<_Laerdal_Sbom_Script_Parameters>$(_Laerdal_Sbom_Script_Parameters) --sbom-signing-key-file-path &quot;$(Laerdal_Dependency_Tracker_Private_Signing_Key_File_Path)&quot;</_Laerdal_Sbom_Script_Parameters>

<_Laerdal_Sbom_Script_Parameters>$(_Laerdal_Sbom_Script_Parameters) --dependency-tracker-url &quot;$(Laerdal_Dependency_Tracker_Server_Url)&quot;</_Laerdal_Sbom_Script_Parameters>
<_Laerdal_Sbom_Script_Parameters>$(_Laerdal_Sbom_Script_Parameters) --dependency-tracker-api-key-file-path &quot;$(Laerdal_Dependency_Tracker_Api_Key_File_Path)&quot;</_Laerdal_Sbom_Script_Parameters>

<_Laerdal_Sbom_Script_Parameters>$(_Laerdal_Sbom_Script_Parameters) --csproj-classifier &quot;Library&quot;</_Laerdal_Sbom_Script_Parameters>
<_Laerdal_Sbom_Script_Parameters>$(_Laerdal_Sbom_Script_Parameters) --csproj-file-path &quot;$(Laerdal_Project)&quot;</_Laerdal_Sbom_Script_Parameters>

<_Laerdal_Sbom_Script_Parameters>$(_Laerdal_Sbom_Script_Parameters) --project-name &quot;$(_Laerdal_Project_Name)&quot;</_Laerdal_Sbom_Script_Parameters>
<_Laerdal_Sbom_Script_Parameters>$(_Laerdal_Sbom_Script_Parameters) --output-sbom-file-name &quot;sbom.laerdal.dfu.xml&quot;</_Laerdal_Sbom_Script_Parameters>

<_Laerdal_Sbom_Script_Parameters>$(_Laerdal_Sbom_Script_Parameters) --parent-project-name &quot;[Group(Legacy)::Laerdal.Dfu]&quot;</_Laerdal_Sbom_Script_Parameters>
</PropertyGroup>

<!-- https://docs.dependencytrack.org/usage/cicd/#large-payloads also notice that we are forced to target -->
<!-- /api/api/v1/bom instead of /api/v1/bom due to an inherent misconfiguration of laerdal's dependency-track server -->
<Message Importance="High" Text="** Generating, Singing and Uploading SBOMs:"/>

<Exec Command=" bash Laerdal.GenerateSignAndUploadSbom.sh $(_Laerdal_Sbom_Script_Parameters) " ConsoleToMSBuild="true" WorkingDirectory="$(Laerdal_Script_FolderPath)"/>
</Target>

</Project>
Loading

0 comments on commit f9b3c0f

Please sign in to comment.