Skip to content

Commit

Permalink
Merge pull request #108 from adobe/staging
Browse files Browse the repository at this point in the history
Staging to main for 5.0.1 release
  • Loading branch information
sbenedicadb authored May 21, 2024
2 parents c57c710 + 8d705f2 commit 5384183
Show file tree
Hide file tree
Showing 9 changed files with 204 additions and 30 deletions.
51 changes: 51 additions & 0 deletions .github/workflows/update_versions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# This is a basic workflow that is manually triggered

name: Update Versions

# Controls when the action will run. Workflow runs when manually triggered using the UI
# or API.
on:
workflow_dispatch:
# Inputs the workflow accepts.
inputs:
version:
description: 'New version to use for the Optimize extension. Example: 5.0.2'
required: true

branch:
description: 'Branch to be used when updating versions'
required: true

core-dependency:
description: 'If a version is provided, update AEPCore dependency in podspec and Package.swift'
required: false

edge-dependency:
description: 'If a version is provided, update AEPEdge dependency in podspec and Package.swift'
required: false

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
update-versions:
runs-on: macos-latest

# Steps represent a sequence of tasks that will be executed as part of the job
steps:

- name: Checkout
uses: actions/[email protected]
with:
ref: ${{ github.event.inputs.branch }}

- name: Update AEPOptimize
run: (sh ./scripts/update-versions.sh -n Optimize -v ${{ github.event.inputs.version }} -d "AEPCore ${{ github.event.inputs.core-dependency }}, AEPEdge ${{ github.event.inputs.edge-dependency }}")

- name: Create Pull Request
uses: peter-evans/[email protected]
with:
token: ${{ github.token }}
commit-message: Updating version to ${{ github.event.inputs.version }}.
branch: version-${{ github.event.inputs.version }}-update
delete-branch: true
title: Updating version to ${{ github.event.inputs.version }}
body: Updating version to ${{ github.event.inputs.version }}
2 changes: 1 addition & 1 deletion AEPOptimize.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = "AEPOptimize"
s.version = "5.0.0"
s.version = "5.0.1"
s.summary = "Experience Platform Optimize extension for Adobe Experience Platform Mobile SDK. Written and maintained by Adobe."
s.description = <<-DESC
The Experience Platform Optimize extension provides APIs to enable real-time personalization workflows in the Adobe Experience Platform SDKs using Adobe Target or Adobe Journey Optimizer Offer Decisioning.
Expand Down
4 changes: 2 additions & 2 deletions AEPOptimize.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1652,7 +1652,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 5.0.0;
MARKETING_VERSION = 5.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.AEPOptimize;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down Expand Up @@ -1681,7 +1681,7 @@
"@executable_path/Frameworks",
"@loader_path/Frameworks",
);
MARKETING_VERSION = 5.0.0;
MARKETING_VERSION = 5.0.1;
PRODUCT_BUNDLE_IDENTIFIER = com.adobe.aep.AEPOptimize;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
shouldUseLaunchSchemeArgsEnv = "YES"
enableThreadSanitizer = "YES">
<Testables>
<TestableReference
skipped = "NO">
Expand Down
28 changes: 16 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,13 @@ PROJECT_NAME = $(EXTENSION_NAME)
TARGET_NAME_XCFRAMEWORK = $(EXTENSION_NAME).xcframework
SCHEME_NAME_XCFRAMEWORK = AEPOptimize

CURR_DIR := ${CURDIR}
SIMULATOR_ARCHIVE_PATH = $(CURR_DIR)/build/ios_simulator.xcarchive/Products/Library/Frameworks/
SIMULATOR_ARCHIVE_DSYM_PATH = $(CURR_DIR)/build/ios_simulator.xcarchive/dSYMs/
IOS_ARCHIVE_PATH = $(CURR_DIR)/build/ios.xcarchive/Products/Library/Frameworks/
IOS_ARCHIVE_DSYM_PATH = $(CURR_DIR)/build/ios.xcarchive/dSYMs/
CURRENT_DIRECTORY := ${CURDIR}
SIMULATOR_ARCHIVE_PATH = $(CURRENT_DIRECTORY)/build/ios_simulator.xcarchive/Products/Library/Frameworks/
SIMULATOR_ARCHIVE_DSYM_PATH = $(CURRENT_DIRECTORY)/build/ios_simulator.xcarchive/dSYMs/
IOS_ARCHIVE_PATH = $(CURRENT_DIRECTORY)/build/ios.xcarchive/Products/Library/Frameworks/
IOS_ARCHIVE_DSYM_PATH = $(CURRENT_DIRECTORY)/build/ios.xcarchive/dSYMs/
IOS_DESTINATION = 'platform=iOS Simulator,name=iPhone 15'

lint-autocorrect:
./Pods/SwiftLint/swiftlint --fix --format

lint:
./Pods/SwiftLint/swiftlint lint

pod-install:
(pod install --repo-update)

Expand Down Expand Up @@ -71,7 +65,17 @@ install-swiftformat:
check-format:
(swiftformat --lint Sources/$(PROJECT_NAME) --swiftversion 5.1)

format:
swift-format:
(swiftformat Sources/$(PROJECT_NAME) --swiftversion 5.1)

lint:
(./Pods/SwiftLint/swiftlint lint $(PROJECT_NAME)/Sources)

lint-autocorrect:
($(CURRENT_DIRECTORY)/Pods/SwiftLint/swiftlint --fix)

format: lint-autocorrect swift-format

# used to test update-versions.sh script locally
test-versions:
(sh ./scripts/update-versions.sh -n Optimize -v 5.0.1 -d "AEPCore 5.0.0, AEPEdge 5.0.0")
6 changes: 3 additions & 3 deletions Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ PODS:
- AEPCore (5.0.0):
- AEPRulesEngine (< 6.0.0, >= 5.0.0)
- AEPServices (< 6.0.0, >= 5.0.0)
- AEPEdge (5.0.0):
- AEPEdge (5.0.1):
- AEPCore (< 6.0.0, >= 5.0.0)
- AEPEdgeIdentity (< 6.0.0, >= 5.0.0)
- AEPEdgeConsent (5.0.0):
Expand Down Expand Up @@ -53,7 +53,7 @@ SPEC REPOS:
SPEC CHECKSUMS:
AEPAssurance: 7f260ded4df38a70a06efebade8c33a3e3221984
AEPCore: f1c3e9238bb12e7e1103f4407c341ebc65aeab5b
AEPEdge: 6bc7c3f6573fdf0a12fb3ddfd32420112a89c80b
AEPEdge: 0873041dfb29f3126260f2dc16d548a1fefbe0c4
AEPEdgeConsent: d7db1d19eb4c1e2146360ed3c8df315f671b26d5
AEPEdgeIdentity: 3161ff33434586962946912d6b8e9e8fca1c4d23
AEPIdentity: a65c1eba43a06f01b0dab191b27a53a81adada57
Expand All @@ -65,4 +65,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: 6c01a16ccaa4ad210fcb2a0841c0df8d98fd1f78

COCOAPODS: 1.14.3
COCOAPODS: 1.15.0
37 changes: 27 additions & 10 deletions Sources/AEPOptimize/Optimize.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,36 @@ public class Optimize: NSObject, Extension {
// and the get propositions request is fulfilled from the latest cached content.
private let eventsQueue = OperationOrderer<Event>("OptimizeEvents")

/// Dispatch queue used to protect against simultaneous access of our containers from multiple threads
private let queue: DispatchQueue = .init(label: "com.adobe.optimize.containers.queue")

/// a dictionary containing the update event IDs (and corresponding requested scopes) for Edge events that haven't yet received an Edge completion response.
private var updateRequestEventIdsInProgress: [String: [DecisionScope]] = [:]
private var _updateRequestEventIdsInProgress: [String: [DecisionScope]] = [:]
private var updateRequestEventIdsInProgress: [String: [DecisionScope]] {
get { queue.sync { self._updateRequestEventIdsInProgress } }
set { queue.async { self._updateRequestEventIdsInProgress = newValue } }
}

/// a dictionary to accumulate propositions returned in various personalization:decisions events for the same Edge personalization request.
private var propositionsInProgress: [DecisionScope: OptimizeProposition] = [:]
private var _propositionsInProgress: [DecisionScope: OptimizeProposition] = [:]
private var propositionsInProgress: [DecisionScope: OptimizeProposition] {
get { queue.sync { self._propositionsInProgress } }
set { queue.async { self._propositionsInProgress = newValue } }
}

/// Dictionary containing decision propositions currently cached in-memory in the SDK.
private var _cachedPropositions: [DecisionScope: OptimizeProposition] = [:]
#if DEBUG
var cachedPropositions: [DecisionScope: OptimizeProposition] {
get { queue.sync { self._cachedPropositions } }
set { queue.async { self._cachedPropositions = newValue } }
}
#else
private(set) var cachedPropositions: [DecisionScope: OptimizeProposition] {
get { queue.sync { self._cachedPropositions } }
set { queue.async { self._cachedPropositions = newValue } }
}
#endif

/// Array containing the schema strings for the proposition items supported by the SDK, sent in the personalization query request.
static let supportedSchemas = [
Expand All @@ -49,16 +74,8 @@ public class Optimize: NSObject, Extension {
OptimizeConstants.JsonValues.SCHEMA_OFFER_TEXT
]

/// Dictionary containing decision propositions currently cached in-memory in the SDK.
#if DEBUG
var cachedPropositions: [DecisionScope: OptimizeProposition]
#else
private(set) var cachedPropositions: [DecisionScope: OptimizeProposition]
#endif

public required init?(runtime: ExtensionRuntime) {
self.runtime = runtime
cachedPropositions = [:]
super.init()
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/AEPOptimize/OptimizeConstants.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
enum OptimizeConstants {
static let EXTENSION_NAME = "com.adobe.optimize"
static let FRIENDLY_NAME = "Optimize"
static let EXTENSION_VERSION = "5.0.0"
static let EXTENSION_VERSION = "5.0.1"
static let LOG_TAG = FRIENDLY_NAME

static let DECISION_SCOPE_NAME = "name"
Expand Down
101 changes: 101 additions & 0 deletions scripts/update-versions.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#!/bin/bash

# make this script executable from terminal:
# chmod 755 update-versions.sh

set -e # Any subsequent(*) commands which fail will cause the shell script to exit immediately

ROOT_DIR=$(git rev-parse --show-toplevel)
LINE="================================================================================"
VERSION_REGEX="[0-9]+\.[0-9]+\.[0-9]+"
DEPENDENCIES=none

# make a "dictionary" to help us find the correct spm repo per dependency (if necessary)
# IMPORTANT - this will be used in a regex search so escape special chars
# usage :
# getRepo AEPCore

declare "repos_AEPCore=https:\/\/github\.com\/adobe\/aepsdk-core-ios\.git"
declare "repos_AEPEdge=https:\/\/github\.com\/adobe\/aepsdk-edge-ios\.git"

getRepo() {
local extensionName=$1
local url="repos_$extensionName"
echo "${!url}"
}

help()
{
echo ""
echo "Usage: $0 -n EXTENSION_NAME -v NEW_VERSION -d \"PODSPEC_DEPENDENCY_1, PODSPEC_DEPENDENCY_2\""
echo ""
echo -e " -n\t- Name of the extension getting a version update. \n\t Example: Edge, Analytics\n"
echo -e " -v\t- New version to use for the extension. \n\t Example: 4.0.2\n"
echo -e " -d (optional)\t- Dependency(ies) that require updating in the extension's podspec and Package.swift file. \n\t Example: -d \"AEPCore 4.0.2\" (update the dependency on AEPCore to version 4.0.2 or newer)\n"
exit 1 # Exit script after printing help
}

while getopts "n:v:d:" opt
do
case "$opt" in
n ) NAME="$OPTARG" ;;
v ) NEW_VERSION="$OPTARG" ;;
d ) DEPENDENCIES="$OPTARG" ;;
? ) help ;; # Print help in case parameter is non-existent
esac
done

# Print help in case parameters are empty
if [ -z "$NAME" ] || [ -z "$NEW_VERSION" ]
then
echo "********** USAGE ERROR **********"
echo "Some or all of the parameters are empty. See usage below:";
help
fi

PODSPEC_FILE=$ROOT_DIR"/AEP"$NAME.podspec
SPM_FILE=$ROOT_DIR/Package.swift

# Begin script in case all parameters are correct
echo ""
echo "$LINE"
echo "Changing version of AEP$NAME to $NEW_VERSION with the following minimum version dependencies: $DEPENDENCIES"
echo "$LINE"

# Replace extension version in podspec
echo "Changing value of 's.version' to '$NEW_VERSION' in '$PODSPEC_FILE'"
sed -i '' -E "/^ *s.version/{s/$VERSION_REGEX/$NEW_VERSION/;}" $PODSPEC_FILE

# Replace dependencies in podspec and Package.swift
if [ "$DEPENDENCIES" != "none" ]; then
IFS=","
dependenciesArray=($(echo "$DEPENDENCIES"))

IFS=" "
for dependency in "${dependenciesArray[@]}"; do
dependencyArray=(${dependency// / })
dependencyName=${dependencyArray[0]}
dependencyVersion=${dependencyArray[1]}

if [ "$dependencyVersion" != "" ]; then
echo "Changing value of 's.dependency' for '$dependencyName' to '>= $dependencyVersion' in '$PODSPEC_FILE'"
sed -i '' -E "/^ *s.dependency +'$dependencyName'/{s/$VERSION_REGEX/$dependencyVersion/;}" $PODSPEC_FILE

spmRepoUrl=$(getRepo $dependencyName)
if [ "$spmRepoUrl" != "" ]; then
echo "Changing value of '.upToNextMajor(from:)' for '$spmRepoUrl' to '$dependencyVersion' in '$SPM_FILE'"
sed -i '' -E "/$spmRepoUrl\", \.upToNextMajor/{s/$VERSION_REGEX/$dependencyVersion/;}" $SPM_FILE
fi
fi
done
fi

# Replace version in Constants file
CONSTANTS_FILE=$ROOT_DIR"/Sources/AEP$NAME/"$NAME"Constants.swift"
echo "Changing value of 'EXTENSION_VERSION' to '$NEW_VERSION' in '$CONSTANTS_FILE'"
sed -i '' -E "/^ +static let EXTENSION_VERSION/{s/$VERSION_REGEX/$NEW_VERSION/;}" $CONSTANTS_FILE

# Replace marketing versions in project.pbxproj
PROJECT_PBX_FILE=$ROOT_DIR"/AEP$NAME.xcodeproj/project.pbxproj"
echo "Changing value of 'MARKETING_VERSION' to '$NEW_VERSION' in '$PROJECT_PBX_FILE'"
sed -i '' -E "/^\t+MARKETING_VERSION = /{s/$VERSION_REGEX/$NEW_VERSION/;}" $PROJECT_PBX_FILE

0 comments on commit 5384183

Please sign in to comment.