-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #108 from adobe/staging
Staging to main for 5.0.1 release
- Loading branch information
Showing
9 changed files
with
204 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |