From d78df8ddb21ca96d8c4e78c1347b22d3d1709b00 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Karnok?= Date: Sat, 5 May 2018 23:15:16 +0200 Subject: [PATCH 1/8] Experiment: auto publish JavaDocs --- .travis.yml | 1 + gradle/push.sh | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 100 insertions(+) create mode 100644 gradle/push.sh diff --git a/.travis.yml b/.travis.yml index 972c0c4cc0..c26524bc7b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,7 @@ script: gradle/buildViaTravis.sh # Code coverage after_success: - bash <(curl -s https://codecov.io/bash) + - bash gradle/push.sh # cache between builds cache: diff --git a/gradle/push.sh b/gradle/push.sh new file mode 100644 index 0000000000..e03bc4c428 --- /dev/null +++ b/gradle/push.sh @@ -0,0 +1,99 @@ +#!/bin/bash +# ---------------------------------------------------------- +# Automatically push back the generated JavaDocs to gh-pages +# ---------------------------------------------------------- +# based on https://gist.github.com/willprice/e07efd73fb7f13f917ea + +# specify the common address for the repository +targetRepo=github.com/ReactiveX/RxJava.git +# ======================================================================= + +# only for main pushes, for now + if [ "$TRAVIS_PULL_REQUEST" == "true" ]; then + echo -e "Pull request detected, skipping JavaDocs pushback." + exit 0 +fi + +// get the current build tag if any +buildTag="$TRAVIS_TAG" + +if [ "$buildTag" == ""]; then + buildTag = "snapshot" +else + buildTag = "${buildTag:1}" +fi + +echo -e "JavaDocs pushback for tag: $buildTag" + +# check if the token is actually there +if [ "$GITHUB_TOKEN" == "" ]; then + echo -e "No access to GitHub, skipping JavaDocs pushback." + exit 0 +fi + +# prepare the git information +git config --global user.email "travis@travis-ci.org" +git config --global user.name "Travis CI" + +# setup the remote +git remote add origin-pages https://${GITHUB_TOKEN}@${targetRepo} > /dev/null 2>&1 + +# stash changes due to chmod +git stash + +# get the gh-pages +git fetch --all +git branch -a +git checkout -b gh-pages origin-pages/gh-pages + +# for snapshots, only replace the 2.x/javadoc/snapshot directory +#if [ "$buildTag" != "snapshot" ]; then +# for now +if [ "$buildTag" != "" ]; then + # for releases, add a new directory with the new version + # and carefully replace the others + + # 1.) main javadoc + # ---------------- + # remove the io subdir + rm -r javadoc/io + # remove the html files + rm javadoc/*.html + # copy the new doc + yes | cp -rf ./build/docs/javadoc/ javadoc/ + + # 2.) 2.x javadoc + # remove the io subdir + rm -r 2.x/javadoc/io + # remove the html files + rm 2.x/javadoc/*.html + # copy the new doc + yes | cp -rf ./build/docs/javadoc/ 2.x/javadoc/ +fi + +# 3.) create a version/snapshot specific copy of the docs +# clear the existing tag +rm -r 2.x/javadoc/${buildTag} +# copy the new doc +yes | cp -rf ./build/docs/javadoc/ 2.x/javadoc/${buildTag}/ + + +# stage all changed and new files +git add *.html +git add *.css +git add *.js +git add javadoc/package-list + +# remove tracked but deleted files +git add -u + +# commit all +git commit --message "Travis build: $TRAVIS_BUILD_NUMBER for $buildTag" + + +# push it +#git push --quiet --set-upstream origin-pages gh-pages +# just print the result for now +find . + +# we are done From 953c0e2ab447ddaaee1279c8d1a7cdf32a297ee7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Karnok?= Date: Sat, 5 May 2018 23:43:49 +0200 Subject: [PATCH 2/8] Fix script error, add logging --- gradle/push.sh | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/gradle/push.sh b/gradle/push.sh index e03bc4c428..85340613c1 100644 --- a/gradle/push.sh +++ b/gradle/push.sh @@ -14,7 +14,7 @@ targetRepo=github.com/ReactiveX/RxJava.git exit 0 fi -// get the current build tag if any +# get the current build tag if any buildTag="$TRAVIS_TAG" if [ "$buildTag" == ""]; then @@ -36,12 +36,15 @@ git config --global user.email "travis@travis-ci.org" git config --global user.name "Travis CI" # setup the remote +echo -e "Adding the target repository to git" git remote add origin-pages https://${GITHUB_TOKEN}@${targetRepo} > /dev/null 2>&1 # stash changes due to chmod +echo -e "Stashing any local non-ignored changes" git stash # get the gh-pages +echo -e "Update branches and checking out gh-pages" git fetch --all git branch -a git checkout -b gh-pages origin-pages/gh-pages @@ -56,44 +59,61 @@ if [ "$buildTag" != "" ]; then # 1.) main javadoc # ---------------- # remove the io subdir + echo -e "Removing javadoc/io" rm -r javadoc/io + # remove the html files + echo -e "Removing javadoc/*.html" rm javadoc/*.html + # copy the new doc + echo -e "Copying to javadoc/" yes | cp -rf ./build/docs/javadoc/ javadoc/ # 2.) 2.x javadoc # remove the io subdir + echo -e "Removing 2.x/javadoc/io" rm -r 2.x/javadoc/io + # remove the html files + echo -e "Removing 2.x/javadoc/*.html" rm 2.x/javadoc/*.html + # copy the new doc + echo -e "Copying to 2.x/javadoc/" yes | cp -rf ./build/docs/javadoc/ 2.x/javadoc/ fi # 3.) create a version/snapshot specific copy of the docs # clear the existing tag +echo -e "Removing to 2.x/javadoc/${buildTag}" rm -r 2.x/javadoc/${buildTag} # copy the new doc +echo -e "Copying to 2.x/javadoc/${buildTag}" yes | cp -rf ./build/docs/javadoc/ 2.x/javadoc/${buildTag}/ # stage all changed and new files +echo -e "Staging new files" git add *.html git add *.css git add *.js git add javadoc/package-list # remove tracked but deleted files +echo -e "Removing deleted files" git add -u # commit all +echo -e "commit Travis build: $TRAVIS_BUILD_NUMBER for $buildTag" git commit --message "Travis build: $TRAVIS_BUILD_NUMBER for $buildTag" # push it +echo -e "Pushing back changes." #git push --quiet --set-upstream origin-pages gh-pages # just print the result for now -find . +find -name "*.html" # we are done +echo -e "JavaDocs pushback complete." \ No newline at end of file From b9dfce61a7e0ed9e7104ceef4011afeb98c3617d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Karnok?= Date: Sat, 5 May 2018 23:56:49 +0200 Subject: [PATCH 3/8] Have all package-list staged --- gradle/push.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gradle/push.sh b/gradle/push.sh index 85340613c1..bd5e88f684 100644 --- a/gradle/push.sh +++ b/gradle/push.sh @@ -88,6 +88,7 @@ fi # clear the existing tag echo -e "Removing to 2.x/javadoc/${buildTag}" rm -r 2.x/javadoc/${buildTag} + # copy the new doc echo -e "Copying to 2.x/javadoc/${buildTag}" yes | cp -rf ./build/docs/javadoc/ 2.x/javadoc/${buildTag}/ @@ -98,7 +99,7 @@ echo -e "Staging new files" git add *.html git add *.css git add *.js -git add javadoc/package-list +git add *package-list* # remove tracked but deleted files echo -e "Removing deleted files" From 3bde88c1324f95b5ded213ff9092e40d78812ef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Karnok?= Date: Sun, 6 May 2018 00:08:59 +0200 Subject: [PATCH 4/8] Fix another scripting error --- gradle/push.sh | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gradle/push.sh b/gradle/push.sh index bd5e88f684..71ff823c96 100644 --- a/gradle/push.sh +++ b/gradle/push.sh @@ -9,18 +9,19 @@ targetRepo=github.com/ReactiveX/RxJava.git # ======================================================================= # only for main pushes, for now - if [ "$TRAVIS_PULL_REQUEST" == "true" ]; then +if [ "$TRAVIS_PULL_REQUEST" == "true" ]; then echo -e "Pull request detected, skipping JavaDocs pushback." exit 0 fi # get the current build tag if any buildTag="$TRAVIS_TAG" +echo -e "Travis tag: '$buildTag'" -if [ "$buildTag" == ""]; then - buildTag = "snapshot" +if [ "$buildTag" == "" ]; then + buildTag="snapshot" else - buildTag = "${buildTag:1}" + buildTag="${buildTag:1}" fi echo -e "JavaDocs pushback for tag: $buildTag" From b8c212f5878f5ee45ec656d538290cefe3880f45 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Karnok?= Date: Sun, 6 May 2018 00:33:54 +0200 Subject: [PATCH 5/8] Fix copy paths --- gradle/push.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle/push.sh b/gradle/push.sh index 71ff823c96..e8109609ec 100644 --- a/gradle/push.sh +++ b/gradle/push.sh @@ -69,7 +69,7 @@ if [ "$buildTag" != "" ]; then # copy the new doc echo -e "Copying to javadoc/" - yes | cp -rf ./build/docs/javadoc/ javadoc/ + yes | cp -rf ./build/docs/javadoc/ . # 2.) 2.x javadoc # remove the io subdir @@ -82,7 +82,7 @@ if [ "$buildTag" != "" ]; then # copy the new doc echo -e "Copying to 2.x/javadoc/" - yes | cp -rf ./build/docs/javadoc/ 2.x/javadoc/ + yes | cp -rf ./build/docs/javadoc/ 2.x/ fi # 3.) create a version/snapshot specific copy of the docs From 1ad088ac2936a65d223bbf669e84412f5ebc68a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Karnok?= Date: Sun, 6 May 2018 00:54:02 +0200 Subject: [PATCH 6/8] Real pushback on snapshot builds. --- gradle/push.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/gradle/push.sh b/gradle/push.sh index e8109609ec..b2fbe201fc 100644 --- a/gradle/push.sh +++ b/gradle/push.sh @@ -50,10 +50,8 @@ git fetch --all git branch -a git checkout -b gh-pages origin-pages/gh-pages -# for snapshots, only replace the 2.x/javadoc/snapshot directory -#if [ "$buildTag" != "snapshot" ]; then -# for now -if [ "$buildTag" != "" ]; then +# releases should update 2 extra locations +if [ "$buildTag" != "snapshot" ]; then # for releases, add a new directory with the new version # and carefully replace the others @@ -110,12 +108,13 @@ git add -u echo -e "commit Travis build: $TRAVIS_BUILD_NUMBER for $buildTag" git commit --message "Travis build: $TRAVIS_BUILD_NUMBER for $buildTag" +# debug file list +#find -name "*.html" # push it echo -e "Pushing back changes." -#git push --quiet --set-upstream origin-pages gh-pages -# just print the result for now -find -name "*.html" +git push --quiet --set-upstream origin-pages gh-pages + # we are done echo -e "JavaDocs pushback complete." \ No newline at end of file From 087910ebb90d7316181cb9e8ff464dc3f101ae6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Karnok?= Date: Sun, 6 May 2018 01:43:44 +0200 Subject: [PATCH 7/8] Pull requests should not trigger snapshot pushbacks --- gradle/push.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/push.sh b/gradle/push.sh index b2fbe201fc..8bd3ef0f87 100644 --- a/gradle/push.sh +++ b/gradle/push.sh @@ -9,7 +9,7 @@ targetRepo=github.com/ReactiveX/RxJava.git # ======================================================================= # only for main pushes, for now -if [ "$TRAVIS_PULL_REQUEST" == "true" ]; then +if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then echo -e "Pull request detected, skipping JavaDocs pushback." exit 0 fi From 2dbecc937c06f2446fd4160a97db8b99228d25e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C3=A1vid=20Karnok?= Date: Sun, 6 May 2018 12:28:26 +0200 Subject: [PATCH 8/8] Rename push.sh to push_javadoc.sh --- .travis.yml | 2 +- gradle/{push.sh => push_javadoc.sh} | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename gradle/{push.sh => push_javadoc.sh} (100%) diff --git a/.travis.yml b/.travis.yml index c26524bc7b..83835caeba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,7 +20,7 @@ script: gradle/buildViaTravis.sh # Code coverage after_success: - bash <(curl -s https://codecov.io/bash) - - bash gradle/push.sh + - bash gradle/push_javadoc.sh # cache between builds cache: diff --git a/gradle/push.sh b/gradle/push_javadoc.sh similarity index 100% rename from gradle/push.sh rename to gradle/push_javadoc.sh