Skip to content

Commit

Permalink
Initial MacOS build support
Browse files Browse the repository at this point in the history
  • Loading branch information
Beyley committed May 3, 2024
1 parent 2452280 commit b9fe997
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 5 deletions.
30 changes: 29 additions & 1 deletion .github/workflows/dotnet.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ ubuntu-latest, windows-latest ]
os: [ ubuntu-latest, windows-latest, macos-latest ]
name: Build, Test, and Upload Builds (${{ matrix.os }})
runs-on: ${{ matrix.os }}
steps:
Expand All @@ -35,6 +35,16 @@ jobs:
if: matrix.os == 'windows-latest'
shell: bash
run: dotnet publish -c Release -r win-x64 --self-contained Refresher //p:Version=${VERSION}

- name: Publish for MacOS x64
if: matrix.os == 'macos-latest'
shell: bash
run: dotnet publish -c Release -r osx-x64 --self-contained Refresher //p:Version=${VERSION}

- name: Publish for MacOS ARM64
if: matrix.os == 'macos-latest'
shell: bash
run: dotnet publish -c Release -r osx-arm64 --self-contained Refresher //p:Version=${VERSION}

- name: Upload Linux x64 build
if: matrix.os == 'ubuntu-latest'
Expand All @@ -53,3 +63,21 @@ jobs:
path: "Refresher/bin/Release/net8.0-windows/win-x64/publish/"
if-no-files-found: error
retention-days: 30

- name: Upload MacOS x64 build
if: matrix.os == 'macos-latest'
uses: actions/[email protected]
with:
name: "Refresher for MacOS x64"
path: "Refresher/bin/Release/net8.0/osx-x64/publish/"
if-no-files-found: error
retention-days: 30

- name: Upload MacOS ARM64 build
if: matrix.os == 'macos-latest'
uses: actions/[email protected]
with:
name: "Refresher for MacOS ARM64"
path: "Refresher/bin/Release/net8.0/osx-arm64/publish/"
if-no-files-found: error
retention-days: 30
36 changes: 32 additions & 4 deletions Refresher/Refresher.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,37 @@
<Project Sdk="Microsoft.NET.Sdk">

<!-- Horrible code wart to detect the target, there does not seem to be a proper way to do this in dotnet... -->

<!-- OS Detection default values -->
<PropertyGroup>
<IsWindows>False</IsWindows>
<IsOSX>False</IsOSX>
<IsLinux>False</IsLinux>
</PropertyGroup>

<!-- Check if we are targetting windows -->
<PropertyGroup Condition="($(RuntimeIdentifier.StartsWith('win')) And !$(RuntimeIdentifier.Equals('')) ) Or ( $(OS.Equals('Windows_NT')) And $(RuntimeIdentifier.Equals('')) ) ">
<IsWindows>True</IsWindows>
</PropertyGroup>

<!-- Check if we are targetting OSX -->
<PropertyGroup Condition="($(RuntimeIdentifier.StartsWith('osx')) And !$(RuntimeIdentifier.Equals('')) ) Or ( $([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::OSX))) And $(RuntimeIdentifier.Equals('')) ) ">
<IsOSX>True</IsOSX>
</PropertyGroup>

<!-- Check if we target Linux (Too many names to check, so we base it off the previous two checks) -->
<PropertyGroup Condition=" !$(IsWindows) And !$(IsOSX)">
<IsLinux>True</IsLinux>
</PropertyGroup>

<PropertyGroup>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<TargetFramework Condition="!$([MSBuild]::IsOSPlatform('Windows'))">net8.0</TargetFramework>
<TargetFramework Condition="$([MSBuild]::IsOSPlatform('Windows'))">net8.0-windows</TargetFramework>
<ApplicationId>Refresher</ApplicationId>
<TargetFramework Condition="!$(IsWindows)">net8.0</TargetFramework>
<TargetFramework Condition="$(IsWindows)">net8.0-windows</TargetFramework>
<RuntimeIdentifiers Condition="$(IsOSX)">osx-x64;osx-arm64</RuntimeIdentifiers>
<ApplicationIcon>Resources\refresher.ico</ApplicationIcon>
<BuiltInComInteropSupport Condition="'$(TargetFramework)' == 'net8.0-windows'">true</BuiltInComInteropSupport>
</PropertyGroup>
Expand All @@ -18,8 +44,10 @@
<PackageReference Include="CommandLineParser" Version="2.9.1" />
<PackageReference Include="ELFSharp" Version="2.17.3" />
<PackageReference Include="Eto.Forms" Version="2.8.3" />
<PackageReference Condition="'$(TargetFramework)' != 'net8.0-windows'" Include="Eto.Platform.Gtk" Version="2.8.3" />
<PackageReference Condition="'$(TargetFramework)' == 'net8.0-windows'" Include="Eto.Platform.Wpf" Version="2.8.3" />
<!-- This could be IsLinux, but GTK is available on basically everything, so might as well use it as the true default -->
<PackageReference Condition="!$(IsWindows) And !$(IsOSX)" Include="Eto.Platform.Gtk" Version="2.8.3" />
<PackageReference Condition="$(IsOSX)" Include="Eto.Platform.Mac64" Version="2.8.3" />
<PackageReference Condition="$(IsWindows)" Include="Eto.Platform.Wpf" Version="2.8.3" />
<EmbeddedResource Include="Resources\refresher.ico" LogicalName="refresher.ico" />
<PackageReference Include="FluentFTP" Version="49.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
Expand Down

0 comments on commit b9fe997

Please sign in to comment.