diff --git a/.github/workflows/maven-sdk-update.yml b/.github/workflows/maven-sdk-update.yml new file mode 100644 index 000000000..3ff9f1b9e --- /dev/null +++ b/.github/workflows/maven-sdk-update.yml @@ -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 \ No newline at end of file diff --git a/src/main/archetype/.gitignore b/src/main/archetype/.gitignore index b86f696dc..ee2fdc1a5 100644 --- a/src/main/archetype/.gitignore +++ b/src/main/archetype/.gitignore @@ -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 diff --git a/src/main/archetype/dispatcher.cloud/test/dummy_sdk/bin/docker_run.sh b/src/main/archetype/dispatcher.cloud/test/dummy_sdk/bin/docker_run.sh new file mode 100755 index 000000000..b33a62ec7 --- /dev/null +++ b/src/main/archetype/dispatcher.cloud/test/dummy_sdk/bin/docker_run.sh @@ -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 diff --git a/src/main/archetype/dispatcher.cloud/test/dummy_sdk/bin/update_maven.sh b/src/main/archetype/dispatcher.cloud/test/dummy_sdk/bin/update_maven.sh new file mode 100755 index 000000000..921f2091c --- /dev/null +++ b/src/main/archetype/dispatcher.cloud/test/dummy_sdk/bin/update_maven.sh @@ -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 diff --git a/src/main/archetype/dispatcher.cloud/test/test_dispatcher_sdk_update.sh b/src/main/archetype/dispatcher.cloud/test/test_dispatcher_sdk_update.sh new file mode 100755 index 000000000..b172c5ab2 --- /dev/null +++ b/src/main/archetype/dispatcher.cloud/test/test_dispatcher_sdk_update.sh @@ -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" diff --git a/src/main/archetype/dispatcher.cloud/update_sdk.sh b/src/main/archetype/dispatcher.cloud/update_sdk.sh new file mode 100755 index 000000000..f42c7944f --- /dev/null +++ b/src/main/archetype/dispatcher.cloud/update_sdk.sh @@ -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 [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" diff --git a/src/main/resources/META-INF/archetype-post-generate.groovy b/src/main/resources/META-INF/archetype-post-generate.groovy index 81c95e724..1aea3493b 100644 --- a/src/main/resources/META-INF/archetype-post-generate.groovy +++ b/src/main/resources/META-INF/archetype-post-generate.groovy @@ -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') } diff --git a/src/main/resources/META-INF/maven/archetype-metadata.xml b/src/main/resources/META-INF/maven/archetype-metadata.xml index d819d946f..375116342 100644 --- a/src/main/resources/META-INF/maven/archetype-metadata.xml +++ b/src/main/resources/META-INF/maven/archetype-metadata.xml @@ -272,6 +272,7 @@ **/*.any **/*.farm assembly.xml + update_sdk.sh