From 8404c3589d0447760ce3b2d98a439c29cc67f149 Mon Sep 17 00:00:00 2001 From: AoEiuV020 Date: Wed, 25 Dec 2024 21:41:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=8D=A2mac=20dmg=E6=89=93=E5=8C=85?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 不使用node系的工具,改用原生自带的hdiutil, --- .github/workflows/main.yml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 81ddac8..5f0b9f7 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -233,21 +233,22 @@ jobs: path: ${{ matrix.RELEASE_PATH }} directory: ${{ matrix.RELEASE_DIRECTORY }} filename: ${{ github.workspace }}/build/${{ env.BUILD_NAME_WITH_VERSION }}-${{ matrix.name }}.${{ matrix.FILE_TYPE }} - - name: set python version - if: "${{ matrix.FILE_TYPE == 'dmg' }}" - uses: actions/setup-python@v4 - with: - python-version: '3.11' - name: dmg if: "${{ matrix.FILE_TYPE == 'dmg' }}" run: | - npm install -g appdmg appPath=$(ls -d ${{ matrix.RELEASE_DIRECTORY }}/${{ matrix.RELEASE_PATH }}) - echo '{"title":"###TITLE###","icon":"###PATH###/Contents/Resources/AppIcon.icns","contents":[{"x":448,"y":144,"type":"link","path":"/Applications"},{"x":192,"y":144,"type":"file","path":"###PATH###"}]}' | - sed "s/###TITLE###/${{ env.BUILD_NAME }}/g" | - sed "s/###PATH###/$(echo $appPath | sed 's_/_\\/_g')/g" | - tee ./appdmg.json - appdmg ./appdmg.json build/${{ env.BUILD_NAME_WITH_VERSION }}-${{ matrix.name }}.${{ matrix.FILE_TYPE }} + cd build + # 创建临时目录 + mkdir -p dist + # 复制 app 到临时目录 + cp -r "$appPath" dist/ + # 创建 Applications 软链接 + ln -s /Applications dist/Applications + # 使用 hdiutil 创建 dmg + hdiutil create -volname "${{ env.BUILD_NAME }}" \ + -srcfolder dist \ + -format UDZO \ + "${{ env.BUILD_NAME_WITH_VERSION }}-${{ matrix.name }}.${{ matrix.FILE_TYPE }}" - name: copy file if: "${{ matrix.FILE_TYPE == 'apk' || matrix.FILE_TYPE == 'aab' }}" run: cp ${{ matrix.RELEASE_DIRECTORY }}/${{ matrix.RELEASE_PATH }} build/${{ env.BUILD_NAME_WITH_VERSION }}-${{ matrix.name }}.${{ matrix.FILE_TYPE }}