Create BuildMacOS.yml #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build PicView Avalonia on macOS | |
on: | |
push: | |
branches: | |
- dev | |
pull_request: | |
branches: | |
- dev | |
jobs: | |
build: | |
runs-on: macos-latest | |
steps: | |
# Step 1: Checkout the code | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Step 2: Setup .NET 9 SDK | |
- name: Setup .NET 9 SDK | |
uses: actions/setup-dotnet@v4 | |
with: | |
dotnet-version: '9.x' | |
# Step 3: Get version from Directory.Build.props using PowerShell | |
- name: Get version from Directory.Build.props | |
id: get-version | |
run: pwsh -File "${{ github.workspace }}/Build/Get-VersionInfo.ps1" | |
# Step 4 (x64): Publish x64 version | |
- name: Publish x64 version | |
run: | | |
dotnet publish src/PicView.MacOS/PicView.MacOS.csproj \ | |
-c Release \ | |
-r osx-x64 \ | |
--self-contained true \ | |
-p:PublishSingleFile=true \ | |
-o "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64" | |
# Step 5 (x64): Create MacOS app bundle for x64 | |
- name: Create MacOS app bundle (x64) | |
run: | | |
mkdir -p "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64/PicView.app/Contents/MacOS" | |
cp -r "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64/*" \ | |
"${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64/PicView.app/Contents/MacOS/" | |
# Step 6 (x64): Upload x64 artifact | |
- name: Upload x64 artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: PicView-v${{steps.get-version.outputs.version}}-osx-x64 | |
path: ${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-x64 | |
retention-days: 14 | |
# Step 7 (arm64): Publish arm64 version | |
- name: Publish arm64 version | |
run: | | |
dotnet publish src/PicView.MacOS/PicView.MacOS.csproj \ | |
-c Release \ | |
-r osx-arm64 \ | |
--self-contained true \ | |
-p:PublishSingleFile=true \ | |
-o "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64" | |
# Step 8 (arm64): Create MacOS app bundle for arm64 | |
- name: Create MacOS app bundle (arm64) | |
run: | | |
mkdir -p "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64/PicView.app/Contents/MacOS" | |
cp -r "${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64/*" \ | |
"${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64/PicView.app/Contents/MacOS/" | |
# Step 9 (arm64): Upload arm64 artifact | |
- name: Upload arm64 artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: PicView-v${{steps.get-version.outputs.version}}-osx-arm64 | |
path: ${{ github.workspace }}/Build/PicView-v${{steps.get-version.outputs.version}}-osx-arm64 | |
retention-days: 14 |