Skip to content
61 changes: 61 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Release

on:
push:
tags:
- 'v*.*.*'

permissions:
contents: write

concurrency:
group: release-${{ github.ref }}
cancel-in-progress: false

jobs:
release:
runs-on: macos-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v7
- name: Read version from tag
env:
RELEASE_TAG: ${{ github.ref_name }}
run: |
python3 - <<'PY'
import os, re
tag = os.environ['RELEASE_TAG']
match = re.fullmatch(r'v((?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*))(?:\+([1-9][0-9]*))?', tag)
if not match:
raise SystemExit('Use a stable vMAJOR.MINOR.PATCH tag, optionally +BUILD (positive integer)')
with open(os.environ['GITHUB_ENV'], 'a') as output:
output.write(f'APP_VERSION={match[1]}\nAPP_BUILD={match[2] or "1"}\n')
PY
- name: Test
run: >-
xcodebuild test -project AllServerForMac.xcodeproj -scheme AllServerForMac
-destination 'platform=macOS' -only-testing:AllServerForMacTests
-derivedDataPath "$RUNNER_TEMP/AllServerForMacDerivedData"
CODE_SIGNING_ALLOWED=NO
- name: Build universal release
run: >-
xcodebuild build -project AllServerForMac.xcodeproj -scheme AllServerForMac
-configuration Release -destination 'generic/platform=macOS'
-derivedDataPath "$RUNNER_TEMP/AllServerForMacRelease"
ARCHS='arm64 x86_64' ONLY_ACTIVE_ARCH=NO
MARKETING_VERSION="$APP_VERSION" CURRENT_PROJECT_VERSION="$APP_BUILD"
CODE_SIGNING_ALLOWED=NO
- name: Package app
run: |
codesign --force --deep --sign - "$RUNNER_TEMP/AllServerForMacRelease/Build/Products/Release/AllServerForMac.app"
ditto -c -k --sequesterRsrc --keepParent "$RUNNER_TEMP/AllServerForMacRelease/Build/Products/Release/AllServerForMac.app" AllServerForMac.app.zip
- name: Publish release
env:
GH_TOKEN: ${{ github.token }}
RELEASE_TAG: ${{ github.ref_name }}
run: |
if ! gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
gh release create "$RELEASE_TAG" --verify-tag --generate-notes --draft
fi
gh release upload "$RELEASE_TAG" AllServerForMac.app.zip --clobber
gh release edit "$RELEASE_TAG" --draft=false --latest
10 changes: 10 additions & 0 deletions AllServerForMac/App/AllServerForMacApp.swift
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,13 @@ extension FocusedValues {

struct AppMenuCommands: Commands {
@FocusedValue(\.appMenuContext) private var context
@ObservedObject private var updater = AppUpdater.shared

var body: some Commands {
CommandGroup(after: .appInfo) {
Button("アップデートを確認…") { updater.check(manual: true) }
}

CommandGroup(after: .toolbar) {
Button("全画面表示/解除") {
toggleFullScreen()
Expand Down Expand Up @@ -203,6 +208,11 @@ struct AppMenuCommands: Commands {
/// そこへ AppKit のビューを割り込ませると矢印キーでの項目移動が壊れる。
/// チェーンの終点であるアプリのデリゲートで受ければ、フォーカスに一切触らずに済む。
final class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(_ notification: Notification) {
guard NSClassFromString("XCTestCase") == nil, AppUpdater.shared.automaticallyChecks else { return }
AppUpdater.shared.check(manual: false)
}

override func acceptsPreviewPanelControl(_ panel: QLPreviewPanel!) -> Bool {
true
}
Expand Down
3 changes: 3 additions & 0 deletions AllServerForMac/App/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,9 @@ struct ContentView: View {
}
}
.toolbar {
ToolbarItem(placement: .primaryAction) {
AppUpdateAvailabilityButton()
}
ToolbarItemGroup(placement: .navigation) {
Button {
withAnimation(.easeInOut(duration: 0.2)) { isSidebarVisible.toggle() }
Expand Down
4 changes: 4 additions & 0 deletions AllServerForMac/Features/Settings/Views/PreferencesView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ struct PreferencesView: View {
case server = "保護"
case performance = "性能"
case export = "書き出し"
case updates = "更新"
case shortcuts = "ショートカット"
var id: String { rawValue }
}
Expand Down Expand Up @@ -200,6 +201,9 @@ struct PreferencesView: View {
}
.id(SettingsSection.export)

UpdateSettingsSection()
.id(SettingsSection.updates)

MediaShortcutSettingsSection()
.id(SettingsSection.shortcuts)
}
Expand Down
103 changes: 103 additions & 0 deletions AllServerForMac/Features/Updates/AppUpdateView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
import SwiftUI

struct AppUpdateView: View {
@ObservedObject var updater: AppUpdater

var body: some View {
VStack(alignment: .leading, spacing: 16) {
Text("ソフトウェアアップデート").font(.title2.bold())
Text("現在のバージョン: \(updater.currentVersion)(ビルド \(updater.currentBuild))")
.foregroundStyle(.secondary)
switch updater.state {
case .idle:
Text("最新バージョンを確認できます。")
Button("アップデートを確認") { updater.check(manual: true) }
case .checking:
ProgressView("アップデートを確認中…")
case .available(let release):
Text("\(release.tag_name) に更新できます。全ての処理が終わってからアプリを終了し、ダウンロードしたアプリに差し替えてください。")
ScrollView {
Text(release.body.flatMap { $0.isEmpty ? nil : $0 } ?? "リリースノートはありません。")
.frame(maxWidth: .infinity, alignment: .leading)
.textSelection(.enabled)
}.frame(height: 180)
HStack {
if release.downloadURL != nil {
Button("更新をダウンロード") { updater.download(release) }
.keyboardShortcut(.defaultAction)
}
Button("リリースページを開く") { updater.openReleases() }
}
HStack {
Button("後で") { updater.remindLater() }
Button("このバージョンをスキップ") { updater.skip(release) }
}
Text("後で更新する場合は、このウィンドウを閉じてください。")
.font(.caption).foregroundStyle(.secondary)
case .upToDate:
Text("現在のバージョンは最新です。")
case .noRelease:
Text("公開されたリリースはまだありません。")
case .downloading:
if let progress = updater.progress {
ProgressView(value: progress) { Text("ダウンロード中…") }
} else {
ProgressView("ダウンロード中…")
}
Button("キャンセル") { updater.cancelDownload() }
case .downloaded(let url):
Text("ダウンロードしました: \(url.lastPathComponent)")
Text("サーバーを停止し、インポート・解析・書き出しの完了を確認してから通常の終了操作を行ってください。ZIPを展開し、現在のアプリを差し替えて起動すると更新が完了します。ライブラリの保存場所は変わりません。")
case .failed(let message):
Text(message).foregroundStyle(.red)
HStack {
Button("再試行") { updater.check(manual: true) }
Button("リリースページを開く") { updater.openReleases() }
}
}
}
.padding(24)
.frame(width: 620, alignment: .leading)
.frame(minHeight: 200)
}
}

struct UpdateSettingsSection: View {
@ObservedObject private var updater = AppUpdater.shared
var body: some View {
Section("アップデート") {
LabeledContent("現在のバージョン", value: "\(updater.currentVersion)(ビルド \(updater.currentBuild))")
Toggle("起動時に自動でアップデートを確認", isOn: $updater.automaticallyChecks)
LabeledContent("最終確認") {
if let date = updater.lastCheck {
Text(date, format: .dateTime.year().month().day().hour().minute())
} else {
Text("未確認")
}
}
AppUpdateAvailabilityButton()
Button(updater.isBusy ? "アップデートの状況を表示" : "今すぐアップデートを確認") {
updater.check(manual: true)
}
}
}
}

/// Observes update availability independently of the library and playback views.
struct AppUpdateAvailabilityButton: View {
@ObservedObject private var updater = AppUpdater.shared

var body: some View {
if case .available(let release) = updater.state {
Button {
updater.showWindow()
} label: {
Label("アップデート可能", systemImage: "arrow.down.circle.fill")
}
.labelStyle(.titleAndIcon)
.tint(NeomorphicTheme.accent)
.help("新しいバージョン \(release.tag_name) の詳細を表示")
.accessibilityIdentifier("updateAvailableButton")
}
}
}
Loading
Loading