From c4c97fcc8c08c0d3ac6e682f6133ae03b7f48e6a Mon Sep 17 00:00:00 2001 From: Jason Dove Date: Sun, 23 Jan 2022 18:36:31 -0600 Subject: [PATCH] customize mac dmg --- .github/workflows/artifacts.yml | 36 +++++++++++++++++++++++------ gon.json | 16 +++++-------- scripts/macOS/ErsatzTV.entitlements | 6 +++++ scripts/macOS/Info.plist | 26 +++++++++++++++++++++ scripts/macOS/bundle.sh | 26 +++++++++++++++++++++ scripts/macOS/sign-dmg.sh | 10 ++++++++ scripts/macOS/sign.sh | 10 +++++--- 7 files changed, 110 insertions(+), 20 deletions(-) create mode 100644 scripts/macOS/Info.plist create mode 100755 scripts/macOS/bundle.sh create mode 100755 scripts/macOS/sign-dmg.sh diff --git a/.github/workflows/artifacts.yml b/.github/workflows/artifacts.yml index 378bae59b..8e7e80733 100644 --- a/.github/workflows/artifacts.yml +++ b/.github/workflows/artifacts.yml @@ -27,7 +27,7 @@ on: required: true jobs: build_and_upload_mac: - name: Build & Upload Mac Artifacts + name: Mac Build & Upload runs-on: ${{ matrix.os }} if: contains(github.event.head_commit.message, '[no build]') == false strategy: @@ -69,14 +69,35 @@ jobs: echo "RELEASE_NAME=${release_name}" >> $GITHUB_ENV - name: Build + shell: bash + run: dotnet publish ErsatzTV/ErsatzTV.csproj --framework net6.0 --runtime "${{ matrix.target }}" -c Release -o publish -p:InformationalVersion="${{ inputs.release_version }}-${{ matrix.target }}" -p:EnableCompressionInSingleFile=true -p:DebugType=Embedded -p:PublishSingleFile=true --self-contained true + + - name: Bundle shell: bash run: | - dotnet msbuild ErsatzTV/ErsatzTV.csproj -t:BundleApp -p:RuntimeIdentifier="${{ matrix.target }}" -p:CFBundleVersion="${{ inputs.info_version }}" -p:Configuration=Release -p:CFBundleShortVersionString="${{ inputs.info_version }}" -p:InformationalVersion="${{ inputs.release_version }}-${{ matrix.target }}" -p:PublishDir=$(pwd)/release - cp scripts/macOS/launcher.sh release/ErsatzTV.app/Contents/MacOS/ + plutil -replace CFBundleShortVersionString -string "${{ inputs.info_version }}" scripts/macOS/Info.plist + plutil -replace CFBundleVersion -string "${{ inputs.info_version }}" scripts/macOS/Info.plist + scripts/macOS/bundle.sh - name: Sign shell: bash run: scripts/macOS/sign.sh + + - name: Create DMG + shell: bash + run: | + brew install create-dmg + create-dmg \ + --volname "ErsatzTV" \ + --volicon "artwork/ErsatzTV.icns" \ + --window-pos 200 120 \ + --window-size 800 400 \ + --icon-size 100 \ + --icon "ErsatzTV.app" 200 190 \ + --hide-extension "ErsatzTV.app" \ + --app-drop-link 600 185 \ + "ErsatzTV.dmg" \ + "ErsatzTV.app/" - name: Notarize shell: bash @@ -91,8 +112,9 @@ jobs: - name: Cleanup shell: bash run: | - mv release/ErsatzTV.dmg "${{ env.RELEASE_NAME }}.dmg" - rm -r release + mv ErsatzTV.dmg "${{ env.RELEASE_NAME }}.dmg" + rm -r publish + rm -r ErsatzTV.app - name: Delete old release assets uses: mknejp/delete-release-assets@v1 @@ -113,7 +135,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.gh_token }} build_and_upload: - name: Build & Upload Artifacts + name: Build & Upload runs-on: ${{ matrix.os }} if: contains(github.event.head_commit.message, '[no build]') == false strategy: @@ -153,7 +175,7 @@ jobs: echo "RELEASE_NAME=${release_name}" >> $GITHUB_ENV # Build everything - dotnet publish ErsatzTV/ErsatzTV.csproj --framework net6.0 --runtime "${{ matrix.target }}" -c Release -o "$release_name" /property:InformationalVersion="${{ inputs.release_version }}-${{ matrix.target }}" /property:EnableCompressionInSingleFile=true /property:DebugType=Embedded /property:PublishSingleFile=true --self-contained true + dotnet publish ErsatzTV/ErsatzTV.csproj --framework net6.0 --runtime "${{ matrix.target }}" -c Release -o "$release_name" -p:InformationalVersion="${{ inputs.release_version }}-${{ matrix.target }}" -p:EnableCompressionInSingleFile=true -p:DebugType=Embedded -p:PublishSingleFile=true --self-contained true # Pack files if [ "${{ matrix.kind }}" == "windows" ]; then diff --git a/gon.json b/gon.json index 69706c7b5..f5806c905 100644 --- a/gon.json +++ b/gon.json @@ -1,15 +1,11 @@ { - "source" : ["./release/ErsatzTV.app"], - "bundle_id" : "com.jasongdove.ersatztv", + "notarize": [{ + "path": "./ErsatzTV.dmg", + "bundle_id": "com.jasongdove.ersatztv", + "staple": true + }], + "apple_id": { "password": "@env:AC_PASSWORD" - }, - "sign" :{ - "application_identity" : "C3BBCFB2D6851FF0DCA6CAC06A3EF1ECE71F9FFF", - "entitlements_file": "./scripts/macOS/ErsatzTV.entitlements" - }, - "dmg" :{ - "output_path": "./release/ErsatzTV.dmg", - "volume_name": "ErsatzTV" } } diff --git a/scripts/macOS/ErsatzTV.entitlements b/scripts/macOS/ErsatzTV.entitlements index 5c80b43c9..5bb134a68 100644 --- a/scripts/macOS/ErsatzTV.entitlements +++ b/scripts/macOS/ErsatzTV.entitlements @@ -6,5 +6,11 @@ com.apple.security.automation.apple-events + com.apple.security.cs.allow-unsigned-executable-memory + + com.apple.security.cs.allow-dyld-environment-variables + + com.apple.security.cs.disable-library-validation + diff --git a/scripts/macOS/Info.plist b/scripts/macOS/Info.plist new file mode 100644 index 000000000..d8b75487e --- /dev/null +++ b/scripts/macOS/Info.plist @@ -0,0 +1,26 @@ + + + + + CFBundleDisplayName + ErsatzTV + CFBundleExecutable + launcher.sh + CFBundleIconFile + ErsatzTV.icns + CFBundleIdentifier + com.jasongdove.ersatztv + CFBundleName + ErsatzTV + CFBundlePackageType + APPL + CFBundleShortVersionString + 0.3.7-alpha + CFBundleVersion + 0.3.7-alpha + NSHighResolutionCapable + + NSPrincipalClass + NSApplication + + diff --git a/scripts/macOS/bundle.sh b/scripts/macOS/bundle.sh new file mode 100755 index 000000000..2704d3422 --- /dev/null +++ b/scripts/macOS/bundle.sh @@ -0,0 +1,26 @@ +#! /bin/bash + +SCRIPT_FOLDER=$(dirname ${BASH_SOURCE[0]}) +REPO_ROOT="$SCRIPT_FOLDER/../.." + +APP_NAME="$REPO_ROOT/ErsatzTV.app" +PUBLISH_OUTPUT_DIRECTORY="$REPO_ROOT/publish/." +INFO_PLIST="$SCRIPT_FOLDER/Info.plist" +ICON_SOURCE="$REPO_ROOT/artwork/ErsatzTV.icns" +ICON_FILE="ErsatzTV.icns" + +if [ -d "$APP_NAME" ] +then + rm -rf "$APP_NAME" +fi + +mkdir "$APP_NAME" + +mkdir "$APP_NAME/Contents" +mkdir "$APP_NAME/Contents/MacOS" +mkdir "$APP_NAME/Contents/Resources" + +cp "$INFO_PLIST" "$APP_NAME/Contents/Info.plist" +cp "$ICON_SOURCE" "$APP_NAME/Contents/Resources/$ICON_FILE" +cp -a "$PUBLISH_OUTPUT_DIRECTORY" "$APP_NAME/Contents/MacOS" +cp "$SCRIPT_FOLDER/launcher.sh" "$APP_NAME/Contents/MacOS/" \ No newline at end of file diff --git a/scripts/macOS/sign-dmg.sh b/scripts/macOS/sign-dmg.sh new file mode 100755 index 000000000..52ab059cc --- /dev/null +++ b/scripts/macOS/sign-dmg.sh @@ -0,0 +1,10 @@ +#! /bin/bash + +SCRIPT_FOLDER=$(dirname ${BASH_SOURCE[0]}) +REPO_ROOT="$SCRIPT_FOLDER/../.." + +DMG_NAME="$REPO_ROOT/ErsatzTV.dmg" +ENTITLEMENTS="$SCRIPT_FOLDER/ErsatzTV.entitlements" +SIGNING_IDENTITY="C3BBCFB2D6851FF0DCA6CAC06A3EF1ECE71F9FFF" + +codesign --force --timestamp --options=runtime --entitlements "$ENTITLEMENTS" --sign "$SIGNING_IDENTITY" "$DMG_NAME" diff --git a/scripts/macOS/sign.sh b/scripts/macOS/sign.sh index e3ebf034f..46c8b4493 100755 --- a/scripts/macOS/sign.sh +++ b/scripts/macOS/sign.sh @@ -1,6 +1,10 @@ -#! /bin/bash -APP_NAME="release/ErsatzTV.app" -ENTITLEMENTS="scripts/macOS/ErsatzTV.entitlements" +#! /bin/bash + +SCRIPT_FOLDER=$(dirname ${BASH_SOURCE[0]}) +REPO_ROOT="$SCRIPT_FOLDER/../.." + +APP_NAME="$REPO_ROOT/ErsatzTV.app" +ENTITLEMENTS="$SCRIPT_FOLDER/ErsatzTV.entitlements" SIGNING_IDENTITY="C3BBCFB2D6851FF0DCA6CAC06A3EF1ECE71F9FFF" find "$APP_NAME/Contents/MacOS/"|while read fname; do