From 714890a65b04960b6630050bdeaf61287f7a26e7 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Mon, 11 Jul 2016 16:25:45 +0100 Subject: [PATCH 01/13] Update for 1.1.3.RELEASE --- docs/pom.xml | 2 +- pom.xml | 8 ++++---- spring-cloud-cli-integration-tests/pom.xml | 4 ++-- spring-cloud-cli/pom.xml | 4 ++-- .../cli/compiler/SpringCloudBomAstTransformation.java | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/pom.xml b/docs/pom.xml index 7fc9069..d4789d1 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -6,7 +6,7 @@ org.springframework.cloud spring-cloud-cli-parent - 1.1.3.BUILD-SNAPSHOT + 1.1.3.RELEASE pom Spring Cloud Cli Docs diff --git a/pom.xml b/pom.xml index dd36198..a35c8bb 100644 --- a/pom.xml +++ b/pom.xml @@ -3,11 +3,11 @@ 4.0.0 org.springframework.cloud spring-cloud-cli-parent - 1.1.3.BUILD-SNAPSHOT + 1.1.3.RELEASE org.springframework.cloud spring-cloud-build - 1.1.2.BUILD-SNAPSHOT + 1.1.1.RELEASE pom @@ -95,14 +95,14 @@ org.springframework.cloud spring-cloud-config - 1.1.3.BUILD-SNAPSHOT + 1.1.2.RELEASE pom import org.springframework.cloud spring-cloud-netflix - 1.1.4.BUILD-SNAPSHOT + 1.1.4.RELEASE pom import diff --git a/spring-cloud-cli-integration-tests/pom.xml b/spring-cloud-cli-integration-tests/pom.xml index 4a25eef..e1607f0 100644 --- a/spring-cloud-cli-integration-tests/pom.xml +++ b/spring-cloud-cli-integration-tests/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-cli-integration-tests - 1.1.3.BUILD-SNAPSHOT + 1.1.3.RELEASE jar spring-cloud-cli-integration-tests @@ -14,7 +14,7 @@ org.springframework.cloud spring-cloud-cli-parent - 1.1.3.BUILD-SNAPSHOT + 1.1.3.RELEASE diff --git a/spring-cloud-cli/pom.xml b/spring-cloud-cli/pom.xml index 9c0dbc8..731cab9 100644 --- a/spring-cloud-cli/pom.xml +++ b/spring-cloud-cli/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-cli - 1.1.3.BUILD-SNAPSHOT + 1.1.3.RELEASE jar spring-cloud-cli @@ -14,7 +14,7 @@ org.springframework.cloud spring-cloud-cli-parent - 1.1.3.BUILD-SNAPSHOT + 1.1.3.RELEASE diff --git a/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java b/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java index 50c9f12..1d3be9a 100644 --- a/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java +++ b/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java @@ -28,7 +28,7 @@ import org.springframework.boot.cli.compiler.GenericBomAstTransformation; @GroovyASTTransformation(phase = CompilePhase.CONVERSION) public class SpringCloudBomAstTransformation extends GenericBomAstTransformation { - private static final String SPRING_CLOUD_VERSION = "Brixton.BUILD-SNAPSHOT"; + private static final String SPRING_CLOUD_VERSION = "Brixton.SR3"; @Override protected String getBomModule() { From 09cea7fd7273e2f0b805e4bd6730665d58b25751 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Mon, 11 Jul 2016 16:28:41 +0100 Subject: [PATCH 02/13] Revert to snapshots --- docs/pom.xml | 2 +- pom.xml | 8 ++++---- spring-cloud-cli-integration-tests/pom.xml | 4 ++-- spring-cloud-cli/pom.xml | 4 ++-- .../cli/compiler/SpringCloudBomAstTransformation.java | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/pom.xml b/docs/pom.xml index d4789d1..43c7c60 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -6,7 +6,7 @@ org.springframework.cloud spring-cloud-cli-parent - 1.1.3.RELEASE + 1.1.4.BUILD-SNAPSHOT pom Spring Cloud Cli Docs diff --git a/pom.xml b/pom.xml index a35c8bb..840a1fe 100644 --- a/pom.xml +++ b/pom.xml @@ -3,11 +3,11 @@ 4.0.0 org.springframework.cloud spring-cloud-cli-parent - 1.1.3.RELEASE + 1.1.4.BUILD-SNAPSHOT org.springframework.cloud spring-cloud-build - 1.1.1.RELEASE + 1.1.2.BUILD-SNAPSHOT pom @@ -95,14 +95,14 @@ org.springframework.cloud spring-cloud-config - 1.1.2.RELEASE + 1.1.3.BUILD-SNAPSHOT pom import org.springframework.cloud spring-cloud-netflix - 1.1.4.RELEASE + 1.1.5.BUILD-SNAPSHOT pom import diff --git a/spring-cloud-cli-integration-tests/pom.xml b/spring-cloud-cli-integration-tests/pom.xml index e1607f0..28d42aa 100644 --- a/spring-cloud-cli-integration-tests/pom.xml +++ b/spring-cloud-cli-integration-tests/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-cli-integration-tests - 1.1.3.RELEASE + 1.1.4.BUILD-SNAPSHOT jar spring-cloud-cli-integration-tests @@ -14,7 +14,7 @@ org.springframework.cloud spring-cloud-cli-parent - 1.1.3.RELEASE + 1.1.4.BUILD-SNAPSHOT diff --git a/spring-cloud-cli/pom.xml b/spring-cloud-cli/pom.xml index 731cab9..00671c2 100644 --- a/spring-cloud-cli/pom.xml +++ b/spring-cloud-cli/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-cli - 1.1.3.RELEASE + 1.1.4.BUILD-SNAPSHOT jar spring-cloud-cli @@ -14,7 +14,7 @@ org.springframework.cloud spring-cloud-cli-parent - 1.1.3.RELEASE + 1.1.4.BUILD-SNAPSHOT diff --git a/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java b/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java index 1d3be9a..50c9f12 100644 --- a/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java +++ b/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java @@ -28,7 +28,7 @@ import org.springframework.boot.cli.compiler.GenericBomAstTransformation; @GroovyASTTransformation(phase = CompilePhase.CONVERSION) public class SpringCloudBomAstTransformation extends GenericBomAstTransformation { - private static final String SPRING_CLOUD_VERSION = "Brixton.SR3"; + private static final String SPRING_CLOUD_VERSION = "Brixton.BUILD-SNAPSHOT"; @Override protected String getBomModule() { From 083a7c2c2502f66b038df27aa0c11846fab2499d Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Tue, 26 Jul 2016 11:35:39 +0100 Subject: [PATCH 03/13] Update to Brixton.SR4 (1.1.4.RELEASE) --- docs/pom.xml | 2 +- pom.xml | 8 ++++---- spring-cloud-cli-integration-tests/pom.xml | 4 ++-- spring-cloud-cli/pom.xml | 4 ++-- .../cli/compiler/SpringCloudBomAstTransformation.java | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/pom.xml b/docs/pom.xml index 43c7c60..089ce89 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -6,7 +6,7 @@ org.springframework.cloud spring-cloud-cli-parent - 1.1.4.BUILD-SNAPSHOT + 1.1.4.RELEASE pom Spring Cloud Cli Docs diff --git a/pom.xml b/pom.xml index 840a1fe..5ceb78d 100644 --- a/pom.xml +++ b/pom.xml @@ -3,11 +3,11 @@ 4.0.0 org.springframework.cloud spring-cloud-cli-parent - 1.1.4.BUILD-SNAPSHOT + 1.1.4.RELEASE org.springframework.cloud spring-cloud-build - 1.1.2.BUILD-SNAPSHOT + 1.1.1.RELEASE pom @@ -95,14 +95,14 @@ org.springframework.cloud spring-cloud-config - 1.1.3.BUILD-SNAPSHOT + 1.1.2.RELEASE pom import org.springframework.cloud spring-cloud-netflix - 1.1.5.BUILD-SNAPSHOT + 1.1.5.RELEASE pom import diff --git a/spring-cloud-cli-integration-tests/pom.xml b/spring-cloud-cli-integration-tests/pom.xml index 28d42aa..ab577b1 100644 --- a/spring-cloud-cli-integration-tests/pom.xml +++ b/spring-cloud-cli-integration-tests/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-cli-integration-tests - 1.1.4.BUILD-SNAPSHOT + 1.1.4.RELEASE jar spring-cloud-cli-integration-tests @@ -14,7 +14,7 @@ org.springframework.cloud spring-cloud-cli-parent - 1.1.4.BUILD-SNAPSHOT + 1.1.4.RELEASE diff --git a/spring-cloud-cli/pom.xml b/spring-cloud-cli/pom.xml index 00671c2..aafe3d7 100644 --- a/spring-cloud-cli/pom.xml +++ b/spring-cloud-cli/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-cli - 1.1.4.BUILD-SNAPSHOT + 1.1.4.RELEASE jar spring-cloud-cli @@ -14,7 +14,7 @@ org.springframework.cloud spring-cloud-cli-parent - 1.1.4.BUILD-SNAPSHOT + 1.1.4.RELEASE diff --git a/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java b/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java index 50c9f12..cf62a43 100644 --- a/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java +++ b/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java @@ -28,7 +28,7 @@ import org.springframework.boot.cli.compiler.GenericBomAstTransformation; @GroovyASTTransformation(phase = CompilePhase.CONVERSION) public class SpringCloudBomAstTransformation extends GenericBomAstTransformation { - private static final String SPRING_CLOUD_VERSION = "Brixton.BUILD-SNAPSHOT"; + private static final String SPRING_CLOUD_VERSION = "Brixton.SR4"; @Override protected String getBomModule() { From 093e0eb77a5591bfa2a8f779d5458d60d2672ac2 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Tue, 26 Jul 2016 11:39:10 +0100 Subject: [PATCH 04/13] Revert to snapshots --- docs/pom.xml | 2 +- pom.xml | 6 +++--- spring-cloud-cli-integration-tests/pom.xml | 4 ++-- spring-cloud-cli/pom.xml | 4 ++-- .../cloud/cli/compiler/SpringCloudBomAstTransformation.java | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/pom.xml b/docs/pom.xml index 089ce89..0672f15 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -6,7 +6,7 @@ org.springframework.cloud spring-cloud-cli-parent - 1.1.4.RELEASE + 1.1.5.BUILD-SNAPSHOT pom Spring Cloud Cli Docs diff --git a/pom.xml b/pom.xml index 5ceb78d..32fd141 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.springframework.cloud spring-cloud-cli-parent - 1.1.4.RELEASE + 1.1.5.BUILD-SNAPSHOT org.springframework.cloud spring-cloud-build @@ -95,14 +95,14 @@ org.springframework.cloud spring-cloud-config - 1.1.2.RELEASE + 1.1.3.BUILD-SNAPSHOT pom import org.springframework.cloud spring-cloud-netflix - 1.1.5.RELEASE + 1.1.6.BUILD-SNAPSHOT pom import diff --git a/spring-cloud-cli-integration-tests/pom.xml b/spring-cloud-cli-integration-tests/pom.xml index ab577b1..a261d0c 100644 --- a/spring-cloud-cli-integration-tests/pom.xml +++ b/spring-cloud-cli-integration-tests/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-cli-integration-tests - 1.1.4.RELEASE + 1.1.5.BUILD-SNAPSHOT jar spring-cloud-cli-integration-tests @@ -14,7 +14,7 @@ org.springframework.cloud spring-cloud-cli-parent - 1.1.4.RELEASE + 1.1.5.BUILD-SNAPSHOT diff --git a/spring-cloud-cli/pom.xml b/spring-cloud-cli/pom.xml index aafe3d7..457fb9d 100644 --- a/spring-cloud-cli/pom.xml +++ b/spring-cloud-cli/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-cli - 1.1.4.RELEASE + 1.1.5.BUILD-SNAPSHOT jar spring-cloud-cli @@ -14,7 +14,7 @@ org.springframework.cloud spring-cloud-cli-parent - 1.1.4.RELEASE + 1.1.5.BUILD-SNAPSHOT diff --git a/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java b/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java index cf62a43..50c9f12 100644 --- a/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java +++ b/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java @@ -28,7 +28,7 @@ import org.springframework.boot.cli.compiler.GenericBomAstTransformation; @GroovyASTTransformation(phase = CompilePhase.CONVERSION) public class SpringCloudBomAstTransformation extends GenericBomAstTransformation { - private static final String SPRING_CLOUD_VERSION = "Brixton.SR4"; + private static final String SPRING_CLOUD_VERSION = "Brixton.BUILD-SNAPSHOT"; @Override protected String getBomModule() { From 945c20ccbcae2dc16728bb3f016b3389c9bdb385 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Tue, 16 Aug 2016 15:41:50 +0200 Subject: [PATCH 05/13] Deploying documentation to proper folder What we're missing ATM is different documentation versions for different application versions. What this change does is that it's: - finding out what is the current branch (e.g. 1.0.x) - finding out out what is the name of the main adoc file (e.g. spring-cloud-sleuth) - pulling the changes from gh-pages after checkout - finding out what is the list of comma separated whitelisted branches (via the `docs.whitelisted.branches` prop) - in gh-pages creating a folder with name of the branch (e.g. /1.0.x) copying all the docs/target/generated-docs/ to that folder - if the branch from which we're calling the script is NOT master then we're changing the ${main.adoc}.html to index.html so that it's easier to access the docs (e.g. http://cloud.spring.io/spring-cloud-sleuth/1.0.x/) --- docs/pom.xml | 1 + docs/src/main/asciidoc/ghpages.sh | 119 +++++++++++++++++++++++------- 2 files changed, 95 insertions(+), 25 deletions(-) diff --git a/docs/pom.xml b/docs/pom.xml index 0672f15..fffdcfc 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -14,6 +14,7 @@ spring-cloud-cli ${basedir}/.. + 1.0.x diff --git a/docs/src/main/asciidoc/ghpages.sh b/docs/src/main/asciidoc/ghpages.sh index e1063ce..e83a358 100755 --- a/docs/src/main/asciidoc/ghpages.sh +++ b/docs/src/main/asciidoc/ghpages.sh @@ -12,12 +12,46 @@ if ! [ -d docs/target/generated-docs ]; then exit 0 fi -# Find name of current branch +# The script should be executed from the root folder + +ROOT_FOLDER=`pwd` +echo "Current folder is ${ROOT_FOLDER}" + +if [[ ! -e "${ROOT_FOLDER}/.git" ]]; then + echo "You're not in the root folder of the project!" + exit 1 +fi + +# Retrieve properties ################################################################### -branch=$TRAVIS_BRANCH -[ "$branch" == "" ] && branch=`git rev-parse --abbrev-ref HEAD` -target=. -if [ "$branch" != "master" ]; then target=./$branch; mkdir -p $target; fi + +# Prop that will let commit the changes +COMMIT_CHANGES="no" + +# Get the name of the `docs.main` property +MAIN_ADOC_VALUE=$(mvn -q \ + -Dexec.executable="echo" \ + -Dexec.args='${docs.main}' \ + --non-recursive \ + org.codehaus.mojo:exec-maven-plugin:1.3.1:exec) +echo "Extracted 'main.adoc' from Maven build [${MAIN_ADOC_VALUE}]" + +# Get whitelisted branches - assumes that a `docs` module is available under `docs` profile +WHITELIST_PROPERTY="docs.whitelisted.branches" +WHITELISTED_BRANCHES_VALUE=$(mvn -q \ + -Dexec.executable="echo" \ + -Dexec.args="\${${WHITELIST_PROPERTY}}" \ + org.codehaus.mojo:exec-maven-plugin:1.3.1:exec \ + -P docs \ + -pl docs) +echo "Extracted '${WHITELIST_PROPERTY}' from Maven build [${WHITELISTED_BRANCHES_VALUE}]" + +# Code getting the name of the current branch. For master we want to publish as we did until now +# http://stackoverflow.com/questions/1593051/how-to-programmatically-determine-the-current-checked-out-git-branch +CURRENT_BRANCH=$(git symbolic-ref -q HEAD) +CURRENT_BRANCH=${CURRENT_BRANCH##refs/heads/} +CURRENT_BRANCH=${CURRENT_BRANCH:-HEAD} +echo "Current branch is [${CURRENT_BRANCH}]" # Stash any outstanding changes ################################################################### @@ -25,30 +59,65 @@ git diff-index --quiet HEAD dirty=$? if [ "$dirty" != "0" ]; then git stash; fi -# Switch to gh-pages branch to sync it with current branch +# Switch to gh-pages branch to sync it with master ################################################################### git checkout gh-pages +git pull origin gh-pages -for f in docs/target/generated-docs/*; do - file=${f#docs/target/generated-docs/*} - if ! git ls-files -i -o --exclude-standard --directory | grep -q ^$file$; then - # Not ignored... - cp -rf $f $target - git add -A $target/$file - fi -done - -git add -A README.adoc || echo "No change to README.adoc" -git commit -a -m "Sync docs from $branch to gh-pages" || echo "Nothing committed" - -# Uncomment the following push if you want to auto push to -# the gh-pages branch whenever you commit to branch locally. -# This is a little extreme. Use with care! +# Add git branches ################################################################### -git push origin gh-pages || echo "Cannot push gh-pages" +mkdir -p ${ROOT_FOLDER}/${CURRENT_BRANCH} +if [[ "${CURRENT_BRANCH}" == "master" ]] ; then + echo -e "Current branch is master - will copy the current docs only to the root folder" + for f in docs/target/generated-docs/*; do + file=${f#docs/target/generated-docs/*} + if ! git ls-files -i -o --exclude-standard --directory | grep -q ^$file$; then + # Not ignored... + cp -rf $f ${ROOT_FOLDER}/ + git add -A ${ROOT_FOLDER}/$file + fi + done + COMMIT_CHANGES="yes" +else + echo -e "Current branch is [${CURRENT_BRANCH}]" + # http://stackoverflow.com/questions/29300806/a-bash-script-to-check-if-a-string-is-present-in-a-comma-separated-list-of-strin + if [[ ",${WHITELISTED_BRANCHES_VALUE}," = *",${CURRENT_BRANCH},"* ]] ; then + echo -e "Branch [${CURRENT_BRANCH}] is whitelisted! Will copy the current docs to the [${CURRENT_BRANCH}] folder" + for f in docs/target/generated-docs/*; do + file=${f#docs/target/generated-docs/*} + if ! git ls-files -i -o --exclude-standard --directory | grep -q ^$file$; then + # Not ignored... + # We want users to access 1.0.0.RELEASE/ instead of 1.0.0.RELEASE/spring-cloud.sleuth.html + if [[ "${file}" == "${MAIN_ADOC_VALUE}.html" ]] ; then + # We don't want to copy the spring-cloud-sleuth.html + # we want it to be converted to index.html + cp -rf $f ${ROOT_FOLDER}/${CURRENT_BRANCH}/index.html + git add -A ${ROOT_FOLDER}/${CURRENT_BRANCH}/index.html + else + cp -rf $f ${ROOT_FOLDER}/${CURRENT_BRANCH} + git add -A ${ROOT_FOLDER}/${CURRENT_BRANCH}/$file + fi + fi + done + COMMIT_CHANGES="yes" + else + echo -e "Branch [${CURRENT_BRANCH}] is not on the white list! Check out the Maven [${WHITELIST_PROPERTY}] property in + [docs] module available under [docs] profile. Won't commit any changes to gh-pages for this branch." + fi +fi -# Finally, switch back to the current branch and exit block -git checkout $branch +if [[ "${COMMIT_CHANGES}" == "yes" ]] ; then + git commit -a -m "Sync docs from ${CURRENT_BRANCH} to gh-pages" + + # Uncomment the following push if you want to auto push to + # the gh-pages branch whenever you commit to master locally. + # This is a little extreme. Use with care! + ################################################################### + git push origin gh-pages +fi + +# Finally, switch back to the master branch and exit block +git checkout ${CURRENT_BRANCH} if [ "$dirty" != "0" ]; then git stash pop; fi -exit 0 +exit 0 \ No newline at end of file From 71b7747d5843d7395b2ae065749c69ef0522efc9 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Tue, 16 Aug 2016 15:44:08 +0200 Subject: [PATCH 06/13] Added missing whitelisted branch --- docs/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/pom.xml b/docs/pom.xml index fffdcfc..e98e678 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -14,7 +14,7 @@ spring-cloud-cli ${basedir}/.. - 1.0.x + 1.0.x,1.1.x From 9c2f04dc69ce2230541288cdae1d6be59e1e459c Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Wed, 17 Aug 2016 12:42:40 +0200 Subject: [PATCH 07/13] Updating ghpages for all projects --- docs/src/main/asciidoc/ghpages.sh | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/docs/src/main/asciidoc/ghpages.sh b/docs/src/main/asciidoc/ghpages.sh index e83a358..a5d1acd 100755 --- a/docs/src/main/asciidoc/ghpages.sh +++ b/docs/src/main/asciidoc/ghpages.sh @@ -27,9 +27,23 @@ fi # Prop that will let commit the changes COMMIT_CHANGES="no" +MAVEN_PATH=${MAVEN_PATH:-} +echo "Path to Maven is [${MAVEN_PATH}]" + +# Code getting the name of the current branch. For master we want to publish as we did until now +# http://stackoverflow.com/questions/1593051/how-to-programmatically-determine-the-current-checked-out-git-branch +# If there is a branch already passed will reuse it - otherwise will try to find it +CURRENT_BRANCH=${BRANCH} +if [[ -z "${CURRENT_BRANCH}" ]] ; then + CURRENT_BRANCH=$(git symbolic-ref -q HEAD) + CURRENT_BRANCH=${CURRENT_BRANCH##refs/heads/} + CURRENT_BRANCH=${CURRENT_BRANCH:-HEAD} +fi +echo "Current branch is [${CURRENT_BRANCH}]" +git checkout ${CURRENT_BRANCH} # Get the name of the `docs.main` property -MAIN_ADOC_VALUE=$(mvn -q \ +MAIN_ADOC_VALUE=$("${MAVEN_PATH}"mvn -q \ -Dexec.executable="echo" \ -Dexec.args='${docs.main}' \ --non-recursive \ @@ -38,7 +52,7 @@ echo "Extracted 'main.adoc' from Maven build [${MAIN_ADOC_VALUE}]" # Get whitelisted branches - assumes that a `docs` module is available under `docs` profile WHITELIST_PROPERTY="docs.whitelisted.branches" -WHITELISTED_BRANCHES_VALUE=$(mvn -q \ +WHITELISTED_BRANCHES_VALUE=$("${MAVEN_PATH}"mvn -q \ -Dexec.executable="echo" \ -Dexec.args="\${${WHITELIST_PROPERTY}}" \ org.codehaus.mojo:exec-maven-plugin:1.3.1:exec \ @@ -46,17 +60,9 @@ WHITELISTED_BRANCHES_VALUE=$(mvn -q \ -pl docs) echo "Extracted '${WHITELIST_PROPERTY}' from Maven build [${WHITELISTED_BRANCHES_VALUE}]" -# Code getting the name of the current branch. For master we want to publish as we did until now -# http://stackoverflow.com/questions/1593051/how-to-programmatically-determine-the-current-checked-out-git-branch -CURRENT_BRANCH=$(git symbolic-ref -q HEAD) -CURRENT_BRANCH=${CURRENT_BRANCH##refs/heads/} -CURRENT_BRANCH=${CURRENT_BRANCH:-HEAD} -echo "Current branch is [${CURRENT_BRANCH}]" - # Stash any outstanding changes ################################################################### -git diff-index --quiet HEAD -dirty=$? +git diff-index --quiet HEAD && dirty=$? || (echo "Failed to check if the current repo is dirty. Assuming that it is." && dirty="1") if [ "$dirty" != "0" ]; then git stash; fi # Switch to gh-pages branch to sync it with master From 8ec8a3e27d46f836878a6fc43ef8abe42bfae96c Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Thu, 18 Aug 2016 13:08:38 +0200 Subject: [PATCH 08/13] Updating ghpages for all projects --- docs/src/main/asciidoc/ghpages.sh | 368 +++++++++++++++++++++--------- 1 file changed, 266 insertions(+), 102 deletions(-) diff --git a/docs/src/main/asciidoc/ghpages.sh b/docs/src/main/asciidoc/ghpages.sh index a5d1acd..c43f190 100755 --- a/docs/src/main/asciidoc/ghpages.sh +++ b/docs/src/main/asciidoc/ghpages.sh @@ -1,129 +1,293 @@ #!/bin/bash -x -git remote set-url --push origin `git config remote.origin.url | sed -e 's/^git:/https:/'` +set -e -if ! (git remote set-branches --add origin gh-pages && git fetch -q); then - echo "No gh-pages, so not syncing" - exit 0 -fi +# Set default props like MAVEN_PATH, ROOT_FOLDER etc. +function set_default_props() { + # The script should be executed from the root folder + ROOT_FOLDER=`pwd` + echo "Current folder is ${ROOT_FOLDER}" -if ! [ -d docs/target/generated-docs ]; then - echo "No gh-pages sources in docs/target/generated-docs, so not syncing" - exit 0 -fi + if [[ ! -e "${ROOT_FOLDER}/.git" ]]; then + echo "You're not in the root folder of the project!" + exit 1 + fi -# The script should be executed from the root folder + # Prop that will let commit the changes + COMMIT_CHANGES="no" + MAVEN_PATH=${MAVEN_PATH:-} + echo "Path to Maven is [${MAVEN_PATH}]" + REPO_NAME=${PWD##*/} + echo "Repo name is [${REPO_NAME}]" +} -ROOT_FOLDER=`pwd` -echo "Current folder is ${ROOT_FOLDER}" +# Check if gh-pages exists and docs have been built +function check_if_anything_to_sync() { + git remote set-url --push origin `git config remote.origin.url | sed -e 's/^git:/https:/'` -if [[ ! -e "${ROOT_FOLDER}/.git" ]]; then - echo "You're not in the root folder of the project!" - exit 1 -fi + if ! (git remote set-branches --add origin gh-pages && git fetch -q); then + echo "No gh-pages, so not syncing" + exit 0 + fi -# Retrieve properties -################################################################### + if ! [ -d docs/target/generated-docs ]; then + echo "No gh-pages sources in docs/target/generated-docs, so not syncing" + exit 0 + fi +} -# Prop that will let commit the changes -COMMIT_CHANGES="no" -MAVEN_PATH=${MAVEN_PATH:-} -echo "Path to Maven is [${MAVEN_PATH}]" +function retrieve_current_branch() { + # Code getting the name of the current branch. For master we want to publish as we did until now + # http://stackoverflow.com/questions/1593051/how-to-programmatically-determine-the-current-checked-out-git-branch + # If there is a branch already passed will reuse it - otherwise will try to find it + CURRENT_BRANCH=${BRANCH} + if [[ -z "${CURRENT_BRANCH}" ]] ; then + CURRENT_BRANCH=$(git symbolic-ref -q HEAD) + CURRENT_BRANCH=${CURRENT_BRANCH##refs/heads/} + CURRENT_BRANCH=${CURRENT_BRANCH:-HEAD} + fi + echo "Current branch is [${CURRENT_BRANCH}]" + git checkout ${CURRENT_BRANCH} -# Code getting the name of the current branch. For master we want to publish as we did until now -# http://stackoverflow.com/questions/1593051/how-to-programmatically-determine-the-current-checked-out-git-branch -# If there is a branch already passed will reuse it - otherwise will try to find it -CURRENT_BRANCH=${BRANCH} -if [[ -z "${CURRENT_BRANCH}" ]] ; then - CURRENT_BRANCH=$(git symbolic-ref -q HEAD) - CURRENT_BRANCH=${CURRENT_BRANCH##refs/heads/} - CURRENT_BRANCH=${CURRENT_BRANCH:-HEAD} -fi -echo "Current branch is [${CURRENT_BRANCH}]" -git checkout ${CURRENT_BRANCH} +} + +# Switches to the provided value of the release version. We always prefix it with `v` +function switch_to_tag() { + git checkout v${VERSION} +} # Get the name of the `docs.main` property -MAIN_ADOC_VALUE=$("${MAVEN_PATH}"mvn -q \ - -Dexec.executable="echo" \ - -Dexec.args='${docs.main}' \ - --non-recursive \ - org.codehaus.mojo:exec-maven-plugin:1.3.1:exec) -echo "Extracted 'main.adoc' from Maven build [${MAIN_ADOC_VALUE}]" - # Get whitelisted branches - assumes that a `docs` module is available under `docs` profile -WHITELIST_PROPERTY="docs.whitelisted.branches" -WHITELISTED_BRANCHES_VALUE=$("${MAVEN_PATH}"mvn -q \ - -Dexec.executable="echo" \ - -Dexec.args="\${${WHITELIST_PROPERTY}}" \ - org.codehaus.mojo:exec-maven-plugin:1.3.1:exec \ - -P docs \ - -pl docs) -echo "Extracted '${WHITELIST_PROPERTY}' from Maven build [${WHITELISTED_BRANCHES_VALUE}]" +function retrieve_doc_properties() { + MAIN_ADOC_VALUE=$("${MAVEN_PATH}"mvn -q \ + -Dexec.executable="echo" \ + -Dexec.args='${docs.main}' \ + --non-recursive \ + org.codehaus.mojo:exec-maven-plugin:1.3.1:exec) + echo "Extracted 'main.adoc' from Maven build [${MAIN_ADOC_VALUE}]" + + + WHITELIST_PROPERTY=${WHITELIST_PROPERTY:-"docs.whitelisted.branches"} + WHITELISTED_BRANCHES_VALUE=$("${MAVEN_PATH}"mvn -q \ + -Dexec.executable="echo" \ + -Dexec.args="\${${WHITELIST_PROPERTY}}" \ + org.codehaus.mojo:exec-maven-plugin:1.3.1:exec \ + -P docs \ + -pl docs) + echo "Extracted '${WHITELIST_PROPERTY}' from Maven build [${WHITELISTED_BRANCHES_VALUE}]" +} # Stash any outstanding changes -################################################################### -git diff-index --quiet HEAD && dirty=$? || (echo "Failed to check if the current repo is dirty. Assuming that it is." && dirty="1") -if [ "$dirty" != "0" ]; then git stash; fi +function stash_changes() { + git diff-index --quiet HEAD && dirty=$? || (echo "Failed to check if the current repo is dirty. Assuming that it is." && dirty="1") + if [ "$dirty" != "0" ]; then git stash; fi +} -# Switch to gh-pages branch to sync it with master -################################################################### -git checkout gh-pages -git pull origin gh-pages - -# Add git branches -################################################################### -mkdir -p ${ROOT_FOLDER}/${CURRENT_BRANCH} -if [[ "${CURRENT_BRANCH}" == "master" ]] ; then - echo -e "Current branch is master - will copy the current docs only to the root folder" - for f in docs/target/generated-docs/*; do - file=${f#docs/target/generated-docs/*} - if ! git ls-files -i -o --exclude-standard --directory | grep -q ^$file$; then - # Not ignored... - cp -rf $f ${ROOT_FOLDER}/ - git add -A ${ROOT_FOLDER}/$file +# Switch to gh-pages branch to sync it with current branch +function add_docs_from_target() { + local DESTINATION_REPO_FOLDER + if [[ -z "${DESTINATION}" ]] ; then + DESTINATION_REPO_FOLDER=${ROOT_FOLDER} + else + if [[ ! -e "${DESTINATION}/.git" ]]; then + echo "[${DESTINATION}] is not a git repository" + exit 1 fi - done - COMMIT_CHANGES="yes" -else - echo -e "Current branch is [${CURRENT_BRANCH}]" - # http://stackoverflow.com/questions/29300806/a-bash-script-to-check-if-a-string-is-present-in-a-comma-separated-list-of-strin - if [[ ",${WHITELISTED_BRANCHES_VALUE}," = *",${CURRENT_BRANCH},"* ]] ; then - echo -e "Branch [${CURRENT_BRANCH}] is whitelisted! Will copy the current docs to the [${CURRENT_BRANCH}] folder" + DESTINATION_REPO_FOLDER=${DESTINATION}/${REPO_NAME} + mkdir -p ${DESTINATION_REPO_FOLDER} + echo "Destination was provided [${DESTINATION}]" + fi + cd ${DESTINATION_REPO_FOLDER} + git checkout gh-pages + git pull origin gh-pages + + # Add git branches + ################################################################### + if [[ -z "${VERSION}" ]] ; then + copy_docs_for_current_version + else + copy_docs_for_provided_version + fi + commit_changes_if_applicable +} + + +# Copies the docs by using the retrieved properties from Maven build +function copy_docs_for_current_version() { + if [[ "${CURRENT_BRANCH}" == "master" ]] ; then + echo -e "Current branch is master - will copy the current docs only to the root folder" for f in docs/target/generated-docs/*; do file=${f#docs/target/generated-docs/*} if ! git ls-files -i -o --exclude-standard --directory | grep -q ^$file$; then # Not ignored... - # We want users to access 1.0.0.RELEASE/ instead of 1.0.0.RELEASE/spring-cloud.sleuth.html - if [[ "${file}" == "${MAIN_ADOC_VALUE}.html" ]] ; then - # We don't want to copy the spring-cloud-sleuth.html - # we want it to be converted to index.html - cp -rf $f ${ROOT_FOLDER}/${CURRENT_BRANCH}/index.html - git add -A ${ROOT_FOLDER}/${CURRENT_BRANCH}/index.html - else - cp -rf $f ${ROOT_FOLDER}/${CURRENT_BRANCH} - git add -A ${ROOT_FOLDER}/${CURRENT_BRANCH}/$file - fi + cp -rf $f ${ROOT_FOLDER}/ + git add -A ${ROOT_FOLDER}/$file fi done COMMIT_CHANGES="yes" else - echo -e "Branch [${CURRENT_BRANCH}] is not on the white list! Check out the Maven [${WHITELIST_PROPERTY}] property in - [docs] module available under [docs] profile. Won't commit any changes to gh-pages for this branch." + echo -e "Current branch is [${CURRENT_BRANCH}]" + # http://stackoverflow.com/questions/29300806/a-bash-script-to-check-if-a-string-is-present-in-a-comma-separated-list-of-strin + if [[ ",${WHITELISTED_BRANCHES_VALUE}," = *",${CURRENT_BRANCH},"* ]] ; then + mkdir -p ${ROOT_FOLDER}/${CURRENT_BRANCH} + echo -e "Branch [${CURRENT_BRANCH}] is whitelisted! Will copy the current docs to the [${CURRENT_BRANCH}] folder" + for f in docs/target/generated-docs/*; do + file=${f#docs/target/generated-docs/*} + if ! git ls-files -i -o --exclude-standard --directory | grep -q ^$file$; then + # Not ignored... + # We want users to access 1.0.0.RELEASE/ instead of 1.0.0.RELEASE/spring-cloud.sleuth.html + if [[ "${file}" == "${MAIN_ADOC_VALUE}.html" ]] ; then + # We don't want to copy the spring-cloud-sleuth.html + # we want it to be converted to index.html + cp -rf $f ${ROOT_FOLDER}/${CURRENT_BRANCH}/index.html + git add -A ${ROOT_FOLDER}/${CURRENT_BRANCH}/index.html + else + cp -rf $f ${ROOT_FOLDER}/${CURRENT_BRANCH} + git add -A ${ROOT_FOLDER}/${CURRENT_BRANCH}/$file + fi + fi + done + COMMIT_CHANGES="yes" + else + echo -e "Branch [${CURRENT_BRANCH}] is not on the white list! Check out the Maven [${WHITELIST_PROPERTY}] property in + [docs] module available under [docs] profile. Won't commit any changes to gh-pages for this branch." + fi fi +} + +# Copies the docs by using the explicitly provided version +function copy_docs_for_provided_version() { + local FOLDER=${DESTINATION_REPO_FOLDER}/${VERSION} + mkdir -p ${FOLDER} + echo -e "Current tag is [v${VERSION}] Will copy the current docs to the [${FOLDER}] folder" + for f in ${ROOT_FOLDER}/docs/target/generated-docs/*; do + file=${f#${ROOT_FOLDER}/docs/target/generated-docs/*} + copy_docs_for_branch ${file} ${FOLDER} + done + COMMIT_CHANGES="yes" + CURRENT_BRANCH="v${VERSION}" +} + +# Copies the docs from target to the provided destination +# Params: +# $1 - file from target +# $2 - destination to which copy the files +function copy_docs_for_branch() { + local file=$1 + local destination=$2 + if ! git ls-files -i -o --exclude-standard --directory | grep -q ^${file}$; then + # Not ignored... + # We want users to access 1.0.0.RELEASE/ instead of 1.0.0.RELEASE/spring-cloud.sleuth.html + if [[ "${file}" == "${MAIN_ADOC_VALUE}.html" ]] ; then + # We don't want to copy the spring-cloud-sleuth.html + # we want it to be converted to index.html + cp -rf $f ${destination}/index.html + git add -A ${destination}/index.html + else + cp -rf $f ${destination} + git add -A ${destination}/$file + fi + fi +} + +function commit_changes_if_applicable() { + if [[ "${COMMIT_CHANGES}" == "yes" ]] ; then + COMMIT_SUCCESSFUL="no" + git commit -a -m "Sync docs from ${CURRENT_BRANCH} to gh-pages" && COMMIT_SUCCESSFUL="yes" || echo "Failed to commit changes" + + # Uncomment the following push if you want to auto push to + # the gh-pages branch whenever you commit to master locally. + # This is a little extreme. Use with care! + ################################################################### + if [[ "${COMMIT_SUCCESSFUL}" == "yes" ]] ; then + git push origin gh-pages + fi + fi +} + +# Switch back to the previous branch and exit block +function checkout_previous_branch() { + git checkout ${CURRENT_BRANCH} + if [ "$dirty" != "0" ]; then git stash pop; fi + exit 0 +} + +# Assert if properties have been properly passed +function assert_properties() { +if [[ "${VERSION}" != "" && -z "${DESTINATION}" ]] ; then echo "Version was set but destination was not!"; exit 1;fi +if [[ "${DESTINATION}" != "" && -z "${VERSION}" ]] ; then echo "Destination was set but version was not!"; exit 1;fi +} + +# Prints the usage +function print_usage() { +cat </` + +USAGE: + +You can use the following options: + +-v|--version - the script will apply the whole procedure for a particular library version +-d|--destination - the root of destination folder where the docs should be copied. E.g. point to spring-cloud-static folder + +EOF +} + + +# ========================================== +# ____ ____ _____ _____ _____ _______ +# / ____|/ ____| __ \|_ _| __ \__ __| +# | (___ | | | |__) | | | | |__) | | | +# \___ \| | | _ / | | | ___/ | | +# ____) | |____| | \ \ _| |_| | | | +# |_____/ \_____|_| \_\_____|_| |_| +# +# ========================================== + +while [[ $# > 0 ]] +do +key="$1" +case ${key} in + -v|--version) + VERSION="$2" + shift # past argument + ;; + -d|--destination) + DESTINATION="$2" + shift # past argument + ;; + -h|--help) + print_usage + exit 0 + ;; + *) + echo "Invalid option: [$1]" + print_usage + exit 1 + ;; +esac +shift # past argument or value +done + +assert_properties +set_default_props +check_if_anything_to_sync +if [[ -z "${VERSION}" ]] ; then + retrieve_current_branch +else + switch_to_tag fi - -if [[ "${COMMIT_CHANGES}" == "yes" ]] ; then - git commit -a -m "Sync docs from ${CURRENT_BRANCH} to gh-pages" - - # Uncomment the following push if you want to auto push to - # the gh-pages branch whenever you commit to master locally. - # This is a little extreme. Use with care! - ################################################################### - git push origin gh-pages -fi - -# Finally, switch back to the master branch and exit block -git checkout ${CURRENT_BRANCH} -if [ "$dirty" != "0" ]; then git stash pop; fi - -exit 0 \ No newline at end of file +retrieve_doc_properties +stash_changes +add_docs_from_target +checkout_previous_branch \ No newline at end of file From d836b52f34f81d02c888d7ed5589071638e998d4 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Fri, 19 Aug 2016 11:44:24 +0200 Subject: [PATCH 09/13] Updating ghpages for all projects --- docs/src/main/asciidoc/ghpages.sh | 52 ++++++++++++++++++++++++++----- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/docs/src/main/asciidoc/ghpages.sh b/docs/src/main/asciidoc/ghpages.sh index c43f190..6a6363b 100755 --- a/docs/src/main/asciidoc/ghpages.sh +++ b/docs/src/main/asciidoc/ghpages.sh @@ -19,6 +19,8 @@ function set_default_props() { echo "Path to Maven is [${MAVEN_PATH}]" REPO_NAME=${PWD##*/} echo "Repo name is [${REPO_NAME}]" + SPRING_CLOUD_STATIC_REPO=${SPRING_CLOUD_STATIC_REPO:-git@github.com:spring-cloud/spring-cloud-static.git} + echo "Spring Cloud Static repo is [${SPRING_CLOUD_STATIC_REPO}" } # Check if gh-pages exists and docs have been built @@ -47,8 +49,7 @@ function retrieve_current_branch() { CURRENT_BRANCH=${CURRENT_BRANCH:-HEAD} fi echo "Current branch is [${CURRENT_BRANCH}]" - git checkout ${CURRENT_BRANCH} - + git checkout ${CURRENT_BRANCH} || echo "Failed to check the branch... continuing with the script" } # Switches to the provided value of the release version. We always prefix it with `v` @@ -56,6 +57,13 @@ function switch_to_tag() { git checkout v${VERSION} } +# Build the docs if switch is on +function build_docs_if_applicable() { + if [[ "${BUILD}" == "yes" ]] ; then + ./mvnw clean install -P docs -pl docs -DskipTests + fi +} + # Get the name of the `docs.main` property # Get whitelisted branches - assumes that a `docs` module is available under `docs` profile function retrieve_doc_properties() { @@ -86,8 +94,19 @@ function stash_changes() { # Switch to gh-pages branch to sync it with current branch function add_docs_from_target() { local DESTINATION_REPO_FOLDER - if [[ -z "${DESTINATION}" ]] ; then + if [[ -z "${DESTINATION}" && -z "${CLONE}" ]] ; then DESTINATION_REPO_FOLDER=${ROOT_FOLDER} + elif [[ "${CLONE}" == "yes" ]]; then + mkdir -p ${ROOT_FOLDER}/target + local clonedStatic=${ROOT_FOLDER}/target/spring-cloud-static + if [[ ! -e "${clonedStatic}/.git" ]]; then + echo "Cloning Spring Cloud Static to target" + git clone ${SPRING_CLOUD_STATIC_REPO} ${clonedStatic} + else + echo "Spring Cloud Static already cloned - will pull changes" + cd ${clonedStatic} && git checkout gh-pages && git pull origin gh-pages + fi + DESTINATION_REPO_FOLDER=${clonedStatic}/${REPO_NAME} else if [[ ! -e "${DESTINATION}/.git" ]]; then echo "[${DESTINATION}] is not a git repository" @@ -178,7 +197,7 @@ function copy_docs_for_branch() { if ! git ls-files -i -o --exclude-standard --directory | grep -q ^${file}$; then # Not ignored... # We want users to access 1.0.0.RELEASE/ instead of 1.0.0.RELEASE/spring-cloud.sleuth.html - if [[ "${file}" == "${MAIN_ADOC_VALUE}.html" ]] ; then + if [[ ("${file}" == "${MAIN_ADOC_VALUE}.html") || ("${file}" == "${REPO_NAME}.html") ]] ; then # We don't want to copy the spring-cloud-sleuth.html # we want it to be converted to index.html cp -rf $f ${destination}/index.html @@ -207,15 +226,19 @@ function commit_changes_if_applicable() { # Switch back to the previous branch and exit block function checkout_previous_branch() { - git checkout ${CURRENT_BRANCH} + # If -version was provided we need to come back to root project + cd ${ROOT_FOLDER} + git checkout ${CURRENT_BRANCH} || echo "Failed to check the branch... continuing with the script" if [ "$dirty" != "0" ]; then git stash pop; fi exit 0 } # Assert if properties have been properly passed function assert_properties() { -if [[ "${VERSION}" != "" && -z "${DESTINATION}" ]] ; then echo "Version was set but destination was not!"; exit 1;fi -if [[ "${DESTINATION}" != "" && -z "${VERSION}" ]] ; then echo "Destination was set but version was not!"; exit 1;fi +echo "VERSION [${VERSION}], DESTINATION [${DESTINATION}], CLONE [${CLONE}]" +if [[ "${VERSION}" != "" && (-z "${DESTINATION}" && -z "${CLONE}") ]] ; then echo "Version was set but destination / clone was not!"; exit 1;fi +if [[ ("${DESTINATION}" != "" && "${CLONE}" != "") && -z "${VERSION}" ]] ; then echo "Destination / clone was set but version was not!"; exit 1;fi +if [[ "${DESTINATION}" != "" && "${CLONE}" == "yes" ]] ; then echo "Destination and clone was set. Pick one!"; exit 1;fi } # Prints the usage @@ -232,13 +255,19 @@ the script will work in the following manner: with that version number will be created in the gh-pages branch. WARNING! No whitelist verification will take place - if the destination switch is passed (-d) then the script will check if the provided dir is a git repo and then will switch to gh-pages of that repo and copy the generated docs to `docs//` +- if the destination switch is passed (-d) then the script will check if the provided dir is a git repo and then will + switch to gh-pages of that repo and copy the generated docs to `docs//` USAGE: You can use the following options: -v|--version - the script will apply the whole procedure for a particular library version --d|--destination - the root of destination folder where the docs should be copied. E.g. point to spring-cloud-static folder +-d|--destination - the root of destination folder where the docs should be copied. You have to use the full path. + E.g. point to spring-cloud-static folder. Can't be used with (-c) +-b|--build - will run the standard build process after checking out the branch +-c|--clone - will automatically clone the spring-cloud-static repo instead of providing the destination. + Obviously can't be used with (-d) EOF } @@ -266,6 +295,12 @@ case ${key} in DESTINATION="$2" shift # past argument ;; + -b|--build) + BUILD="yes" + ;; + -c|--clone) + CLONE="yes" + ;; -h|--help) print_usage exit 0 @@ -287,6 +322,7 @@ if [[ -z "${VERSION}" ]] ; then else switch_to_tag fi +build_docs_if_applicable retrieve_doc_properties stash_changes add_docs_from_target From 618026d58b1bde183c4e9861561680b1569757f7 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Mon, 22 Aug 2016 13:30:41 +0200 Subject: [PATCH 10/13] Updating ghpages for all projects --- docs/src/main/asciidoc/ghpages.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/src/main/asciidoc/ghpages.sh b/docs/src/main/asciidoc/ghpages.sh index 6a6363b..57c5da3 100755 --- a/docs/src/main/asciidoc/ghpages.sh +++ b/docs/src/main/asciidoc/ghpages.sh @@ -32,7 +32,7 @@ function check_if_anything_to_sync() { exit 0 fi - if ! [ -d docs/target/generated-docs ]; then + if ! [ -d docs/target/generated-docs ] && ! [ "${BUILD}" == "yes" ]; then echo "No gh-pages sources in docs/target/generated-docs, so not syncing" exit 0 fi @@ -101,12 +101,13 @@ function add_docs_from_target() { local clonedStatic=${ROOT_FOLDER}/target/spring-cloud-static if [[ ! -e "${clonedStatic}/.git" ]]; then echo "Cloning Spring Cloud Static to target" - git clone ${SPRING_CLOUD_STATIC_REPO} ${clonedStatic} + git clone ${SPRING_CLOUD_STATIC_REPO} ${clonedStatic} && git checkout gh-pages else echo "Spring Cloud Static already cloned - will pull changes" cd ${clonedStatic} && git checkout gh-pages && git pull origin gh-pages fi DESTINATION_REPO_FOLDER=${clonedStatic}/${REPO_NAME} + mkdir -p ${DESTINATION_REPO_FOLDER} else if [[ ! -e "${DESTINATION}/.git" ]]; then echo "[${DESTINATION}] is not a git repository" From c35531c8e016de9c20b8bb338c184327f936d67c Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Tue, 23 Aug 2016 09:13:36 +0100 Subject: [PATCH 11/13] Update for 1.1.5 (Brixton.SR5) --- docs/pom.xml | 2 +- pom.xml | 6 +++--- spring-cloud-cli-integration-tests/pom.xml | 4 ++-- spring-cloud-cli/pom.xml | 4 ++-- .../cloud/cli/compiler/SpringCloudBomAstTransformation.java | 2 +- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/docs/pom.xml b/docs/pom.xml index e98e678..874d381 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -6,7 +6,7 @@ org.springframework.cloud spring-cloud-cli-parent - 1.1.5.BUILD-SNAPSHOT + 1.1.5.RELEASE pom Spring Cloud Cli Docs diff --git a/pom.xml b/pom.xml index 32fd141..f3fbf61 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 org.springframework.cloud spring-cloud-cli-parent - 1.1.5.BUILD-SNAPSHOT + 1.1.5.RELEASE org.springframework.cloud spring-cloud-build @@ -95,14 +95,14 @@ org.springframework.cloud spring-cloud-config - 1.1.3.BUILD-SNAPSHOT + 1.1.3.RELEASE pom import org.springframework.cloud spring-cloud-netflix - 1.1.6.BUILD-SNAPSHOT + 1.1.5.RELEASE pom import diff --git a/spring-cloud-cli-integration-tests/pom.xml b/spring-cloud-cli-integration-tests/pom.xml index a261d0c..5d22252 100644 --- a/spring-cloud-cli-integration-tests/pom.xml +++ b/spring-cloud-cli-integration-tests/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-cli-integration-tests - 1.1.5.BUILD-SNAPSHOT + 1.1.5.RELEASE jar spring-cloud-cli-integration-tests @@ -14,7 +14,7 @@ org.springframework.cloud spring-cloud-cli-parent - 1.1.5.BUILD-SNAPSHOT + 1.1.5.RELEASE diff --git a/spring-cloud-cli/pom.xml b/spring-cloud-cli/pom.xml index 457fb9d..76aa201 100644 --- a/spring-cloud-cli/pom.xml +++ b/spring-cloud-cli/pom.xml @@ -5,7 +5,7 @@ org.springframework.cloud spring-cloud-cli - 1.1.5.BUILD-SNAPSHOT + 1.1.5.RELEASE jar spring-cloud-cli @@ -14,7 +14,7 @@ org.springframework.cloud spring-cloud-cli-parent - 1.1.5.BUILD-SNAPSHOT + 1.1.5.RELEASE diff --git a/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java b/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java index 50c9f12..3d25372 100644 --- a/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java +++ b/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java @@ -28,7 +28,7 @@ import org.springframework.boot.cli.compiler.GenericBomAstTransformation; @GroovyASTTransformation(phase = CompilePhase.CONVERSION) public class SpringCloudBomAstTransformation extends GenericBomAstTransformation { - private static final String SPRING_CLOUD_VERSION = "Brixton.BUILD-SNAPSHOT"; + private static final String SPRING_CLOUD_VERSION = "Brixton.SR5"; @Override protected String getBomModule() { From 598e79d1f5b9bfc6da85f8c934bb87f646bdfb5a Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Tue, 23 Aug 2016 09:16:41 +0100 Subject: [PATCH 12/13] Revert to snapshots --- docs/pom.xml | 2 +- pom.xml | 8 ++++---- spring-cloud-cli-integration-tests/pom.xml | 3 +-- spring-cloud-cli/pom.xml | 3 +-- .../cli/compiler/SpringCloudBomAstTransformation.java | 2 +- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/docs/pom.xml b/docs/pom.xml index 874d381..2ff6d50 100644 --- a/docs/pom.xml +++ b/docs/pom.xml @@ -6,7 +6,7 @@ org.springframework.cloud spring-cloud-cli-parent - 1.1.5.RELEASE + 1.1.6.BUILD-SNAPSHOT pom Spring Cloud Cli Docs diff --git a/pom.xml b/pom.xml index f3fbf61..a505f4a 100644 --- a/pom.xml +++ b/pom.xml @@ -3,11 +3,11 @@ 4.0.0 org.springframework.cloud spring-cloud-cli-parent - 1.1.5.RELEASE + 1.1.6.BUILD-SNAPSHOT org.springframework.cloud spring-cloud-build - 1.1.1.RELEASE + 1.1.3.BUILD-SNAPSHOT pom @@ -95,14 +95,14 @@ org.springframework.cloud spring-cloud-config - 1.1.3.RELEASE + 1.1.4.BUILD-SNAPSHOT pom import org.springframework.cloud spring-cloud-netflix - 1.1.5.RELEASE + 1.1.6.BUILD-SNAPSHOT pom import diff --git a/spring-cloud-cli-integration-tests/pom.xml b/spring-cloud-cli-integration-tests/pom.xml index 5d22252..a7f803e 100644 --- a/spring-cloud-cli-integration-tests/pom.xml +++ b/spring-cloud-cli-integration-tests/pom.xml @@ -5,7 +5,6 @@ org.springframework.cloud spring-cloud-cli-integration-tests - 1.1.5.RELEASE jar spring-cloud-cli-integration-tests @@ -14,7 +13,7 @@ org.springframework.cloud spring-cloud-cli-parent - 1.1.5.RELEASE + 1.1.6.BUILD-SNAPSHOT diff --git a/spring-cloud-cli/pom.xml b/spring-cloud-cli/pom.xml index 76aa201..b977655 100644 --- a/spring-cloud-cli/pom.xml +++ b/spring-cloud-cli/pom.xml @@ -5,7 +5,6 @@ org.springframework.cloud spring-cloud-cli - 1.1.5.RELEASE jar spring-cloud-cli @@ -14,7 +13,7 @@ org.springframework.cloud spring-cloud-cli-parent - 1.1.5.RELEASE + 1.1.6.BUILD-SNAPSHOT diff --git a/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java b/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java index 3d25372..50c9f12 100644 --- a/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java +++ b/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/compiler/SpringCloudBomAstTransformation.java @@ -28,7 +28,7 @@ import org.springframework.boot.cli.compiler.GenericBomAstTransformation; @GroovyASTTransformation(phase = CompilePhase.CONVERSION) public class SpringCloudBomAstTransformation extends GenericBomAstTransformation { - private static final String SPRING_CLOUD_VERSION = "Brixton.SR5"; + private static final String SPRING_CLOUD_VERSION = "Brixton.BUILD-SNAPSHOT"; @Override protected String getBomModule() { From 06548d06ca4a71ae2eda88c50ce36340f074f47b Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Thu, 25 Aug 2016 21:50:20 +0100 Subject: [PATCH 13/13] Add --keypass option to CLI Up to now we only supported the default key pass (the same as the store password). This change adds a new option to "encrypt" and "decrypt" commands. Fixes gh-26 --- .../encrypt/BaseEncryptOptionHandler.java | 38 ++++++++++++------ .../command/encrypt/DecryptCommandTests.java | 14 +++++++ .../src/test/resources/keystore.jks | Bin 0 -> 2236 bytes 3 files changed, 39 insertions(+), 13 deletions(-) create mode 100644 spring-cloud-cli/src/test/resources/keystore.jks diff --git a/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/command/encrypt/BaseEncryptOptionHandler.java b/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/command/encrypt/BaseEncryptOptionHandler.java index 39c1961..f26b8e5 100644 --- a/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/command/encrypt/BaseEncryptOptionHandler.java +++ b/spring-cloud-cli/src/main/java/org/springframework/cloud/cli/command/encrypt/BaseEncryptOptionHandler.java @@ -40,6 +40,8 @@ class BaseEncryptOptionHandler extends OptionHandler { private OptionSpec passwordOption; + private OptionSpec keyPassOption; + private Charset charset; { @@ -48,16 +50,18 @@ class BaseEncryptOptionHandler extends OptionHandler { @Override protected final void options() { - this.keyOption = option( - asList("key", "k"), + this.keyOption = option(asList("key", "k"), "Specify key (symmetric secret, or pem-encoded key). If the value starts with @ it is interpreted as a file location.") - .withRequiredArg(); + .withRequiredArg(); this.passwordOption = option("password", - "A password for the keyfile (assuming the --key option is a KetStore file).") - .withRequiredArg(); + "A password for the keyfile (assuming the --key option is a KeyStore file).") + .withRequiredArg(); + this.keyPassOption = option("keypass", + "A password for the key, defaults to the same as the store password (assuming the --key option is a KeyStore file).") + .withRequiredArg(); this.aliasOption = option("alias", - "An alias for the the key in a keyfile (assuming the --key option is a KetStore file).") - .withRequiredArg(); + "An alias for the the key in a keyfile (assuming the --key option is a KeyStore file).") + .withRequiredArg(); doOptions(); } @@ -66,17 +70,25 @@ class BaseEncryptOptionHandler extends OptionHandler { protected TextEncryptor createEncryptor(OptionSet options) { String value = keyOption.value(options); - if (value==null) { + if (value == null) { throw new MissingKeyException(); } if (options.has(passwordOption)) { // it's a keystore String password = options.valueOf(passwordOption); String alias = options.valueOf(aliasOption); - KeyStoreKeyFactory factory = new KeyStoreKeyFactory(new FileSystemResource( - value), password.toCharArray()); - RsaSecretEncryptor encryptor = new RsaSecretEncryptor( - factory.getKeyPair(alias)); - return encryptor; + KeyStoreKeyFactory factory = new KeyStoreKeyFactory( + new FileSystemResource(value), password.toCharArray()); + if (options.has(keyPassOption)) { + String keypass = options.valueOf(keyPassOption); + RsaSecretEncryptor encryptor = new RsaSecretEncryptor( + factory.getKeyPair(alias, keypass.toCharArray())); + return encryptor; + } + else { + RsaSecretEncryptor encryptor = new RsaSecretEncryptor( + factory.getKeyPair(alias)); + return encryptor; + } } boolean verbose = Boolean.getBoolean("debug"); if (value.startsWith("@")) { diff --git a/spring-cloud-cli/src/test/java/org/springframework/cloud/cli/command/encrypt/DecryptCommandTests.java b/spring-cloud-cli/src/test/java/org/springframework/cloud/cli/command/encrypt/DecryptCommandTests.java index d0ea7a7..3e33e85 100644 --- a/spring-cloud-cli/src/test/java/org/springframework/cloud/cli/command/encrypt/DecryptCommandTests.java +++ b/spring-cloud-cli/src/test/java/org/springframework/cloud/cli/command/encrypt/DecryptCommandTests.java @@ -22,6 +22,7 @@ import java.nio.charset.Charset; import org.junit.Test; import org.springframework.boot.cli.command.status.ExitStatus; import org.springframework.core.io.ClassPathResource; +import org.springframework.security.rsa.crypto.KeyStoreKeyFactory; import org.springframework.security.rsa.crypto.RsaSecretEncryptor; import org.springframework.util.StreamUtils; @@ -49,6 +50,19 @@ public class DecryptCommandTests { command.run("-k", "@src/test/resources/private.pem", cipher)); } + @Test + public void decryptsFromRsaKeyWithKeyStore() throws Exception { + KeyStoreKeyFactory factory = new KeyStoreKeyFactory( + new ClassPathResource("keystore.jks"), "letmein".toCharArray()); + RsaSecretEncryptor encryptor = new RsaSecretEncryptor( + factory.getKeyPair("mytestkey", "changeme".toCharArray())); + String cipher = encryptor.encrypt("foo"); + assertEquals(ExitStatus.OK, + command.run("-k", "src/test/resources/keystore.jks", "--password", + "letmein", "--keypass", "changeme", "--alias", "mytestkey", + cipher)); + } + @Test(expected = IllegalArgumentException.class) public void failsWithPlainText() throws Exception { assertEquals(ExitStatus.OK, command.run("-k", "deadbeef", "foo")); diff --git a/spring-cloud-cli/src/test/resources/keystore.jks b/spring-cloud-cli/src/test/resources/keystore.jks new file mode 100644 index 0000000000000000000000000000000000000000..8cd9b5a16af313e008501514e2c263b8aa6f1727 GIT binary patch literal 2236 zcmchY*H@E?7RB?WfKmb>^roP+(2~%kc`pMPdJhDp2na|?D2WtBkRZJ%prS(Pp(8Me zB2@@oiXcUhDvCpq5=Zn>2WQ>8*8BzcVL$xN+7D;#bJjUWUyr_mKp^mmfWLK`7*6pd zQ~W%`Pb!w;E1$1|KrjGJg&v~eENt>D02Dxh5dZ)KL8;JHFE5>ZaMQT$xhyB$qt_XJ z%=!y@%^o)0QOPs60xLFe=QWUD;s+kW!v+#ssw4U3H(Q1=En~2-*QbTGjC$_}Yt_7+2+5=qwU4UYE1=s`A=hkQ6M zf8qCdE0!#IV%VsDjJOtQ%=&vOGrJr^dE#O&7yCKR-@0}%>)8@1*;m7iY7`u;i)HRZnpC3k*bxbOD@lGHYox^@FiX3>5Gdv$DBBQt9JKOrwPAW0A$H@D| z*%TYzMuYTTC3Tmr*@Ido0^C|@VC@NU;AZ{RT*bAi^E&F4L-wbWY2u!>en#3u3Ti^_ zNo+V%i4oHNh~QoPJ!3`yZ(Z8v4};J`$FYkb2tHO!y(`-Mqs&{Ly~=3E`n6q6{MR$n z>Aaq8qIxT|Qs@THz82WQ)DSDW`MZqHmtLGu4byKa>!WzVD1juH)o5yEqR(x|qK;xP z%HOAtw@yd+w9+kIvCK|d$lJ@|*Dc?ZD$YsI;}n)Fb@_^o1o@w|JkYzqomja7E|#2h z2sd6NUnL#U^2jU?tA_$7IlNTVzF>WOc2nL;^dG5SrbxF`h!mtG5|2yj7Ms1^eU89c z6qXFd!)y2BTqLJE;-r;%#sk{Jd0aY6#$H7+-zB**uevgP^p_dx6m#Kf4IkM}y263K zBTCFD{Rv+MagzgE?cb}5denkgS}~#J5?87$!0~n={OC7vZVE@IRO=u)K{v*iN(Y|I zPtjV&V0zKy>G_PNRfmDJ+`VlrdQzg~V98c&*++UdmhXomI5pCr)JlvfzT z(;b&NEL&A-fkvE%GOL9&OfKCU`QEnbLhs3=TS4rN)zPjrp^P$sV-r{j*whEdS*#<~81GMoYuXV0G6H8Rv&5qeLI?4JQ{VK>L)5=-u&uFoyy4hDYtIjAsvslO4BN*?q#B+?%LCo!w4 zJKrQ*%DyLODw+|B|JiViYjD55y#4LsFnP!|L^wvZM!?Sb({Tnrx1WB&ZcqX#f_&#& zPzda^#mp3^X6D&st=|wxe2|<=VTzM#>m|(Ft7S7i+Bs15zI?m94HKkAu>HXTZFVA( zdXJv4W{0r1Zx7S2l$;b7NP%SN+1PM$9ePn=ow_ePdrb`cus|!WFIV#K+Xy2lsi8GN zAV?6J3L&DYV0=CV41mEXs5qmzADjTd4g;aRG3@BmED$`D1qsI6V&G_w zUvLTuv!%FEJTaVT_Fv43gzEcH!ZCbk0-rNdI%OBcXVb4+Von zBYwFcNHzyg_p`R1!6BZ(XmJ5fj2ij^27|?_sH$Nv|3VA~t@&U4|20AdB>x%0$%}wc z0WJ`l3b28x002tUCFHV(iWb+u(W)!|cRxXDwq~SOd12y`jT^11Q0~sqEX^bE9)v@y z?Wm@R2Uvd*!`3E2cmZtNwtO=a61ZU1{ob zHvVC@weG{NjAcI+ozH)(P6oF+c_m7iWUhPO7(sO!HNM7wrHzNYJC-2uvhmiArZ=*~ zN#y7)*o^EYG~H<pyqJ=vZWX*H`r+Ez z%Q!2F=$Y0lGM2^!k!&MQp|x=@(9t z$AVBCa;@Kw_FM-jplz2ZF9>um40XA{+jGl8)gDFM-RU()!QkIp3H6`kQ|(mGv3qTo zRIHzo*Itl)4bR(VaA%7?D)l*j6^n~l)OO@N#XvAOXiGV1<*v!a^x`Gk!=&9o53!ey zGHNDUGvvs@eGmR)sSvF{R5|HM!&0o+c!N#Tj;#$+Lzdj1F8H2qzNvx`W%`!EI(zN* z;r;3T$x4x!aYn44)zO_%5#?PE9@9VwaSq+Lv$iA1#n|NrH^9FD&n3#|+$)_8ShL%^ VZkYQnRT-t*oz}jH@Reeu{srR%*l+*< literal 0 HcmV?d00001