fix macOS updater
Some checks are pending
Build / windows (arm64) (push) Waiting to run
Build / windows (ia32) (push) Waiting to run
Build / windows (x64) (push) Waiting to run
Build / windows7 (ia32) (push) Waiting to run
Build / windows7 (x64) (push) Waiting to run
Build / linux (arm64) (push) Waiting to run
Build / linux (x64) (push) Waiting to run
Build / macos (arm64) (push) Waiting to run
Build / macos (x64) (push) Waiting to run
Build / updater (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-bin) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-electron) (push) Blocked by required conditions
Build / aur-release-updater (mihomo-party-electron-bin) (push) Blocked by required conditions
Build / aur-git-updater (push) Waiting to run
Build / Update WinGet Package (push) Blocked by required conditions
Build / Update Homebrew cask (push) Blocked by required conditions

This commit is contained in:
pompurin404 2024-09-23 13:03:11 +08:00
parent 526282ce9b
commit 00ee111c0b
No known key found for this signature in database
5 changed files with 21 additions and 16 deletions

View File

@ -198,7 +198,7 @@ jobs:
npm_config_target_arch: ${{ matrix.arch }}
run: pnpm build:mac --${{ matrix.arch }}
- name: Generate checksums
run: pnpm checksum .dmg .zip
run: pnpm checksum .dmg
- name: Upload Artifacts
if: startsWith(github.ref, 'refs/heads/')
uses: actions/upload-artifact@v4
@ -207,7 +207,6 @@ jobs:
path: |
dist/*.sha256
dist/*.dmg
dist/*.zip
if-no-files-found: error
- name: Publish Release
if: startsWith(github.ref, 'refs/tags/v')
@ -216,7 +215,6 @@ jobs:
files: |
dist/*.sha256
dist/*.dmg
dist/*.zip
body_path: changelog.md
token: ${{ secrets.GITHUB_TOKEN }}

View File

@ -1,8 +1,3 @@
### Features
- 支持在特定WiFi SSID下直连
- 支持同步运行时配置到GitHub Gist
### Bug Fixes
- 修复某些mac无法开启开机启动的问题
- 修复macOS应用内更新后权限丢失的问题

View File

@ -40,7 +40,6 @@ nsis:
mac:
target:
- dmg
- zip
entitlementsInherit: build/entitlements.mac.plist
extendInfo:
- NSCameraUsageDescription: Application requests access to the device's camera.

View File

@ -2,7 +2,7 @@ import axios from 'axios'
import yaml from 'yaml'
import { app } from 'electron'
import { getControledMihomoConfig } from '../config'
import { dataDir, exeDir, isPortable, resourcesFilesDir } from '../utils/dirs'
import { dataDir, exeDir, exePath, isPortable, resourcesFilesDir } from '../utils/dirs'
import { rm, writeFile } from 'fs/promises'
import path from 'path'
import { existsSync } from 'fs'
@ -39,8 +39,8 @@ export async function downloadAndInstallUpdate(version: string): Promise<void> {
'win32-x64': `mihomo-party-windows-${version}-x64-setup.exe`,
'win32-ia32': `mihomo-party-windows-${version}-ia32-setup.exe`,
'win32-arm64': `mihomo-party-windows-${version}-arm64-setup.exe`,
'darwin-x64': `mihomo-party-macos-${version}-x64.zip`,
'darwin-arm64': `mihomo-party-macos-${version}-arm64.zip`
'darwin-x64': `mihomo-party-macos-${version}-x64.dmg`,
'darwin-arm64': `mihomo-party-macos-${version}-arm64.dmg`
}
let file = fileMap[`${process.platform}-${process.arch}`]
if (isPortable()) {
@ -84,9 +84,22 @@ export async function downloadAndInstallUpdate(version: string): Promise<void> {
).unref()
app.quit()
}
if (file.endsWith('.zip')) {
if (file.endsWith('.dmg')) {
const execPromise = promisify(exec)
await execPromise(`unzip -o -K '${path.join(dataDir(), file)}' -d /Applications`)
const name = exePath().split('.app')[0].replace('/Applications/', '')
await execPromise(
`hdiutil attach "${path.join(dataDir(), file)}" -mountpoint "/Volumes/mihomo-party" -nobrowse`
)
try {
await execPromise(`mv /Applications/${name}.app /tmp`)
await execPromise('cp -R "/Volumes/mihomo-party/mihomo-party.app" /Applications/')
await execPromise(`rm -rf /tmp/${name}.app`)
} catch (e) {
await execPromise(`mv /tmp/${name}.app /Applications`)
throw e
} finally {
await execPromise('hdiutil detach "/Volumes/mihomo-party"')
}
app.relaunch()
app.quit()
}

View File

@ -105,7 +105,7 @@ async function cleanup(): Promise<void> {
// update cache
const files = await readdir(dataDir())
for (const file of files) {
if (file.endsWith('.exe') || file.endsWith('.dmg') || file.endsWith('.zip')) {
if (file.endsWith('.exe') || file.endsWith('.dmg')) {
try {
await rm(path.join(dataDir(), file))
} catch {