diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1cce9822..0c8d4093 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,30 +60,24 @@ jobs: sudo apt-get install fuse - name: Build-MacOsApp run: | - cd ./PCL.Neo sudo su - dotnet restore -r osx-x64 - dotnet msbuild -t:BundleApp -p:RuntimeIdentifier=osx-x64 -property:Configuration=Release -p:SelfContained=true -p:TrimMode=link - dotnet restore -r osx-arm64 - dotnet msbuild -t:BundleApp -p:RuntimeIdentifier=osx-arm64 -property:Configuration=Release -p:SelfContained=true -p:TrimMode=link - cd ./bin/Release/net9.0/ - cd ./osx-x64/publish/ - zip -9 -r ../../PCL.Neo.osx.mac.x64.app.zip ./PCL.Neo.app - cd ../../ - cd ./osx-arm64/publish/ - zip -9 -r ../../PCL.Neo.osx.mac.arm64.app.zip ./PCL.Neo.app + sh ./mac-publish-assets/package-mac.sh + cd ./mac-publish-assets/x64 + zip -9 -r PCL.Neo.osx.mac.x64.app.zip PCL.Neo.app + cd ../arm64 + zip -9 -r PCL.Neo.osx.mac.arm64.app.zip PCL.Neo.app - name: UploadArtifacts osx.mac.arm64 uses: actions/upload-artifact@v4 with: name: osx.mac.arm64 path: | - PCL.Neo/bin/Release/net9.0/PCL.Neo.osx.mac.arm64.app.zip + mac-publish-assets/arm64/PCL.Neo.osx.mac.arm64.app.zip - name: UploadArtifacts osx.mac.x64 uses: actions/upload-artifact@v4 with: name: osx.mac.x64 path: | - PCL.Neo/bin/Release/net9.0/PCL.Neo.osx.mac.x64.app.zip + mac-publish-assets/x64/PCL.Neo.osx.mac.x64.app.zip build-WinExe: runs-on: ubuntu-22.04 steps: diff --git a/mac-publish-assets/Info.plist b/mac-publish-assets/Info.plist new file mode 100644 index 00000000..556422f5 --- /dev/null +++ b/mac-publish-assets/Info.plist @@ -0,0 +1,28 @@ + + + + + CFBundleName + PCL.Neo + CFBundleDisplayName + PCL.Neo + CFBundleIdentifier + github.com/PCL-Community/PCL.Neo + CFBundleVersion + 1.0.0 + CFBundlePackageType + AAPL + CFBundleSignature + PCL.Neo + CFBundleExecutable + PCL.Neo + CFBundleIconFile + PCL.Neo.icns + CFBundleShortVersionString + 1.0 + NSPrincipalClass + NSApplication + NSHighResolutionCapable + + + diff --git a/mac-publish-assets/PCL.Neo.icns b/mac-publish-assets/PCL.Neo.icns new file mode 100644 index 00000000..860ffa26 Binary files /dev/null and b/mac-publish-assets/PCL.Neo.icns differ diff --git a/mac-publish-assets/PCLNeoEntitlements.entitlements b/mac-publish-assets/PCLNeoEntitlements.entitlements new file mode 100644 index 00000000..14fc0084 --- /dev/null +++ b/mac-publish-assets/PCLNeoEntitlements.entitlements @@ -0,0 +1,10 @@ + + + + + com.apple.security.cs.allow-jit + + com.apple.security.automation.apple-events + + + diff --git a/mac-publish-assets/package-mac.sh b/mac-publish-assets/package-mac.sh new file mode 100644 index 00000000..e023cfa5 --- /dev/null +++ b/mac-publish-assets/package-mac.sh @@ -0,0 +1,60 @@ +#!/bin/bash +# 此脚本中签名和hdiutil的部分只能在Mac上运行! + +INFO_PLIST="Info.plist" +ICON_FILE="PCL.Neo.icns" +ENTITLEMENTS="PCLNeoEntitlements.entitlements" +# SIGNING_IDENTITY="Developer ID: PCLCommunity" + +cd ./PCL.Neo +dotnet publish -r osx-arm64 --configuration Release -p:UseAppHost=true +dotnet publish -r osx-x64 --configuration Release -p:UseAppHost=true + +cd ../mac-publish-assets + +# 创建输出目录 +mkdir -p arm64 +mkdir -p x64 + +# 打包 arm64 版本 +APP_NAME_ARM64="arm64/PCL.Neo.app" +PUBLISH_OUTPUT_DIRECTORY_ARM64="../PCL.Neo/bin/Release/net9.0/osx-arm64/publish/." + +if [ -d "$APP_NAME_ARM64" ]; then + rm -rf "$APP_NAME_ARM64" +fi + +mkdir -p "$APP_NAME_ARM64/Contents/MacOS" +mkdir -p "$APP_NAME_ARM64/Contents/Resources" + +cp "$INFO_PLIST" "$APP_NAME_ARM64/Contents/Info.plist" +cp "$ICON_FILE" "$APP_NAME_ARM64/Contents/Resources/PCL.Neo.icns" +cp -a $PUBLISH_OUTPUT_DIRECTORY_ARM64/* "$APP_NAME_ARM64/Contents/MacOS/" + +# find "$APP_NAME_ARM64/Contents/MacOS/"|while read fname; do +# if [[ -f $fname ]]; then +# echo "[INFO] Signing $fname" +# codesign --force --timestamp --options=runtime --entitlements "$ENTITLEMENTS" --sign "$SIGNING_IDENTITY" "$fname" +# fi +# done + +# echo "[INFO] Signing app file" + +# codesign --force --timestamp --options=runtime --entitlements "$ENTITLEMENTS" --sign "$SIGNING_IDENTITY" "$APP_NAME" +# hdiutil create -volname "PCL.Neo.Arm64" -srcfolder $APP_NAME_ARM64 -ov -format UDZO arm64/PCL.Neo.dmg + +# 打包 x64 版本 +APP_NAME_X64="x64/PCL.Neo.app" +PUBLISH_OUTPUT_DIRECTORY_X64="../PCL.Neo/bin/Release/net9.0/osx-x64/publish/." + +if [ -d "$APP_NAME_X64" ]; then + rm -rf "$APP_NAME_X64" +fi + +mkdir -p "$APP_NAME_X64/Contents/MacOS" +mkdir -p "$APP_NAME_X64/Contents/Resources" + +cp "$INFO_PLIST" "$APP_NAME_X64/Contents/Info.plist" +cp "$ICON_FILE" "$APP_NAME_X64/Contents/Resources/PCL.Neo.icns" +cp -a $PUBLISH_OUTPUT_DIRECTORY_X64/* "$APP_NAME_X64/Contents/MacOS/" +# hdiutil create -volname "PCL.Neo.X64" -srcfolder $APP_NAME_X64 -ov -format UDZO x64/PCL.Neo.dmg