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

Publish documentation snapshot only if necessary #1610

Merged
merged 3 commits into from
Sep 29, 2018
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
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,4 @@ jobs:
env:
# GRGIT_USER
- secure: PwwKcsVdukfzvDBHmdajhMsIVHSbPt+lorgibpRXImBt+C4XHlaz/Z78Bq8jtkDvrXb+DTSfSGvAxg1IBM+rtCzrYb5DAqq+OfuG9Uu6FDTnkIOHs5Gii7pAfT0+W31Oj76OgiCAXX+p8lbFTchz6ope5zVYEpSlAe7aXCVTGM0=
script: ./gradlew --scan gitPublishPush
script: ./src/publishDocumentationSnapshotOnlyIfNecessary.sh
3 changes: 3 additions & 0 deletions gradle/gh-pages.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ task prepareDocsForUploadToGhPages(type: Copy) {
dependsOn 'aggregateJavadocs', ':documentation:asciidoctor'
outputs.dir docsDir

from("${project(':documentation').buildDir}") {
include 'published-checksum.txt'
}
from("${project(':documentation').buildDir}/asciidoc") {
include 'user-guide/**'
include 'release-notes/**'
Expand Down
33 changes: 33 additions & 0 deletions src/publishDocumentationSnapshotOnlyIfNecessary.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

readonly current='documentation/build/current-checksum.txt'
readonly published='documentation/build/published-checksum.txt'
readonly github_pages_url='https://raw.githubusercontent.com/junit-team/junit5/gh-pages/docs/snapshot/published-checksum.txt'

#
# always generate current sums
#
echo "Generating checksum file..."
md5sum documentation/documentation.gradle > "${current}"
md5sum $(find documentation/src/ -type f) >> "${current}"
md5sum $(find . -wholename '**/src/main/java/*.java') >> "${current}"
stat "${current}"
md5sum "${current}"

#
# compare current with published sums
#
curl --silent --output "${published}" "${github_pages_url}"
if cmp --silent "${current}" "${published}" ; then
#
# no changes detected: we're done
#
echo "Already published documentation with same source checksum."
else
#
# update checksum file and trigger new documentation build and upload
#
echo "Creating and publishing documentation..."
cp --force "${current}" "${published}"
./gradlew --scan gitPublishPush
fi