From 1b62a0dc40bceae31e23dca44d2c1166e4be2a7d Mon Sep 17 00:00:00 2001 From: steve benedick Date: Thu, 1 Oct 2020 10:43:48 -0600 Subject: [PATCH 1/5] -fix makefile --- build/xcode/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/xcode/Makefile b/build/xcode/Makefile index 6228b1d0..6101490d 100755 --- a/build/xcode/Makefile +++ b/build/xcode/Makefile @@ -50,6 +50,7 @@ ROOT_DIR = $(shell git rev-parse --show-toplevel) LIB_VERSION = $(shell grep 'private static let version' $(ROOT_DIR)/code/src/ExperiencePlatformInternal.swift | sed 's/.*private static let version.*=.*\"\(.*\)\".*/\1/') # environments +EXTENSION_NAME = AEPExperiencePlatform WORKSPACE_NAME = $(EXTENSION_NAME).xcworkspace PROJECT_FILE = $(EXTENSION_NAME).xcodeproj BUILD_SCHEME = $(EXTENSION_NAME) @@ -244,4 +245,3 @@ clean: -rm -rf $(BIN_DIR)$(LIBRARY_NAME) -rm -rf $(BIN_DIR)$(LIBRARY_NAME_SIM) -rm -rf $(BIN_DIR)$(LIBRARY_NAME_DEVICE) - From f8934318accec34852c382c327f13a839fefb285 Mon Sep 17 00:00:00 2001 From: Steve Benedick Date: Thu, 8 Dec 2022 14:28:42 -0700 Subject: [PATCH 2/5] -add update version script and gh action --- .github/workflows/update_versions.yml | 56 +++++++++++++++++++ Makefile | 3 ++ Script/update-versions.sh | 77 +++++++++++++++++++++++++++ 3 files changed, 136 insertions(+) create mode 100644 .github/workflows/update_versions.yml create mode 100755 Script/update-versions.sh diff --git a/.github/workflows/update_versions.yml b/.github/workflows/update_versions.yml new file mode 100644 index 00000000..74f2eb4e --- /dev/null +++ b/.github/workflows/update_versions.yml @@ -0,0 +1,56 @@ +# 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 UIk +# or API. +on: + workflow_dispatch: + # Inputs the workflow accepts. + inputs: + version: + description: 'New version to use for the extension. Example: 3.0.2' + required: true + + branch: + description: 'Branch to be used when updating versions' + required: true + +# 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/checkout@v3.1.0 + with: + ref: ${{ github.event.inputs.branch }} + + - name: Update AEPEdge + run: (sh ./Script/update-versions.sh -n Edge -v ${{ github.event.inputs.version }}) + + - name: Create Pull Request + # You may pin to the exact commit or the version. + # uses: peter-evans/create-pull-request@2b011faafdcbc9ceb11414d64d0573f37c774b04 + uses: peter-evans/create-pull-request@v4.2.3 + with: + # GITHUB_TOKEN or a `repo` scoped Personal Access Token (PAT) + token: ${{ github.token }} + + # The message to use when committing changes. + commit-message: Updating versions to ${{ github.event.inputs.version }}. + + # The pull request branch name. + branch: version-${{ github.event.inputs.version }}-update + + # Delete the `branch` when closing pull requests, and when undeleted after merging. Recommend `true`. + delete-branch: true + + # The title of the pull request. + title: Updating versions to ${{ github.event.inputs.version }} + + # The body of the pull request. + body: Updating versions to ${{ github.event.inputs.version }} diff --git a/Makefile b/Makefile index 6a121ad6..54c00272 100644 --- a/Makefile +++ b/Makefile @@ -81,3 +81,6 @@ test-SPM-integration: test-podspec: (sh ./Script/test-podspec.sh) + +test-version-update: + (sh ./Script/update-versions.sh -n Edge -v 9.9.9) diff --git a/Script/update-versions.sh b/Script/update-versions.sh new file mode 100755 index 00000000..2321923c --- /dev/null +++ b/Script/update-versions.sh @@ -0,0 +1,77 @@ +#!/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 + +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: 3.0.2\n" + echo -e " -d\t- Dependency(ies) that require updating in the extension's podspec file. \n\t Example: AEPCore 3.7.3 (means add a dependency on AEPCore for version 3.7.3 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 + +# 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 +if [ "$DEPENDENCIES" != "none" ]; then + IFS="," + dependenciesArray=($(echo "$DEPENDENCIES")) + + IFS=" " + for dependency in "${dependenciesArray[@]}"; do + dependencyArray=(${dependency// / }) + dependencyName=${dependencyArray[0]} + dependencyVersion=${dependencyArray[1]} + + 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 + done +fi + +# Replace version in Constants file +CONSTANTS_FILE=$ROOT_DIR"/Sources/"$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 From 25db0934b80c5b09be37aae4661b8d1151403218 Mon Sep 17 00:00:00 2001 From: Steve Benedick Date: Thu, 8 Dec 2022 16:27:12 -0700 Subject: [PATCH 3/5] -add new input to the GHA --- .github/workflows/update_versions.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/update_versions.yml b/.github/workflows/update_versions.yml index 74f2eb4e..0c9a5656 100644 --- a/.github/workflows/update_versions.yml +++ b/.github/workflows/update_versions.yml @@ -16,6 +16,10 @@ on: 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 + # A workflow run is made up of one or more jobs that can run sequentially or in parallel jobs: update-versions: @@ -29,7 +33,12 @@ jobs: with: ref: ${{ github.event.inputs.branch }} - - name: Update AEPEdge + - if: ${{ github.event.inputs.core-dependency != '' }} + name: Update AEPEdge (with core dependency update) + run: (sh ./Script/update-versions.sh -n Edge -v ${{ github.event.inputs.version }} -d "AEPCore ${{ github.event.inputs.core-dependency }}") + + - if: ${{ github.event.inputs.core-dependency == '' }} + name: Update AEPEdge (no core dependency update) run: (sh ./Script/update-versions.sh -n Edge -v ${{ github.event.inputs.version }}) - name: Create Pull Request From 394ff612b00a7b0a91df336e57a12319be21ab3f Mon Sep 17 00:00:00 2001 From: Steve Benedick Date: Mon, 12 Dec 2022 11:29:54 -0700 Subject: [PATCH 4/5] -updates spm file too --- Script/update-versions.sh | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/Script/update-versions.sh b/Script/update-versions.sh index 2321923c..52106a38 100755 --- a/Script/update-versions.sh +++ b/Script/update-versions.sh @@ -9,6 +9,18 @@ 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" +getRepo() { + local extensionName=$1 + local url="repos_$extensionName" + echo "${!url}" +} + help() { echo "" @@ -16,7 +28,7 @@ help() 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: 3.0.2\n" - echo -e " -d\t- Dependency(ies) that require updating in the extension's podspec file. \n\t Example: AEPCore 3.7.3 (means add a dependency on AEPCore for version 3.7.3 or newer)\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 3.7.3\" (update the dependency on AEPCore to version 3.7.3 or newer)\n" exit 1 # Exit script after printing help } @@ -39,8 +51,9 @@ then fi PODSPEC_FILE=$ROOT_DIR"/AEP"$NAME.podspec +SPM_FILE=$ROOT_DIR/Package.swift -# Begin script in case all parameters are correct +# Begin script when all parameters are correct echo "" echo "$LINE" echo "Changing version of AEP$NAME to $NEW_VERSION with the following minimum version dependencies: $DEPENDENCIES" @@ -50,19 +63,25 @@ echo "$LINE" 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 +# 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]} + for dependency in "${dependenciesArray[@]}"; do + dependencyArray=(${dependency// / }) + dependencyName=${dependencyArray[0]} + dependencyVersion=${dependencyArray[1]} - echo "Changing value of 's.dependency' for '$dependencyName' to '>= $dependencyVersion' in '$PODSPEC_FILE'" + 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 done fi From 02856b559667d675d6679bb3d908bd9073e22db9 Mon Sep 17 00:00:00 2001 From: Steve Benedick Date: Mon, 27 Feb 2023 15:09:09 -0700 Subject: [PATCH 5/5] -fix typo and update to newer version of update_versions script --- .github/workflows/update_versions.yml | 30 ++++++--------------------- Script/update-versions.sh | 14 +++++++------ 2 files changed, 14 insertions(+), 30 deletions(-) diff --git a/.github/workflows/update_versions.yml b/.github/workflows/update_versions.yml index 0c9a5656..8efb8706 100644 --- a/.github/workflows/update_versions.yml +++ b/.github/workflows/update_versions.yml @@ -2,14 +2,14 @@ name: Update Versions -# Controls when the action will run. Workflow runs when manually triggered using the UIk +# 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 extension. Example: 3.0.2' + description: 'New version to use for the extension. Example: 1.5.2' required: true branch: @@ -33,33 +33,15 @@ jobs: with: ref: ${{ github.event.inputs.branch }} - - if: ${{ github.event.inputs.core-dependency != '' }} - name: Update AEPEdge (with core dependency update) + - name: Update AEPEdge (with core dependency update) run: (sh ./Script/update-versions.sh -n Edge -v ${{ github.event.inputs.version }} -d "AEPCore ${{ github.event.inputs.core-dependency }}") - - if: ${{ github.event.inputs.core-dependency == '' }} - name: Update AEPEdge (no core dependency update) - run: (sh ./Script/update-versions.sh -n Edge -v ${{ github.event.inputs.version }}) - - name: Create Pull Request - # You may pin to the exact commit or the version. - # uses: peter-evans/create-pull-request@2b011faafdcbc9ceb11414d64d0573f37c774b04 uses: peter-evans/create-pull-request@v4.2.3 with: - # GITHUB_TOKEN or a `repo` scoped Personal Access Token (PAT) token: ${{ github.token }} - - # The message to use when committing changes. - commit-message: Updating versions to ${{ github.event.inputs.version }}. - - # The pull request branch name. + commit-message: Updating version to ${{ github.event.inputs.version }}. branch: version-${{ github.event.inputs.version }}-update - - # Delete the `branch` when closing pull requests, and when undeleted after merging. Recommend `true`. delete-branch: true - - # The title of the pull request. - title: Updating versions to ${{ github.event.inputs.version }} - - # The body of the pull request. - body: Updating versions to ${{ github.event.inputs.version }} + title: Updating version to ${{ github.event.inputs.version }} + body: Updating version to ${{ github.event.inputs.version }} diff --git a/Script/update-versions.sh b/Script/update-versions.sh index 52106a38..faeeb523 100755 --- a/Script/update-versions.sh +++ b/Script/update-versions.sh @@ -74,13 +74,15 @@ if [ "$DEPENDENCIES" != "none" ]; then dependencyName=${dependencyArray[0]} dependencyVersion=${dependencyArray[1]} - 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 + 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 + 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