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

release.sh to also publish docs #1274

Merged
merged 1 commit into from
Dec 11, 2020
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
35 changes: 25 additions & 10 deletions scripts/publish-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,24 @@ cd "$(dirname "$0")"
cd ..

version=""
cleanRemoteSite=true
DOCS_FOLDER="docs/generation/.out/remote"
JAVADOC_FOLDER="build/javadoc"
BRANCH_NAME=$(git symbolic-ref -q HEAD)
BRANCH_NAME=${BRANCH_NAME##refs/heads/}
GIT_AUTHOR=$(git --no-pager show -s --format='%an <%ae>' HEAD)

if [ -z "${DRYRUN:-}" ]; then
git="git"
else
git="echo git"
fi

function usage() {
cat << EOF
Run as:
publish-docs.sh - to update the SNAPSHOT version of docs website only
publish-docs.sh {release_version} - to publish docs for a new release version and update the SNAPSHOT version
publish-docs.sh {release_version} [skip_clean_remote_site] - to publish docs for a new release version and update the SNAPSHOT version
EOF
}

Expand All @@ -50,20 +57,23 @@ function clean_up_gh_pages() {

# Enforce JDK8 to keep javadoc format consistent for all versions:
java_version=$(./gradlew --no-daemon -version | grep ^JVM: | awk -F\. '{gsub(/^JVM:[ \t]*/,"",$1); print $1"."$2}')
if [ "$java_version" != "1.8" ]; then
echo "Docs can be published only using Java 1.8, current version: $java_version"
if [ "$java_version" != "11.0" ]; then
echo "Docs can be published only using Java 11, current version: $java_version"
exit 1
fi

if [ "$#" -eq "0" ]; then
echo "Publishing docs website for the SNAPSHOT version only"
elif [ "$#" -eq "1" ]; then
elif [ "$#" -ge "1" ]; then
version="$1"
if ( echo "$version" | grep -Eqv "^\d+\.\d+$" ); then
echo "Release version should match 'major.minor' pattern"
echo "Release version should match 'major.minor' pattern was: $1"
exit 1
fi
echo "Publishing docs website for the release version $version"
if [ "$#" -ge "2" ]; then
cleanRemoteSite=false
fi
else
usage
exit 1
Expand All @@ -76,7 +86,12 @@ clean_up_gh_pages

echo "Generate docs website"
pushd docs/generation
./gradlew --no-daemon clean validateRemoteSite
if $cleanRemoteSite; then
./gradlew --no-daemon clean validateRemoteSite
else
echo "Skipping cleaning remote site"
./gradlew --no-daemon validateRemoteSite
fi
popd
echo "Docs website generated, see ./$DOCS_FOLDER"

Expand Down Expand Up @@ -111,14 +126,14 @@ if [ ! -z "$version" ]; then
fi
echo $files_to_revert | xargs git checkout --

git add * .nojekyll
$git add * .nojekyll
if [ -z "$version" ]; then
git commit --author="$GIT_AUTHOR" -m "Update SNAPSHOT doc website"
$git commit --author="$GIT_AUTHOR" -m "Update SNAPSHOT doc website"
else
git commit --author="$GIT_AUTHOR" -m "Publish docs website $version"
$git commit --author="$GIT_AUTHOR" -m "Publish docs website $version"
fi

git push docs gh-pages
$git push docs gh-pages
popd

# Clean up the state (worktree and temporary branch) after publication of the docs
Expand Down
10 changes: 7 additions & 3 deletions scripts/release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ if ( echo "$version" | grep -q "SNAPSHOT" ); then
fi

echo "Releasing version $version"
version_majorminor="${version%.*}"

if [ -z "${DRYRUN:-}" ]; then
git="git"
Expand All @@ -65,18 +66,18 @@ $git pull
$git log -n1

pushd docs/generation
./gradlew --no-daemon clean validateLocalSite
./gradlew --no-daemon clean validateRemoteSite
popd

sed "s/^version=.*/version=$version/" gradle.properties > gradle.properties.tmp
mv gradle.properties.tmp gradle.properties

for file in docs/antora.yml */docs/antora.yml; do
sed "s/^version:.*/version: '${version%.*}'/" "$file" > "$file.tmp"
sed "s/^version:.*/version: '${version_majorminor}'/" "$file" > "$file.tmp"
mv "$file.tmp" "$file"
done
for file in docs/modules/ROOT/nav.adoc */docs/modules/ROOT/nav.adoc; do
sed "s/^:page-version: .*/:page-version: ${version%.*}/" "$file" > "$file.tmp"
sed "s/^:page-version: .*/:page-version: ${version_majorminor}/" "$file" > "$file.tmp"
mv "$file.tmp" "$file"
done
./scripts/manage-antora-remote-versions.sh "$version"
Expand Down Expand Up @@ -115,3 +116,6 @@ done

$git commit -a -m "Preparing for $nextVersion development"
$git push origin main

# false -> we already did "clean validateRemoteSite" above, no need to clean again
./scripts/publish-docs.sh "$version_majorminor" "false"