[ci] Upload docs and javadocs to https://docs.pmd-code.org

This commit is contained in:
Andreas Dangel
2020-04-14 17:19:13 +02:00
parent 61321c88f1
commit 727c398326
3 changed files with 105 additions and 2 deletions

View File

@ -1,10 +1,11 @@
#!/bin/bash
#!/usr/bin/env bash
set -e
source .travis/logger.sh
source .travis/common-functions.sh
source .travis/github-releases-api.sh
source .travis/sourceforge-api.sh
source .travis/pmd-code-api.sh
function main() {
VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec)
@ -15,7 +16,7 @@ function main() {
# The docs should appear under "docs/pages/rules/..." for each language
# With this profile, also the checks are executed (e.g. DeadLinksChecker).
#
./mvnw clean verify -Dmaven.test.skip=true -Dmaven.javadoc.skip=true -P generate-rule-docs
./mvnw clean verify -Dmaven.test.skip=true -P generate-rule-docs
if ! travis_isPush; then
log_info "Not publishing site, since this is not a push!"
@ -31,9 +32,17 @@ function main() {
# Deploy to sourceforge files
sourceforge_uploadFile "${VERSION}" "docs/pmd-doc-${VERSION}.zip"
# Deploy doc to https://docs.pmd-code.org/pmd-doc-${VERSION}/
pmd_code_uploadDocumentation "${VERSION}" "docs/pmd-doc-${VERSION}.zip"
# Deploy javadoc to https://docs.pmd-code.org/apidocs/*/${VERSION}/
pmd_code_uploadJavadoc "${VERSION}" "$(pwd)"
if [[ "${VERSION}" == *-SNAPSHOT && "${TRAVIS_BRANCH}" == "master" ]]; then
# only for snapshot builds from branch master
pmd_code_createSymlink "${VERSION}" "snapshot"
# update github pages https://pmd.github.io/pmd/
publish_to_github_pages
# rsync site to https://pmd.sourceforge.io/snapshot
@ -44,6 +53,14 @@ function main() {
if [[ "${VERSION}" != *-SNAPSHOT && "${TRAVIS_TAG}" != "" ]]; then
log_info "This is a release documentation build for pmd ${VERSION}"
# documentation is already uploaded to https://docs.pmd-code.org/pmd-doc-${VERSION}
pmd_code_createSymlink "${VERSION}" "latest"
# remove old doc and point to the new version
pmd_code_removeDocumentation "${VERSION}-SNAPSHOT"
pmd_code_createSymlink "${VERSION}" "${VERSION}-SNAPSHOT"
# remove old javadoc
pmd_code_removeJavadoc "${VERSION}-SNAPSHOT"
# Deploy to github releases
gh_releases_getLatestDraftRelease
GH_RELEASE="$RESULT"

84
.travis/pmd-code-api.sh Normal file
View File

@ -0,0 +1,84 @@
#
# The functions here require the following scripts:
# .travis/logger.sh
#
PMD_CODE_SSH_USER=pmd
PMD_CODE_DOCS_PATH=/docs.pmd-code.org/
function pmd_code_uploadDocumentation() {
local pmdVersion="$1"
local filename="$2"
local basefilename="$(basename $filename)"
log_debug "$FUNCNAME pmdVersion=$pmdVersion filename=$filename"
scp "${filename}" ${PMD_CODE_SSH_USER}@pmd-code.org:${PMD_CODE_DOCS_PATH}
ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd ${PMD_CODE_DOCS_PATH} && \
unzip -qo ${basefilename} && \
rm ${basefilename}"
log_info "Docs updated: https://docs.pmd-code.org/pmd-doc-${pmdVersion}/"
}
function pmd_code_removeDocumentation() {
local pmdVersion="$1"
log_debug "$FUNCNAME pmdVersion=$pmdVersion"
ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd ${PMD_CODE_DOCS_PATH} && \
rm -rf pmd-doc-${pmdVersion}/"
log_info "Removed docs: https://docs.pmd-code.org/pmd-doc-${pmdVersion}/"
}
function pmd_code_createSymlink() {
local pmdVersion="$1"
local name="$2"
log_debug "$FUNCNAME pmdVersion=$pmdVersion name=$name"
ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd ${PMD_CODE_DOCS_PATH} && \
rm -f $name && \
ln -s pmd-doc-${pmdVersion} $name"
log_info "Symlink created: https://docs.pmd-code.org/$name/ -> https://docs.pmd-code.org/pmd-doc-${pmdVersion}/"
}
function pmd_code_uploadJavadoc() {
local pmdVersion="$1"
local basePath="$2"
log_debug "$FUNCNAME pmdVersion=$pmdVersion basePath=$basePath"
for i in ${basePath}/*/target/*-javadoc.jar; do
pmd_code_uploadJavadocModule "$pmdVersion" "$i"
done
# make sure https://docs.pmd-code.org/apidocs/ shows directory index
ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd ${PMD_CODE_DOCS_PATH}/apidocs && \
echo 'Options +Indexes' > .htaccess"
log_info "Directory index enabled for https://docs.pmd-code.org/apidocs/"
}
function pmd_code_uploadJavadocModule() {
local pmdVersion="$1"
local moduleJavadocJar="$2"
local moduleJavadocJarBasename="$(basename $moduleJavadocJar)"
local module=${moduleJavadocJarBasename%%-${pmdVersion}-javadoc.jar}
log_debug "$FUNCNAME pmdVersion=$pmdVersion moduleJavadocJar=$moduleJavadocJar module=$module"
scp "$moduleJavadocJar" ${PMD_CODE_SSH_USER}@pmd-code.org:${PMD_CODE_DOCS_PATH}
ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd ${PMD_CODE_DOCS_PATH} && \
mkdir -p apidocs/${module}/${pmdVersion} && \
unzip -qo -d apidocs/${module}/${pmdVersion} ${moduleJavadocJarBasename} && \
rm ${moduleJavadocJarBasename}"
log_info "JavaDoc for $module uploaded: https://docs.pmd-code.org/apidocs/${module}/${pmdVersion}/"
}
function pmd_code_removeJavadoc() {
local pmdVersion="$1"
log_debug "$FUNCNAME pmdVersion=$pmdVersion"
ssh ${PMD_CODE_SSH_USER}@pmd-code.org "cd ${PMD_CODE_DOCS_PATH} && \
rm -rf apidocs/*/${pmdVersion}"
log_info "Removed Javadoc: https://docs.pmd-code.org/apidocs/*/${pmdVersion}/ is gone"
}

View File

@ -61,3 +61,5 @@ echo 'web.sourceforge.net ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2uifHZbNexw6cXbyg1
echo 'web.sourceforge.net ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCwsY6sZT4MTTkHfpRzYjxG7mnXrGL74RCT2cO/NFvRrZVNB5XNwKNn7G5fHbYLdJ6UzpURDRae1eMg92JG0+yo=' >> "$HOME/.ssh/known_hosts"
echo 'web.sourceforge.net ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIOQD35Ujalhh+JJkPvMckDlhu4dS7WH6NsOJ15iGCJLC' >> "$HOME/.ssh/known_hosts"
# add pmd-code.org (ssh-keyscan pmd-code.org)
echo 'pmd-code.org ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDVsIeF6xU0oPb/bMbxG1nU1NDyBpR/cBEPZcm/PuJwdI9B0ydPHA6FysqAnt32fNFznC2SWisnWyY3iNsP3pa8RQJVwmnnv9OboGFlW2/61o3iRyydcpPbgl+ADdt8iU9fmMI7dC04UqgHGBoqOwVNna9VylTjp5709cK2qHnwU450F6YcOEiOKeZfJvV4PmpJCz/JcsUVqft6StviR31jKnqbnkZdP8qNoTbds6WmGKyXkhHdLSZE7X1CFQH28tk8XFqditX93ezeCiThFL7EleDexV/3+2+cs5878sDMUMzHS5KShTjkxzhHaodhtIEdNesinq/hOPbxAGkQ0FbD' >> $HOME/.ssh/known_hosts