Skip to content

Commit 27d359b

Browse files
authored
Enhancement (#25)
1 parent e7935ad commit 27d359b

File tree

7 files changed

+40
-88
lines changed

7 files changed

+40
-88
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ jobs:
3333
uses: stefanzweifel/git-auto-commit-action@v5
3434
with:
3535
branch: ${{ github.event.pull_request.head.ref || github.head_ref || github.ref }}
36-
file_pattern: "*.sh *.yml *.md *.json"
36+
file_pattern: "setup.sh .github/**/*.yml README.md mpvx/**/*.json"
3737
commit_message: "chore: fix linting issues"
3838
commit_user_name: super-linter
3939
commit_user_email: [email protected]

.github/workflows/release.yml

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ jobs:
5454
GCM_SENDER_ID: ${{ secrets.GCM_SENDER_ID }}
5555
run: |
5656
./setup.sh
57+
- name: Restore Build Cache
58+
uses: actions/cache@v3
59+
with:
60+
path: build
61+
key: build-cache-${{ runner.os }}-${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles('**/Package.resolved') }}
62+
restore-keys: |
63+
build-cache-${{ runner.os }}-${{ matrix.os }}-${{ matrix.arch }}-
5764
- name: Archive
5865
run: |
5966
xcodebuild clean archive \
@@ -63,6 +70,11 @@ jobs:
6370
-destination "platform=macOS"
6471
mkdir -p build/Build/Products/Release
6572
cp -R build/mpvx.xcarchive/Products/Applications/mpvx.app build/Build/Products/Release/mpvx.app
73+
- name: Save Build Cache
74+
uses: actions/cache@v3
75+
with:
76+
path: build
77+
key: build-cache-${{ runner.os }}-${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles('**/Package.resolved') }}
6678
- name: Install create-dmg
6779
run: |
6880
brew install create-dmg
@@ -78,24 +90,28 @@ jobs:
7890
--icon "mpvx.app" 200 200 \
7991
./dist/mpvx.dmg \
8092
./build/Build/Products/Release/mpvx.app
81-
- name: Download latest Sparkle CLI
93+
- name: Download Sparkle CLI (version from Package.resolved)
8294
run: |
83-
# wget ${GITHUB_API_URL}/repos/sparkle-project/Sparkle/releases/latest -O sparkle.json
84-
# cat sparkle.json | jq
85-
# DOWNLOAD_URL=`cat sparkle.json | jq -r '.assets[] | select(.name == "Sparkle-for-Swift-Package-Manager.zip").browser_download_url'`
86-
# if [ -z "$DOWNLOAD_URL" ]; then
87-
# echo "Error: Could not find a Sparkle-for-Swift-Package-Manager.zip asset in the latest Sparkle release."
88-
# exit 1
89-
# fi
90-
# Workaround: Use a fixed version of Sparkle CLI for now to fix API rate limit issue
91-
DOWNLOAD_URL="https://github.com/sparkle-project/Sparkle/releases/download/2.6.4/Sparkle-for-Swift-Package-Manager.zip"
95+
# Extract Sparkle version from Package.resolved
96+
SPARKLE_VERSION=$(jq -r '.pins[] | select(.identity == "sparkle") | .state.version' \
97+
mpvx.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved)
98+
if [ -z "$SPARKLE_VERSION" ]; then
99+
echo "Error: Could not determine Sparkle version from Package.resolved."
100+
exit 1
101+
fi
102+
echo "Detected Sparkle version: $SPARKLE_VERSION"
103+
# Construct download URL
104+
DOWNLOAD_URL="https://github.com/sparkle-project/Sparkle/releases/download/${SPARKLE_VERSION}/Sparkle-for-Swift-Package-Manager.zip"
92105
echo "Downloading Sparkle CLI from \`${DOWNLOAD_URL}\`..."
106+
# Download and unzip Sparkle CLI
93107
wget -O /tmp/Sparkle-for-Swift-Package-Manager.zip "${DOWNLOAD_URL}"
94108
echo "Unzipping Sparkle CLI to \`/tmp/sparkle\`..."
95109
unzip /tmp/Sparkle-for-Swift-Package-Manager.zip -d /tmp/sparkle
110+
# Make CLI tools executable
96111
echo "Making CLI tools executable..."
97112
chmod +x /tmp/sparkle/bin/generate_appcast
98113
chmod +x /tmp/sparkle/bin/sign_update
114+
# Copy CLI tools to the workspace
99115
echo "Copying CLI tools to \`${GITHUB_WORKSPACE}\`..."
100116
cp /tmp/sparkle/bin/generate_appcast $GITHUB_WORKSPACE/
101117
cp /tmp/sparkle/bin/sign_update $GITHUB_WORKSPACE/

.github/workflows/test-and-coverage.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,26 @@ jobs:
3333
- name: Setup
3434
run: |
3535
./setup.sh
36+
- name: Restore Build Cache
37+
uses: actions/cache@v3
38+
with:
39+
path: build
40+
key: build-cache-${{ runner.os }}-${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles('**/Package.resolved') }}
41+
restore-keys: |
42+
build-cache-${{ runner.os }}-${{ matrix.os }}-${{ matrix.arch }}-
3643
- name: Run Tests
3744
run: |
38-
xcodebuild clean test \
45+
xcodebuild test \
3946
-scheme mpvx \
4047
-configuration Debug \
4148
-derivedDataPath build \
4249
-destination "platform=macOS,arch=${{ matrix.arch }}" \
4350
-resultBundlePath "artifacts/ResultBundle-${{ matrix.os }}-${{ matrix.arch }}.xcresult"
51+
- name: Save Build Cache
52+
uses: actions/cache@v3
53+
with:
54+
path: build
55+
key: build-cache-${{ runner.os }}-${{ matrix.os }}-${{ matrix.arch }}-${{ hashFiles('**/Package.resolved') }}
4456
- name: Upload Result Bundle
4557
uses: actions/upload-artifact@v4
4658
with:

mpvx/AppDelegate+Handlers.swift

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@ extension AppDelegate {
66
.response: response.rawValue,
77
.urlCount: urls.count
88
])
9-
for url in urls {
10-
AnalyticsLogger.logEvent(.openUrl, parameters: [
11-
.urlPath: url.lastPathComponent.truncatedFilename(to: 100)
12-
])
13-
}
149
if response == .OK {
1510
Task(priority: .userInitiated) {
1611
do {
@@ -91,9 +86,6 @@ extension AppDelegate {
9186
switch result {
9287
case .terminated:
9388
for url in urls {
94-
AnalyticsLogger.logEvent(.recentDocumentAdded, parameters: [
95-
.urlPath: url.lastPathComponent.truncatedFilename(to: 100)
96-
])
9789
NSDocumentController.shared.noteNewRecentDocumentURL(url)
9890
}
9991
}

mpvx/AppDelegate+NSApplicationDelegate.swift

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@ extension AppDelegate: NSApplicationDelegate {
3535
}
3636

3737
func application(_ application: NSApplication, open urls: [URL]) {
38-
for url in urls {
39-
AnalyticsLogger.logEvent(.openUrl, parameters: [
40-
.urlPath: url.lastPathComponent.truncatedFilename(to: 100)
41-
])
42-
}
4338
Task(priority: .userInitiated) {
4439
do {
4540
try await mpvLauncher.launch(with: urls) { result in

mpvx/String+Extension.swift

Lines changed: 0 additions & 19 deletions
This file was deleted.

mpvxTests/StringTruncateTests.swift

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)