Skip to content

Commit

Permalink
Merge branch 'meta-dev' into meta
Browse files Browse the repository at this point in the history
  • Loading branch information
mrFq1 committed Sep 22, 2024
2 parents ae33435 + 1bf4a7e commit 36c2456
Show file tree
Hide file tree
Showing 69 changed files with 4,481 additions and 1,239 deletions.
50 changes: 22 additions & 28 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,46 +48,19 @@ jobs:
/usr/libexec/PlistBuddy -c 'Print gitCommit' ClashX/Info.plist
/usr/libexec/PlistBuddy -c 'Print buildTime' ClashX/Info.plist
- name: swiftui build infos
run: |
/usr/libexec/PlistBuddy -c "Set CFBundleVersion $(git rev-list --count origin/master..origin/meta)" ClashX/ClashX\ Meta\ SwiftUI-Info.plist
/usr/libexec/PlistBuddy -c "Set CFBundleShortVersionString $(git describe --tags --abbrev=0)" ClashX/ClashX\ Meta\ SwiftUI-Info.plist
/usr/libexec/PlistBuddy -c "Add coreVersion string $(ls clash.meta | grep -m1 "" | sed -ne 's/.*64-\(.*\).gz/\1/p')" ClashX/ClashX\ Meta\ SwiftUI-Info.plist
/usr/libexec/PlistBuddy -c "Add gitBranch string $GITHUB_REF_NAME" ClashX/ClashX\ Meta\ SwiftUI-Info.plist
/usr/libexec/PlistBuddy -c "Add gitCommit string ${GITHUB_SHA::7}" ClashX/ClashX\ Meta\ SwiftUI-Info.plist
/usr/libexec/PlistBuddy -c "Add buildTime string $(date +%Y-%m-%d\ %H:%M)" ClashX/ClashX\ Meta\ SwiftUI-Info.plist
/usr/libexec/PlistBuddy -c 'Print CFBundleVersion' ClashX/ClashX\ Meta\ SwiftUI-Info.plist
/usr/libexec/PlistBuddy -c 'Print CFBundleShortVersionString' ClashX/ClashX\ Meta\ SwiftUI-Info.plist
/usr/libexec/PlistBuddy -c 'Print coreVersion' ClashX/ClashX\ Meta\ SwiftUI-Info.plist
/usr/libexec/PlistBuddy -c 'Print gitBranch' ClashX/ClashX\ Meta\ SwiftUI-Info.plist
/usr/libexec/PlistBuddy -c 'Print gitCommit' ClashX/ClashX\ Meta\ SwiftUI-Info.plist
/usr/libexec/PlistBuddy -c 'Print buildTime' ClashX/ClashX\ Meta\ SwiftUI-Info.plist
- name: install deps
run: |
bash install_dependency.sh
xcodebuild -resolvePackageDependencies -project ClashX.xcodeproj
- name: build
if: startsWith(github.ref, 'refs/tags/')
run: |
xcodebuild archive -project ClashX.xcodeproj -scheme ClashX\ Meta -archivePath archive/ClashX.xcarchive -showBuildTimingSummary -allowProvisioningUpdates
- name: build-SwiftUI
run: |
xcodebuild archive -project ClashX.xcodeproj -scheme ClashX\ Meta\ SwiftUI -archivePath archive/ClashX\ SwiftUI.xcarchive -showBuildTimingSummary -allowProvisioningUpdates
- name: create zip
if: startsWith(github.ref, 'refs/tags/')
run: ditto -c -k --sequesterRsrc --keepParent archive/ClashX.xcarchive/Products/Applications/ClashX\ Meta.app "ClashX Meta.zip"

- name: create SwiftUI zip
run: ditto -c -k --sequesterRsrc --keepParent archive/ClashX\ SwiftUI.xcarchive/Products/Applications/ClashX\ Meta.app "ClashX Meta macOS 12.0+.zip"


- name: upload Artifact
uses: actions/upload-artifact@v4
Expand All @@ -96,6 +69,28 @@ jobs:
name: "ClashX Meta.zip"
path: "*.zip"

- name: load sparkle-repo
uses: actions/checkout@v4
if: startsWith(github.ref, 'refs/tags/')
with:
ref: sparkle
path: 'sparkle-repo'

- name: update sparkle-repo
if: startsWith(github.ref, 'refs/tags/')
run: |
cp "ClashX Meta.zip" "sparkle-repo/ClashX Meta $GITHUB_REF_NAME.zip"
brew install sparkle
echo '${{ secrets.ED_KEY }}' | $(brew --prefix)/Caskroom/sparkle/2.*/bin/generate_appcast sparkle-repo --ed-key-file -
cd sparkle-repo
git config --global user.name "github-actions[bot]"
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git add -A
git commit -m $GITHUB_REF_NAME
git push origin sparkle
- name: upload build to github
uses: softprops/action-gh-release@v2
if: startsWith(github.ref, 'refs/tags/')
Expand All @@ -105,5 +100,4 @@ jobs:
generate_release_notes: true
files: |
ClashX Meta.zip
ClashX Meta macOS 12.0+.zip
836 changes: 320 additions & 516 deletions ClashX.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"originHash" : "04a3b3bc2bf53686240dbd5a590ed7d847103b4a63a3a4cb1892d2b9b92e3a52",
"originHash" : "8ca2b383ef3a419b80259396c281989a0b5151620017e615fd9f74e2a0dabf52",
"pins" : [
{
"identity" : "alamofire",
Expand All @@ -10,15 +10,6 @@
"version" : "5.9.1"
}
},
{
"identity" : "clashx-dashboard",
"kind" : "remoteSourceControl",
"location" : "https://github.com/mrFq1/ClashX-Dashboard",
"state" : {
"branch" : "dev",
"revision" : "19da905b9261e7c47c5e36d697c466fc2fb76158"
}
},
{
"identity" : "cocoalumberjack",
"kind" : "remoteSourceControl",
Expand Down Expand Up @@ -100,6 +91,15 @@
"version" : "6.7.1"
}
},
{
"identity" : "sparkle",
"kind" : "remoteSourceControl",
"location" : "https://github.com/sparkle-project/Sparkle",
"state" : {
"revision" : "0ef1ee0220239b3776f433314515fd849025673f",
"version" : "2.6.4"
}
},
{
"identity" : "starscream",
"kind" : "remoteSourceControl",
Expand Down

This file was deleted.

6 changes: 3 additions & 3 deletions ClashX.xcodeproj/xcshareddata/xcschemes/ClashX Meta.xcscheme
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "49CF3B1C20CD7463001EBF94"
BlueprintIdentifier = "01F335B32AD10D0B0048AF77"
BuildableName = "ClashX Meta.app"
BlueprintName = "ClashX Meta"
ReferencedContainer = "container:ClashX.xcodeproj">
Expand Down Expand Up @@ -44,7 +44,7 @@
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "49CF3B1C20CD7463001EBF94"
BlueprintIdentifier = "01F335B32AD10D0B0048AF77"
BuildableName = "ClashX Meta.app"
BlueprintName = "ClashX Meta"
ReferencedContainer = "container:ClashX.xcodeproj">
Expand All @@ -61,7 +61,7 @@
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "49CF3B1C20CD7463001EBF94"
BlueprintIdentifier = "01F335B32AD10D0B0048AF77"
BuildableName = "ClashX Meta.app"
BlueprintName = "ClashX Meta"
ReferencedContainer = "container:ClashX.xcodeproj">
Expand Down
2 changes: 1 addition & 1 deletion ClashX/Actions/TerminalCleanUpAction.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ enum TerminalConfirmAction {
ConfigManager.shared.restoreTunProxy = ConfigManager.shared.isTunModeVariable.value

PrivilegedHelperManager.shared.helper()?.stopMeta()
PrivilegedHelperManager.shared.helper()?.updateTun(state: false)
PrivilegedHelperManager.shared.helper()?.updateTun(state: false, dns: ConfigManager.metaTunDNS)

let path = Paths.tempPath() + "/cacheConfigs"
try? FileManager.default.removeItem(atPath: path)
Expand Down
40 changes: 11 additions & 29 deletions ClashX/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ private let MetaCoreMd5 = "WOSHIZIDONGSHENGCHENGDEA"
@main
class AppDelegate: NSObject, NSApplicationDelegate {
private(set) var statusItem: NSStatusItem!
@IBOutlet var checkForUpdateMenuItem: NSMenuItem!

@IBOutlet var statusMenu: NSMenu!
@IBOutlet var proxySettingMenuItem: NSMenuItem!
Expand Down Expand Up @@ -116,8 +115,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
if WebPortalManager.hasWebProtal {
WebPortalManager.shared.addWebProtalMenuItem(&statusMenu)
}
AutoUpgardeManager.shared.setup()
AutoUpgardeManager.shared.setupCheckForUpdatesMenuItem(checkForUpdateMenuItem)

// install proxy helper
_ = ClashResourceManager.check()
PrivilegedHelperManager.shared.checkInstall()
Expand Down Expand Up @@ -442,7 +440,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
return
}

PrivilegedHelperManager.shared.helper()?.updateTun(state: enable)
PrivilegedHelperManager.shared.helper()?.updateTun(state: enable, dns: ConfigManager.metaTunDNS)
Logger.log("tun state updated, new: \(enable)")
}
}
Expand Down Expand Up @@ -578,7 +576,7 @@ extension AppDelegate: ClashProcessDelegate {

if ConfigManager.shared.restoreTunProxy {
ApiRequest.updateTun(enable: true) {
PrivilegedHelperManager.shared.helper()?.updateTun(state: true)
PrivilegedHelperManager.shared.helper()?.updateTun(state: true, dns: ConfigManager.metaTunDNS)
}
} else {
syncConfigWithTun(true)
Expand Down Expand Up @@ -750,6 +748,14 @@ extension AppDelegate {
// MARK: Streaming Info

extension AppDelegate: ApiRequestStreamDelegate {
func didUpdateMemory(memory: Int64) {

}

func streamStatusChanged() {

}

func didUpdateTraffic(up: Int, down: Int) {
statusItemView.updateSpeedLabel(up: up, down: down)
}
Expand Down Expand Up @@ -824,30 +830,6 @@ extension AppDelegate {
}
}

@IBAction func checkForUpdate(_ sender: NSMenuItem) {
let unc = NSUserNotificationCenter.default
AF.request("https://api.github.com/repos/MetaCubeX/ClashX.Meta/releases/latest").responseString {
guard $0.error == nil,
let data = $0.data,
let tagName = try? JSON(data: data)["tag_name"].string else {
unc.postUpdateNotice(msg: NSLocalizedString("Some thing failed.", comment: ""))
return
}

if tagName != AppVersionUtil.currentVersion {
let alert = NSAlert()
alert.messageText = NSLocalizedString("Open github release page to download ", comment: "") + "\(tagName)"
alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
alert.addButton(withTitle: NSLocalizedString("Cancel", comment: ""))
if alert.runModal() == .alertFirstButtonReturn {
NSWorkspace.shared.open(.init(string: "https://github.com/MetaCubeX/ClashX.Meta/releases/latest")!)
}
} else {
unc.postUpdateNotice(msg: NSLocalizedString("No new release found.", comment: ""))
}
}
}

@IBAction func updateGEO(_ sender: NSMenuItem) {
guard updateGeoTimer == nil else { return }
updateGeoTimer = Timer.scheduledTimer(withTimeInterval: 500, repeats: true) { [weak self] timer in
Expand Down
Loading

0 comments on commit 36c2456

Please sign in to comment.