Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,10 @@ DerivedData/
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!azooKeyMac.xcodeproj/project.xcworkspace/
azooKeyMac.xcodeproj/project.xcworkspace/*
!azooKeyMac.xcodeproj/project.xcworkspace/xcshareddata/
!azooKeyMac.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/
!azooKeyMac.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved
**/xcshareddata/WorkspaceSettings.xcsettings
!*.xcworkspace/contents.xcworkspacedata
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,36 @@ ls -lh azooKeyMac/Resources/zenz-v3.1-small-gguf/ggml-model-Q5_K_M.gguf
* Git LFSが導入されていない環境では、重みファイルがローカル環境に落とせていない場合があります。`azooKeyMac/Resources/zenz-v3.1-small-gguf/ggml-model-Q5_K_M.gguf` が数十MB以上あるかを確認し、ポインタのままであれば `git -C azooKeyMac/Resources/zenz-v3.1-small-gguf lfs pull` を実行してください

### pkgファイルの作成
`pkgbuild.sh`によって配布用のdmgファイルを作成できます。`build/azooKeyMac.app` としてDeveloper IDで署名済みの.appを配置してください。
`pkgbuild.sh`によって配布用のpkgファイルを作成できます。作成された `azooKey-release-signed.pkg` は初回インストールと上書きインストールの両方で利用します。

自動アップデートはSparkle経由のpkg更新として配布します。リリースビルドではSparkleの `generate_keys` で作成した公開鍵を `SPARKLE_PUBLIC_ED_KEY` に設定してください。

初回のみ、SparkleのEdDSA鍵を生成します。`generate_keys` は秘密鍵を実行したMacのlogin Keychainに保存し、アプリへ埋め込む公開鍵を出力します。秘密鍵はGitHubやリポジトリに置かないでください。

```sh
xcodebuild -resolvePackageDependencies \
-project azooKeyMac.xcodeproj \
-scheme azooKeyMac \
-clonedSourcePackagesDirPath ./build/source-packages

./build/source-packages/artifacts/sparkle/Sparkle/bin/generate_keys
```

出力された `SUPublicEDKey` の文字列を、以後のrelease時に `SPARKLE_PUBLIC_ED_KEY` として渡します。

GitHub Releaseの作成は `create_release.sh` で行います。このスクリプトは実行中のcommitにtagを打ち、`pkgbuild.sh` を実行し、`azooKey-release-signed.pkg` と `appcast.xml` をGitHub Releaseへアップロードします。release前に `CURRENT_PROJECT_VERSION` を増やしてください。

```sh
SPARKLE_PUBLIC_ED_KEY="..." ./create_release.sh --stable-release
SPARKLE_PUBLIC_ED_KEY="..." ./create_release.sh --pre-release
SPARKLE_PUBLIC_ED_KEY="..." ./create_release.sh --test-release
```

stable releaseのtagは標準で `vMARKETING_VERSION`、pre-releaseのtagは `vMARKETING_VERSION-pre.CURRENT_PROJECT_VERSION` になります。必要な場合は `--tag`、`--repo`、`--remote` で上書きできます。

`--test-release` は自動アップデートの動作検証用です。標準では固定tag `sparkle-update-test` のGitHub Releaseを作成または更新し、アプリに埋め込むfeed URLも `https://github.com/azooKey/azooKey-Desktop/releases/download/sparkle-update-test/appcast.xml` に切り替えます。このpkgを手動インストールした環境では、以後Sparkleが検証用feedを見に行きます。tag名を変える場合は `TEST_RELEASE_TAG` または `--tag`、feed URLを別の固定URLにしたい場合は `SPARKLE_FEED_URL` を指定してください。

pkg更新後、postinstallはConverterServerのLaunchAgentを再登録してConverterServerだけを再起動します。既に起動しているazooKeyMacクライアントは終了せず、クライアント側の更新は次回ログイン後に反映されます。

### v1.0リリースに向けて
[meta: v1.0のリリースに向けたロードマップ(#181)](https://github.com/azooKey/azooKey-Desktop/issues/181)をご覧ください.
Expand Down
24 changes: 24 additions & 0 deletions azooKeyMac.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
551434E82D576B6600A9B5CA /* lm_c_abc.marisa in Resources */ = {isa = PBXBuildFile; fileRef = 551434E12D576B6600A9B5CA /* lm_c_abc.marisa */; };
551434EA2D57A8AC00A9B5CA /* ggml-model-Q5_K_M.gguf in Resources */ = {isa = PBXBuildFile; fileRef = 551434E92D57A8AC00A9B5CA /* ggml-model-Q5_K_M.gguf */; };
554A26602DB37657003C5CFB /* Core in Frameworks */ = {isa = PBXBuildFile; productRef = 554A265F2DB37657003C5CFB /* Core */; };
556B9A102EFD000000000001 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = 556B9A0F2EFD000000000001 /* Sparkle */; };
556C52FB2BAAAF7E00EB343F /* en.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 556C52F92BAAAF7D00EB343F /* en.tiff */; };
556C52FC2BAAAF7E00EB343F /* en@2x.tiff in Resources */ = {isa = PBXBuildFile; fileRef = 556C52FA2BAAAF7D00EB343F /* en@2x.tiff */; };
55A27D022BAAADDB00512DCD /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 55A27D002BAAADDB00512DCD /* InfoPlist.strings */; };
Expand Down Expand Up @@ -75,6 +76,7 @@
buildActionMask = 2147483647;
files = (
554A26602DB37657003C5CFB /* Core in Frameworks */,
556B9A102EFD000000000001 /* Sparkle in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -175,6 +177,7 @@
name = azooKeyMac;
packageProductDependencies = (
554A265F2DB37657003C5CFB /* Core */,
556B9A0F2EFD000000000001 /* Sparkle */,
);
productName = azooKeyMac;
productReference = 1A41E61426E745D9009B65D7 /* azooKeyMac.app */;
Expand Down Expand Up @@ -256,6 +259,7 @@
mainGroup = 1A41E60B26E745D9009B65D7;
packageReferences = (
554A265E2DB37657003C5CFB /* XCLocalSwiftPackageReference "Core" */,
556B9A0E2EFD000000000001 /* XCRemoteSwiftPackageReference "Sparkle" */,
);
productRefGroup = 1A41E61526E745D9009B65D7 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -530,6 +534,8 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = dev.ensan.inputmethod.azooKeyMac;
PRODUCT_NAME = "$(TARGET_NAME)";
SPARKLE_FEED_URL = "https://github.com/azooKey/azooKey-Desktop/releases/latest/download/appcast.xml";
SPARKLE_PUBLIC_ED_KEY = "";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OBJC_INTEROP_MODE = objcxx;
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -566,6 +572,8 @@
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = dev.ensan.inputmethod.azooKeyMac;
PRODUCT_NAME = "$(TARGET_NAME)";
SPARKLE_FEED_URL = "https://github.com/azooKey/azooKey-Desktop/releases/latest/download/appcast.xml";
SPARKLE_PUBLIC_ED_KEY = "";
SWIFT_EMIT_LOC_STRINGS = YES;
SWIFT_OBJC_INTEROP_MODE = objcxx;
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -712,6 +720,17 @@
};
/* End XCLocalSwiftPackageReference section */

/* Begin XCRemoteSwiftPackageReference section */
556B9A0E2EFD000000000001 /* XCRemoteSwiftPackageReference "Sparkle" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/sparkle-project/Sparkle";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 2.9.3;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
554A265F2DB37657003C5CFB /* Core */ = {
isa = XCSwiftPackageProductDependency;
Expand All @@ -722,6 +741,11 @@
package = 554A265E2DB37657003C5CFB /* XCLocalSwiftPackageReference "Core" */;
productName = Core;
};
556B9A0F2EFD000000000001 /* Sparkle */ = {
isa = XCSwiftPackageProductDependency;
package = 556B9A0E2EFD000000000001 /* XCRemoteSwiftPackageReference "Sparkle" */;
productName = Sparkle;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = 1A41E60C26E745D9009B65D7 /* Project object */;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

41 changes: 41 additions & 0 deletions azooKeyMac/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Cocoa
import Core
import InputMethodKit
import KanaKanjiConverterModuleWithDefaultDictionary
import Sparkle
import SwiftUI

// Necessary to launch this app
Expand All @@ -34,6 +35,7 @@ class AppDelegate: NSObject, NSApplicationDelegate {
var configWindowController: NSWindowController?
var userDictionaryEditorWindowController: NSWindowController?
var kanaKanjiConverter = KanaKanjiConverter.withDefaultDictionary()
private var updaterController: SPUStandardUpdaterController?

private var userDictionaryMemoryDirectoryURL: URL {
AppGroup.memoryDirectoryURL()
Expand Down Expand Up @@ -122,10 +124,47 @@ class AppDelegate: NSObject, NSApplicationDelegate {
}
}

@objc private func checkForUpdates(_ sender: Any?) {
guard let updaterController else {
let alert = NSAlert()
alert.messageText = "自動アップデートは未設定です"
alert.informativeText = "SPARKLE_FEED_URL と SPARKLE_PUBLIC_ED_KEY を設定したビルドで利用できます。"
alert.runModal()
return
}
updaterController.checkForUpdates(sender)
}

private func configureUpdaterIfAvailable() {
guard
let feedURL = Bundle.main.object(forInfoDictionaryKey: "SUFeedURL") as? String,
!feedURL.isEmpty,
let publicEDKey = Bundle.main.object(forInfoDictionaryKey: "SUPublicEDKey") as? String,
!publicEDKey.isEmpty
else {
NSLog("Sparkle updater is disabled because SUFeedURL or SUPublicEDKey is not configured.")
return
}
self.updaterController = SPUStandardUpdaterController(startingUpdater: true, updaterDelegate: nil, userDriverDelegate: nil)
}

private func addApplicationMenuIfNeeded() {
let appMenuItem = NSMenuItem(title: "azooKey", action: nil, keyEquivalent: "")
NSApp.mainMenu?.addItem(appMenuItem)

let appSubmenu = NSMenu(title: "azooKey")
appMenuItem.submenu = appSubmenu

let checkForUpdatesItem = NSMenuItem(title: "更新を確認...", action: #selector(checkForUpdates(_:)), keyEquivalent: "")
checkForUpdatesItem.target = self
appSubmenu.addItem(checkForUpdatesItem)
}

func applicationDidFinishLaunching(_ notification: Notification) {
// Insert code here to initialize your application
self.server = IMKServer(name: Bundle.main.infoDictionary?["InputMethodConnectionName"] as? String, bundleIdentifier: Bundle.main.bundleIdentifier)
NSLog("tried connection")
self.configureUpdaterIfAvailable()

// Keychainから設定値を非同期で読み込み
Task {
Expand All @@ -138,6 +177,8 @@ class AppDelegate: NSObject, NSApplicationDelegate {
NSApp.mainMenu = NSMenu()
}

self.addApplicationMenuIfNeeded()

// Add an Edit menu
let editMenu = NSMenuItem(title: "Edit", action: nil, keyEquivalent: "")
NSApp.mainMenu?.addItem(editMenu)
Expand Down
6 changes: 6 additions & 0 deletions azooKeyMac/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
<dict>
<key>LSUIElement</key>
<true/>
<key>SUEnableInstallerLauncherService</key>
<true/>
<key>SUFeedURL</key>
<string>$(SPARKLE_FEED_URL)</string>
<key>SUPublicEDKey</key>
<string>$(SPARKLE_PUBLIC_ED_KEY)</string>
<key>ComponentInputModeDict</key>
<dict>
<key>tsVisibleInputModeOrderedArrayKey</key>
Expand Down
2 changes: 2 additions & 0 deletions azooKeyMac/azooKeyMac.entitlements
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
<key>com.apple.security.temporary-exception.mach-lookup.global-name</key>
<array>
<string>dev.ensan.inputmethod.azooKeyMac.ConverterServer</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)-spks</string>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)-spki</string>
</array>
</dict>
</plist>
Loading
Loading