Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an update script that helps to update the dispatcher configuratio… #966

Merged
merged 3 commits into from
Aug 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions .github/workflows/maven-sdk-update.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Copyright 2022 Adobe Systems Incorporated
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

name: Test dispatcher SDK update

# Only run on a push to develop branch or manually
on:
push:
branches: [ master, develop ]
pull_request:
branches: [ master, develop ]

jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest ]
java: [11]

outputs:
commit: ${{ steps.getCommit.outputs.commit }}
steps:
# Checkout this project into a sub folder
- uses: actions/checkout@v2
with:
path: archetype
# Set up environment with Java and Maven
- name: Setup JDK
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}
# Set up dependency cache
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('archetype/**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
# Install archetype snapshot and store version in a variable
- name: Install archetype snapshot and store version in a variable
run: |
cd archetype
mvn clean install -Darchetype.test.skip
echo "ARCHETYPE_VERSION=$(mvn -q -Dexec.executable=echo -Dexec.args='${project.version}' --non-recursive exec:exec)" >> $GITHUB_ENV
echo "ARCHETYPE_COMMIT=$(git rev-parse HEAD)" >> $GITHUB_ENV
cd ..
- name: Set commit in output variable
id: getCommit
run: |
echo "Commit: ${ARCHETYPE_COMMIT}"
echo ::set-output name=commit::${ARCHETYPE_COMMIT}
# Create new project
- name: Create new project with the archetype
run: |
mvn -B archetype:generate \
-D archetypeGroupId=com.adobe.aem \
-D archetypeArtifactId=aem-project-archetype \
-D archetypeVersion=${ARCHETYPE_VERSION} \
-D appTitle="Sites 30 Demo" \
-D appId="sitesdemo" \
-D groupId="com.sites30demo" \
-D includeExamples="y" \
-D includeFormsenrollment="y"
# Set global git configuration
- name: Test SDK update
run: |
archetype/src/main/archetype/dispatcher.cloud/test/test_dispatcher_sdk_update.sh sitesdemo archetype/src/main/archetype/dispatcher.cloud/test/dummy_sdk
3 changes: 3 additions & 0 deletions src/main/archetype/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ local.properties
# External tool builders
.externalToolBuilders/

# Escape dummy_sdk bin folder
!dispatcher.cloud/test/dummy_sdk/bin

# Locally stored "Eclipse launch configurations"
*.launch

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/sh

# Copyright 2022 Adobe Systems Incorporated
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

version=2.0.110
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

# Copyright 2022 Adobe Systems Incorporated
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


if [ -n "$1" ]; then
echo "Updated SDK!"
else
echo "Failed to update SDK!"
exit 1
fi
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# Copyright 2022 Adobe Systems Incorporated
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

siteDir="$1"
sdkDir="$2"
dispatcherDir="$siteDir/dispatcher"

"$dispatcherDir/update_sdk.sh" "$sdkDir"
60 changes: 60 additions & 0 deletions src/main/archetype/dispatcher.cloud/update_sdk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/bin/bash

# Copyright 2022 Adobe Systems Incorporated
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

function usage() {
echo "Usage: ./update_sdk.sh <SDK path> [dispatcher config directory]"
echo "Example 1: ./update_sdk.sh /opt/dispatcher-sdks/dispatcher-sdk-2.0.116"
echo "Example 2: ./update_sdk.sh /opt/dispatcher-sdks/dispatcher-sdk-2.0.116 src"
}

if [[ -z "$1" ]]; then
echo "You have to specify a path to an SDK as a parameter!"
usage
exit -1
fi

sdkPath="$1"

if [[ ! -e "${sdkPath}/bin/docker_run.sh" ]]; then
echo "Cannot find docker_run.sh file in '${sdkPath}/bin/docker_run.sh'."
usage
exit -1
fi

dispatcherVersion=$(cat ${sdkPath}/bin/docker_run.sh | grep version= | cut -f2 -d '=')

if [[ -z "$sdkPath" ]]; then
echo "Cannot evaluate SDK. Is it a valid path to a dispatcher SDK?"
usage
exit -1
fi

echo "Attempting to upgrade to dispatcher SDK version $dispatcherVersion..."

if [[ ! -e "${sdkPath}/bin/update_maven.sh" ]]; then
echo "The dispatcher SDK version that you have chosen does not yet support updates."
exit -1
fi

if [[ -z "$2" ]]; then
scriptDir=$(dirname "$0")
configPath=$scriptDir/src
else
configPath="$2"
fi


$sdkPath/bin/update_maven.sh "$configPath"
2 changes: 2 additions & 0 deletions src/main/resources/META-INF/archetype-post-generate.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ if ( includeDispatcherConfig == "n"){
def source;
if (aemVersion == 'cloud') {
source = new File(rootDir.getPath(),'dispatcher.cloud')
def updateFile = new File("$source/update_sdk.sh");
updateFile.setExecutable(true, false);
} else {
source = new File(rootDir.getPath(), 'dispatcher.ams')
}
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/META-INF/maven/archetype-metadata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@
<include>**/*.any</include>
<include>**/*.farm</include>
<include>assembly.xml</include>
<include>update_sdk.sh</include>
</includes>
</fileSet>
<fileSet filtered="false" packaged="false" encoding="UTF-8">
Expand Down