From ad2705b6906c7497ca29194517ecb4e6d5027e91 Mon Sep 17 00:00:00 2001 From: xunbu Date: Sun, 24 Aug 2025 12:15:51 +0800 Subject: [PATCH] =?UTF-8?q?macos=E6=89=93=E5=8C=85=E5=B8=A6=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/build-macos.yml | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-macos.yml b/.github/workflows/build-macos.yml index 175c098..62e77a1 100644 --- a/.github/workflows/build-macos.yml +++ b/.github/workflows/build-macos.yml @@ -40,7 +40,15 @@ jobs: run: | uv run pyinstaller lite_mac.spec --noconfirm - # 第 7 步: 创建 macOS 应用包结构 + # 第 7 步: 获取应用版本号 + - name: Get application version + id: get_version + run: | + VERSION=$(python -c "import docutranslate; print(docutranslate.__version__)") + echo "VERSION=$VERSION" >> $GITHUB_ENV + echo "version=$VERSION" >> $GITHUB_OUTPUT + + # 第 8 步: 创建 macOS 应用包结构 - name: Create macOS app bundle structure run: | mkdir -p dist/DocuTranslate.app/Contents/MacOS @@ -70,7 +78,7 @@ jobs: CFBundleVersion ${{ github.run_number }} CFBundleShortVersionString - $(python -c "import docutranslate; print(docutranslate.__version__)") + ${{ env.VERSION }} NSHighResolutionCapable @@ -78,14 +86,14 @@ jobs: EOF shell: bash - # 第 8 步: 将 .app 打包成 .dmg 磁盘映像 - - name: Create DMG Disk Image + # 第 9 步: 将 .app 打包成 .dmg 磁盘映像(带版本号) + - name: Create DMG Disk Image with version run: | - hdiutil create -volname "DocuTranslate Installer" -srcfolder dist/DocuTranslate.app -ov -format UDZO dist/DocuTranslate-macOS.dmg + hdiutil create -volname "DocuTranslate Installer" -srcfolder dist/DocuTranslate.app -ov -format UDZO "dist/DocuTranslate-${{ env.VERSION }}-macOS.dmg" - # 第 9 步: 上传 .dmg 文件作为构建产物 + # 第 10 步: 上传 .dmg 文件作为构建产物 - name: Upload macOS DMG uses: actions/upload-artifact@v4 with: - name: DocuTranslate-macOS - path: dist/DocuTranslate-macOS.dmg # <--- 修改这里,上传 .dmg 文件 \ No newline at end of file + name: DocuTranslate-macOS-${{ env.VERSION }} + path: dist/DocuTranslate-${{ env.VERSION }}-macOS.dmg \ No newline at end of file