Skip to content

Commit

Permalink
Versions fix (#24)
Browse files Browse the repository at this point in the history
* Only compare major version of Premiere

* Open latest version of PP with matching major version

* Use latest MacOs runner image

* Use github run number

* Don't offset build number

* Include project configfuration
  • Loading branch information
richpryce authored Aug 31, 2023
1 parent 52a65fb commit 04a39e2
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 14 deletions.
11 changes: 3 additions & 8 deletions .github/workflows/objective-c-xcode.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@ on:
jobs:
build:
name: Build and export default scheme using xcodebuild command
runs-on: macos-10.15
runs-on: macos-latest

steps:
- name: Checkout
uses: actions/checkout@v2
- name: Generate Build Number
id: buildnumber
uses: einaregilsson/build-number@v3
with:
token: ${{secrets.github_token}}
- name: Set Build Number
run: |
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion Build ${BUILD_NUMBER}" "PlutoHelperAgent/Info.plist"
/usr/libexec/PlistBuddy -c "Set :CFBundleVersion Build $GITHUB_RUN_NUMBER" "PlutoHelperAgent/Info.plist"
- name: Test
run: |
xcodebuild test -project PlutoHelperAgent.xcodeproj -scheme PlutoHelperAgent -destination 'platform=OS X,arch=x86_64'
Expand All @@ -43,7 +38,7 @@ jobs:
uses: actions/[email protected]
with:
# Artifact name
name: PlutoHelperAgent-${{ env.BUILD_NUMBER }}
name: PlutoHelperAgent-${{ github.run_number }}
# A file, directory or wildcard pattern that describes what to upload
path: ./package/
# The desired behavior if no files are found using the provided path.
Expand Down
7 changes: 4 additions & 3 deletions PlutoHelperAgent.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
ONLY_ACTIVE_ARCH = NO;
SDKROOT = macosx;
};
name = Debug;
Expand Down Expand Up @@ -376,6 +376,7 @@
GCC_WARN_UNUSED_VARIABLE = YES;
MACOSX_DEPLOYMENT_TARGET = 10.12;
MTL_ENABLE_DEBUG_INFO = NO;
ONLY_ACTIVE_ARCH = NO;
SDKROOT = macosx;
};
name = Release;
Expand All @@ -389,7 +390,7 @@
INFOPLIST_FILE = PlutoHelperAgent/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 3.1;
MARKETING_VERSION = 3.2.2;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
Expand All @@ -403,7 +404,7 @@
INFOPLIST_FILE = PlutoHelperAgent/Info.plist;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 10.12;
MARKETING_VERSION = 3.1;
MARKETING_VERSION = 3.2.2;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
Expand Down
38 changes: 35 additions & 3 deletions PlutoHelperAgent/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,49 @@ - (void)showError:(NSString *)showError informativeText:(NSString *)informativeT
}

- (void) processVersion:(NSString *)premiereVersion filePath:(NSString *)filePath {
NSLog(@"Starting processVersion with premiereVersion: %@ and filePath: %@", premiereVersion, filePath);

NSDictionary * premiereVersions = [[NSUserDefaults standardUserDefaults] objectForKey:@"Premiere_versions"];
if (premiereVersions[premiereVersion]) {
if (!premiereVersions) {
NSLog(@"Warning: premiereVersions dictionary not found in UserDefaults.");
return;
}
NSLog(@"Fetched premiereVersions from UserDefaults: %@", premiereVersions);

NSArray *allKeys = [premiereVersions allKeys];
NSLog(@"All available versions: %@", allKeys);

NSArray *versionComponents = [premiereVersion componentsSeparatedByString:@"."];
if ([versionComponents count] < 1) {
NSLog(@"Error: Invalid premiereVersion format");
return;
}

NSString *majorVersion = versionComponents[0];
NSLog(@"Extracted major version: %@", majorVersion);

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"SELF BEGINSWITH %@", majorVersion];
NSArray *filteredKeys = [allKeys filteredArrayUsingPredicate:predicate];
NSLog(@"Filtered versions with the same major version: %@", filteredKeys);

if ([filteredKeys count] > 0) {
NSString *latestVersion = [HelperFunctions getLatestVersion:filteredKeys];
NSLog(@"Latest available version with the same major version: %@", latestVersion);

NSLog(@"Launched app with version: %@", premiereVersions[latestVersion]);
NSTask *openTask = [[NSTask alloc] init];
[openTask setLaunchPath:@"/usr/bin/open"];
[openTask setCurrentDirectoryPath:@"/"];
[openTask setArguments:@[ @"-a", premiereVersions[premiereVersion], filePath ]];
[openTask setArguments:@[ @"-a", premiereVersions[latestVersion], filePath ]];
[openTask launch];
} else {
NSString *requiredVersion = [HelperFunctions getLatestVersion:[premiereVersions allKeys]];
NSString *requiredVersion = [HelperFunctions getLatestVersion:allKeys];
NSLog(@"No matching versions found. Falling back to latest version: %@", requiredVersion);

NSString *plutoURL = [NSString stringWithFormat:@"%@pluto-core/file/changePremiereVersion?project=%@&requiredVersion=%@", [[NSUserDefaults standardUserDefaults] stringForKey:@"pluto_url"], filePath, requiredVersion];
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:plutoURL]];

NSLog(@"Opened URL for version change: %@", plutoURL);
}
}

Expand Down

0 comments on commit 04a39e2

Please sign in to comment.