-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
add update version script and gh action #298
Merged
Merged
Changes from 7 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
1b62a0d
-fix makefile
sbenedicadb 4108b4c
-merge
sbenedicadb f893431
-add update version script and gh action
sbenedicadb 958619d
Merge branch 'main' of github.com:sbenedicadb/aepsdk-edge-ios
sbenedicadb 25db093
-add new input to the GHA
sbenedicadb 394ff61
-updates spm file too
sbenedicadb 02856b5
-fix typo and update to newer version of update_versions script
sbenedicadb 7a955c6
Merge branch 'main' into main
emdobrin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,47 @@ | ||
# 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 extension. Example: 1.5.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 | ||
|
||
# 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 (with core dependency update) | ||
run: (sh ./Script/update-versions.sh -n Edge -v ${{ github.event.inputs.version }} -d "AEPCore ${{ github.event.inputs.core-dependency }}") | ||
|
||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@v4.2.3 | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
#!/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" | ||
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: 3.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 3.7.3\" (update the dependency on AEPCore to 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you might want to exit early for missing required params when running this in a non-interactive mode like the gh action |
||
fi | ||
|
||
PODSPEC_FILE=$ROOT_DIR"/AEP"$NAME.podspec | ||
SPM_FILE=$ROOT_DIR/Package.swift | ||
|
||
# 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" | ||
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/"$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 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there a way to include a branch picker here instead of text input?