[ci] Refactor upload of documentation to sourceforge

This commit is contained in:
Andreas Dangel
2019-11-10 18:35:10 +01:00
parent 839968c95c
commit 226f78bf8a
4 changed files with 41 additions and 49 deletions

View File

@ -51,7 +51,6 @@ elif travis_isPush; then
# Deploy to sourceforge files
sourceforge_uploadFile "${VERSION}" "pmd-dist/target/pmd-bin-${VERSION}.zip"
sourceforge_uploadFile "${VERSION}" "pmd-dist/target/pmd-src-${VERSION}.zip"
sourceforge_selectDefault "${VERSION}"
regression-tester_uploadBaseline

View File

@ -98,58 +98,16 @@ if [[ "${VERSION}" != *-SNAPSHOT && "${TRAVIS_TAG}" != "" ]]; then
git push origin master
)
(
# disable fast fail, exit immediately, in this subshell
set +e
echo -e "\n\n"
log_info "Uploading the new release to pmd.sourceforge.net which serves as an archive..."
.travis/travis_wait "rsync -ah --stats docs/pmd-doc-${VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/pmd-${VERSION}/"
if [ $? -ne 0 ]; then
log_error "Uploading documentation to pmd.sourceforge.net failed..."
log_error "Please upload manually (PMD Version: ${VERSION})"
else
log_success "The documentation is now available under http://pmd.sourceforge.net/pmd-${VERSION}/"
fi
true
)
sourceforge_rsyncSnapshotDocumentation "${VERSION}" "pmd-${VERSION}"
fi
# Deploy to sourceforge files
(
# disable fast fail, exit immediately, in this subshell
set +e
if [[ "${TRAVIS_TAG}" != "" || "${VERSION}" == *-SNAPSHOT ]]; then
echo -e "\n\n"
log_info "Uploading pmd doc distribution to sourceforge..."
.travis/travis_wait "rsync -avh docs/pmd-doc-${VERSION}.zip ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/"
if [ $? -ne 0 ]; then
log_error "Couldn't upload docs/pmd-doc-${VERSION}.zip!"
log_error "Please upload manually: https://sourceforge.net/projects/pmd/files/pmd/"
else
log_success "Successfully uploaded pmd-doc-${VERSION}.zip to sourceforge"
fi
fi
# rsync site to pmd.sourceforge.net/snapshot
if [[ "${VERSION}" == *-SNAPSHOT && "${TRAVIS_BRANCH}" == "master" ]]; then
echo -e "\n\n"
log_info "Uploading snapshot site to pmd.sourceforge.net/snapshot..."
.travis/travis_wait "rsync -ah --stats --delete docs/pmd-doc-${VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/snapshot/"
if [ $? -ne 0 ]; then
log_error "Couldn't upload the snapshot documentation. It won't be current on http://pmd.sourceforge.net/snapshot/"
else
log_success "Successfully uploaded snapshot documentation: http://pmd.sourceforge.net/snapshot/"
fi
fi
true
)
sourceforge_uploadFile "${VERSION}" "docs/pmd-doc-${VERSION}.zip"
# rsync site to https://pmd.sourceforge.io/snapshot
if [[ "${VERSION}" == *-SNAPSHOT && "${TRAVIS_BRANCH}" == "master" ]]; then
sourceforge_rsyncSnapshotDocumentation "${VERSION}" "snapshot"
fi

View File

@ -4,6 +4,7 @@ set -e
source .travis/logger.sh
source .travis/common-functions.sh
source .travis/github-releases-api.sh
source .travis/sourceforge-api.sh
VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec)
log_info "PMD Release ${VERSION}"
@ -24,3 +25,4 @@ gh_releases_getLatestDraftRelease
GH_RELEASE="$RESULT"
gh_release_publishRelease "$GH_RELEASE"
sourceforge_selectDefault "${VERSION}"

View File

@ -131,3 +131,36 @@ function sourceforge_selectDefault() {
# restore errexit state
eval "$errexitstate"
}
#
# Rsyncs the complete documentation to sourceforge.
#
# Note: This function always succeeds, even if the upload fails.
# In that case, just a error logging is provided.
#
function sourceforge_rsyncSnapshotDocumentation() {
local pmdVersion="$1"
local targetPath="$2"
log_debug "$FUNCNAME pmdVersion=$pmdVersion targetPath=$targetPath"
local targetUrl="https://pmd.sourceforge.io/${targetPath}/"
local errexitstate="$(shopt -po errexit)"
set +e # disable errexit
(
# This handler is called if any command fails
function upload_failed() {
log_error "Couldn't upload the documentation. It won't be current on ${targetUrl}"
}
# exit subshell after trap
set -e
trap upload_failed ERR
log_info "Uploading documentation to ${targetUrl}..."
.travis/travis_wait "rsync -ah --stats --delete docs/pmd-doc-${VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/snapshot/"
log_success "Successfully uploaded documentation: ${targetUrl}"
)
# restore errexit state
eval "$errexitstate"
}