diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index caf3891..a1c1ee2 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -191,7 +191,6 @@ jobs: run: | pnpm install pnpm add @mihomo-party/sysproxy-darwin-${{ matrix.arch }} - pnpm add -D electron@32.2.0 pnpm prepare --${{ matrix.arch }} - name: Build env: @@ -222,9 +221,61 @@ jobs: body_path: changelog.md token: ${{ secrets.GITHUB_TOKEN }} + macos10: + strategy: + fail-fast: false + matrix: + arch: + - x64 + - arm64 + runs-on: macos-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Setup pnpm + run: npm install -g pnpm + - name: Install Dependencies + env: + npm_config_arch: ${{ matrix.arch }} + npm_config_target_arch: ${{ matrix.arch }} + run: | + pnpm install + pnpm add @mihomo-party/sysproxy-darwin-${{ matrix.arch }} + pnpm add -D electron@32.2.0 + pnpm prepare --${{ matrix.arch }} + - name: Build + env: + npm_config_arch: ${{ matrix.arch }} + npm_config_target_arch: ${{ matrix.arch }} + run: | + sed -i "" -e "s/productName: mihomo-party/productName: Mihomo Party/" electron-builder.yml + sed -i "" -e "s/macos/catalina/" electron-builder.yml + chmod +x build/pkg-scripts/postinstall + pnpm build:mac --${{ matrix.arch }} + - name: Generate checksums + run: pnpm checksum .pkg + - name: Upload Artifacts + if: startsWith(github.ref, 'refs/heads/') + uses: actions/upload-artifact@v4 + with: + name: Catalina ${{ matrix.arch }} + path: | + dist/*.sha256 + dist/*.pkg + if-no-files-found: error + - name: Publish Release + if: startsWith(github.ref, 'refs/tags/v') + uses: softprops/action-gh-release@v2 + with: + files: | + dist/*.sha256 + dist/*.pkg + body_path: changelog.md + token: ${{ secrets.GITHUB_TOKEN }} + artifact: if: startsWith(github.ref, 'refs/heads/') - needs: [windows, macos, linux, windows7] + needs: [windows, macos, linux, windows7, macos10] runs-on: ubuntu-latest services: telegram-bot-api: @@ -252,7 +303,7 @@ jobs: updater: if: startsWith(github.ref, 'refs/tags/v') - needs: [windows, macos, windows7] + needs: [windows, macos, windows7, macos10] runs-on: ubuntu-latest steps: - name: Checkout @@ -361,7 +412,7 @@ jobs: homebrew: if: startsWith(github.ref, 'refs/tags/v') name: Update Homebrew cask - needs: macos + needs: [macos, macos10] runs-on: macos-latest steps: - name: Set up Git diff --git a/changelog.md b/changelog.md index 4c20c23..86e2f52 100644 --- a/changelog.md +++ b/changelog.md @@ -1,11 +1,4 @@ ### Breaking Changes -- macOS 改用 pkg 安装方式,不再支持 dmg 安装方式,因此本次更新需要手动下载安装包进行安装 - -### New Features - -- macOS/Linux 均不再存储 root 密码 - -### Bug Fixes - -- 修复 macOS 10.15 无法安装的问题 +- 1.5.0 之后 macOS 改用 pkg 安装方式,不再支持 dmg 安装方式,因此本次更新需要手动下载安装包进行安装 +- electron33 已不再支持 macOS 10.15,故为 10.15 提供单独的安装包,需要的用户请自行下载安装,应用内更新时会自动检测系统版本,安装后后续可正常在应用内直接更新 diff --git a/electron-builder.yml b/electron-builder.yml index 808d360..7429815 100644 --- a/electron-builder.yml +++ b/electron-builder.yml @@ -39,7 +39,6 @@ nsis: mac: target: - pkg - minimumSystemVersion: '10.15' entitlementsInherit: build/entitlements.mac.plist extendInfo: - NSCameraUsageDescription: Application requests access to the device's camera. diff --git a/scripts/artifact.mjs b/scripts/artifact.mjs index 801a111..3dad1b8 100644 --- a/scripts/artifact.mjs +++ b/scripts/artifact.mjs @@ -24,6 +24,11 @@ const macosFiles = [ path.join(GITHUB_WORKSPACE, `mihomo-party-macos-${version}-x64.pkg`) ] +const macos10Files = [ + path.join(GITHUB_WORKSPACE, `mihomo-party-catalina-${version}-arm64.pkg`), + path.join(GITHUB_WORKSPACE, `mihomo-party-catalina-${version}-x64.pkg`) +] + const windowsFiles = [ path.join(GITHUB_WORKSPACE, `mihomo-party-windows-${version}-x64-setup.exe`), path.join(GITHUB_WORKSPACE, `mihomo-party-windows-${version}-x64-portable.7z`), @@ -80,7 +85,7 @@ const macosMedia = macosFiles.map((file, index) => ({ type: 'document', media: `attach://file${index}` })) -macosMedia[macosMedia.length - 1].caption = `#${hash} #macOS\n${message}` +macosMedia[macosMedia.length - 1].caption = `#${hash} #macOS 11+\n${message}` const macosForm = new FormData() macosForm.append('chat_id', CHAT_ID) macosForm.append('media', JSON.stringify(macosMedia)) @@ -88,6 +93,18 @@ macosFiles.forEach((file, index) => { macosForm.append(`file${index}`, fs.createReadStream(file)) }) +const macos10Media = macos10Files.map((file, index) => ({ + type: 'document', + media: `attach://file${index}` +})) +macos10Media[macos10Media.length - 1].caption = `#${hash} #macOS 10.15+\n${message}` +const macos10Form = new FormData() +macos10Form.append('chat_id', CHAT_ID) +macos10Form.append('media', JSON.stringify(macos10Media)) +macos10Files.forEach((file, index) => { + macos10Form.append(`file${index}`, fs.createReadStream(file)) +}) + function sleep(ms) { return new Promise((resolve) => setTimeout(resolve, ms)) } @@ -122,6 +139,16 @@ await axios.post( await sleep(10000) +await axios.post( + `http://127.0.0.1:8081/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMediaGroup`, + macos10Form, + { + headers: macos10Form.getHeaders() + } +) + +await sleep(10000) + await axios.post( `http://127.0.0.1:8081/bot${process.env.TELEGRAM_BOT_TOKEN}/sendMediaGroup`, linuxForm, diff --git a/scripts/telegram.mjs b/scripts/telegram.mjs index f73b364..283c3c0 100644 --- a/scripts/telegram.mjs +++ b/scripts/telegram.mjs @@ -23,9 +23,12 @@ content += `便携版:64位 | 32位\n` content += `便携版:64位 | 32位\n` -content += '\nmacOS:\n' -content += `DMG:Intel | Apple Silicon\n` +content += '\nmacOS 10.15+:\n' +content += `PKG:Intel | Apple Silicon\n` content += '\nLinux:\n' content += `DEB:64位 | ARM64\n` diff --git a/scripts/updater.mjs b/scripts/updater.mjs index 8ced64d..fcfd1b5 100644 --- a/scripts/updater.mjs +++ b/scripts/updater.mjs @@ -16,8 +16,10 @@ changelog += `- 便携版:[64位](${downloadUrl}/mihomo-party-windows-${versio changelog += '\n#### Windows7/8:\n\n' changelog += `- 安装版:[64位](${downloadUrl}/mihomo-party-win7-${version}-x64-setup.exe) | [32位](${downloadUrl}/mihomo-party-win7-${version}-ia32-setup.exe)\n\n` changelog += `- 便携版:[64位](${downloadUrl}/mihomo-party-win7-${version}-x64-portable.7z) | [32位](${downloadUrl}/mihomo-party-win7-${version}-ia32-portable.7z)\n\n` -changelog += '\n#### macOS:\n\n' -changelog += `- DMG:[Intel](${downloadUrl}/mihomo-party-macos-${version}-x64.pkg) | [Apple Silicon](${downloadUrl}/mihomo-party-macos-${version}-arm64.pkg)\n\n` +changelog += '\n#### macOS 11+:\n\n' +changelog += `- PKG:[Intel](${downloadUrl}/mihomo-party-macos-${version}-x64.pkg) | [Apple Silicon](${downloadUrl}/mihomo-party-macos-${version}-arm64.pkg)\n\n` +changelog += '\n#### macOS 10.15+:\n\n' +changelog += `- PKG:[Intel](${downloadUrl}/mihomo-party-catalina-${version}-x64.pkg) | [Apple Silicon](${downloadUrl}/mihomo-party-catalina-${version}-arm64.pkg)\n\n` changelog += '\n#### Linux:\n\n' changelog += `- DEB:[64位](${downloadUrl}/mihomo-party-linux-${version}-amd64.deb) | [ARM64](${downloadUrl}/mihomo-party-linux-${version}-arm64.deb)\n\n` changelog += `- RPM:[64位](${downloadUrl}/mihomo-party-linux-${version}-x86_64.rpm) | [ARM64](${downloadUrl}/mihomo-party-linux-${version}-aarch64.rpm)` diff --git a/src/main/resolve/autoUpdater.ts b/src/main/resolve/autoUpdater.ts index 49afae3..dc8156b 100644 --- a/src/main/resolve/autoUpdater.ts +++ b/src/main/resolve/autoUpdater.ts @@ -7,7 +7,7 @@ import { copyFile, rm, writeFile } from 'fs/promises' import path from 'path' import { existsSync } from 'fs' import os from 'os' -import { exec, spawn } from 'child_process' +import { exec, execSync, spawn } from 'child_process' import { promisify } from 'util' export async function checkUpdate(): Promise { @@ -52,6 +52,14 @@ export async function downloadAndInstallUpdate(version: string): Promise { if (process.platform === 'win32' && parseInt(os.release()) < 10) { file = file.replace('windows', 'win7') } + if (process.platform === 'darwin') { + const productVersion = execSync('sw_vers -productVersion', { encoding: 'utf8' }) + .toString() + .trim() + if (parseInt(productVersion) < 11) { + file = file.replace('macos', 'catalina') + } + } try { if (!existsSync(path.join(dataDir(), file))) { const res = await axios.get(`${baseUrl}${file}`, {