diff --git a/.travis.yml b/.travis.yml index c7968bbd5c..6874e5cc62 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,8 +13,6 @@ env: matrix: fast_finish: true - allow_failures: - - os: windows include: - name: "linux - mvn deploy" os: linux @@ -49,22 +47,6 @@ script: source .travis/build-$BUILD.sh after_success: true -before_deploy: true -deploy: - provider: releases - api_key: ${GITHUB_OAUTH_TOKEN} - file_glob: true - file: - - pmd-dist/target/pmd-*.zip - - docs/pmd-doc-*.zip - skip_cleanup: true - draft: true - on: - tags: true - repo: pmd/pmd - condition: "${TRAVIS_SECURE_ENV_VARS} = true && ${BUILD} != sonar && ${BUILD} != coveralls && ${TRAVIS_OS_NAME} = linux" -after_deploy: bash .travis/release.sh - notifications: webhooks: urls: diff --git a/.travis/build-deploy.sh b/.travis/build-deploy.sh index ea6223f197..4552e9b237 100755 --- a/.travis/build-deploy.sh +++ b/.travis/build-deploy.sh @@ -59,6 +59,63 @@ elif travis_isPush; then log_info "This is a release build for tag ${TRAVIS_TAG}" echo -e "\n\n" ./mvnw deploy -Possrh,sign,pmd-release $MVN_BUILD_FLAGS + echo -e "\n\n" + + # Deploy to ossrh has already been done with the usual maven build + + # Deploy to github releases + RELEASE_ID=$(curl -s -H "Authorization: token ${GITHUB_OAUTH_TOKEN}" 'https://api.github.com/repos/pmd/pmd/releases?per_page=1'|jq ".[0].id") + RELEASE_DATA=$(curl -s -H "Authorization: token ${GITHUB_OAUTH_TOKEN}" "https://api.github.com/repos/pmd/pmd/releases/${RELEASE_ID}") + DRAFT=$(echo "$RELEASE_DATA"|jq ".draft") + if [ "$DRAFT" != "true" ]; then + REQUEST=$(cat < release-edit-request.json < .git/info/sparse-checkout + echo "/sitemap.xml" >> .git/info/sparse-checkout + git pull --depth=1 origin master + log_info "Copying documentation from ../docs/pmd-doc-${VERSION}/ to pmd-${VERSION}/ ..." + rsync -ah --stats ../docs/pmd-doc-${VERSION}/ pmd-${VERSION}/ + git status + echo "Executing: git add pmd-${VERSION}" + git add pmd-${VERSION} + echo "Executing: git commit..." + git commit -q -m "Added pmd-${VERSION}" + + log_info "Copying pmd-${VERSION} to latest ..." + git rm -qr latest + cp -a pmd-${VERSION} latest + echo "Executing: git add latest" + git add latest + echo "Executing: git commit..." + git commit -q -m "Copying pmd-${VERSION} to latest" + + log_info "Generating sitemap.xml" + ../.travis/sitemap_generator.sh > sitemap.xml + echo "Executing: git add sitemap.xml" + git add sitemap.xml + echo "Executing: git commit..." + git commit -q -m "Generated sitemap.xml" + + echo "Executing: git push origin master" + 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 + ) +fi + + +# Deploy to sourceforge files ( # disable fast fail, exit immediately, in this subshell set +e @@ -51,9 +173,9 @@ ls -lh pmd-doc-${VERSION}.zip if [[ "${TRAVIS_TAG}" != "" || "${VERSION}" == *-SNAPSHOT ]]; then echo -e "\n\n" log_info "Uploading pmd doc distribution to sourceforge..." - ../.travis/travis_wait "rsync -avh pmd-doc-${VERSION}.zip ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/" + .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 pmd-doc-${VERSION}.zip!" + 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" @@ -61,10 +183,10 @@ ls -lh pmd-doc-${VERSION}.zip fi # rsync site to pmd.sourceforge.net/snapshot - if [[ "${VERSION}" == *-SNAPSHOT && "${TRAVIS_BRANCH}" == "master" ]] && has_docs_change; then + 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 pmd-doc-${VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/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 @@ -81,14 +203,14 @@ ls -lh pmd-doc-${VERSION}.zip # Push the generated site to gh-pages branch # only for snapshot builds from branch master # -if [[ "${VERSION}" == *-SNAPSHOT && "${TRAVIS_BRANCH}" == "master" ]] && has_docs_change; then +if [[ "${VERSION}" == *-SNAPSHOT && "${TRAVIS_BRANCH}" == "master" ]]; then echo -e "\n\n" log_info "Pushing the new site to github pages..." git clone --branch gh-pages --depth 1 git@github.com:pmd/pmd.git pmd-gh-pages # clear the files first rm -rf pmd-gh-pages/* # copy the new site - cp -a pmd-doc-${VERSION}/* pmd-gh-pages/ + cp -a docs/pmd-doc-${VERSION}/* pmd-gh-pages/ ( cd pmd-gh-pages git config user.name "Travis CI (pmd-bot)" @@ -104,4 +226,3 @@ TRAVIS_COMMIT_RANGE=${TRAVIS_COMMIT_RANGE}" ) fi -popd diff --git a/.travis/common-functions.sh b/.travis/common-functions.sh index 57b5c1390f..e46731feb6 100755 --- a/.travis/common-functions.sh +++ b/.travis/common-functions.sh @@ -53,14 +53,3 @@ function travis_isWindows() { return 1 fi } - - -function has_docs_change() { - if [[ $(git diff --name-only ${TRAVIS_COMMIT_RANGE}) = *"docs/"* ]]; then - log_info "Checking for changes in docs/ (TRAVIS_COMMIT_RANGE=${TRAVIS_COMMIT_RANGE}): changes found" - return 0 - else - log_info "Checking for changes in docs/ (TRAVIS_COMMIT_RANGE=${TRAVIS_COMMIT_RANGE}): no changes" - return 1 - fi -} diff --git a/.travis/release.sh b/.travis/release.sh deleted file mode 100755 index 5c199336fa..0000000000 --- a/.travis/release.sh +++ /dev/null @@ -1,135 +0,0 @@ -#!/bin/bash -set -e - -source .travis/logger.sh - -echo "BUILD: $BUILD" -RELEASE_VERSION=$(./mvnw -q -Dexec.executable="echo" -Dexec.args='${project.version}' --non-recursive org.codehaus.mojo:exec-maven-plugin:1.5.0:exec | tail -1) -echo "RELEASE_VERSION: $RELEASE_VERSION" - -if [ "${BUILD}" = "deploy" ]; then - -# Deploy to ossrh has already been done with the usual build. See build-deploy.sh - -( - # disable fast fail, exit immediately, in this subshell - set +e - - # The site has been built before, the files have already been uploaded to sourceforge. - # Since this is a release, making the binary the new default file... - log_info "Selecting pmd-bin-${RELEASE_VERSION} as default on sourceforge.net..." - curl -H "Accept: application/json" -X PUT -d "default=windows&default=mac&default=linux&default=bsd&default=solaris&default=others" \ - -d "api_key=${PMD_SF_APIKEY}" https://sourceforge.net/projects/pmd/files/pmd/${RELEASE_VERSION}/pmd-bin-${RELEASE_VERSION}.zip - if [ $? -ne 0 ]; then - log_error "Couldn't select latest binary as default on sourceforge.net" - else - log_info "pmd-bin-${RELEASE_VERSION} is now the default download option." - fi - true -) - -fi - - -if [ "${BUILD}" = "doc" ]; then - -echo -e "\n\n" -log_info "Adding the new doc to pmd.github.io..." -# clone pmd.github.io. Note: This uses the ssh key setup earlier -# In order to speed things up, we use a sparse checkout - no need to checkout all directories here -mkdir pmd.github.io -( - cd pmd.github.io - git init - git config user.name "Travis CI (pmd-bot)" - git config user.email "andreas.dangel+pmd-bot@adangel.org" - git config core.sparsecheckout true - git remote add origin git@github.com:pmd/pmd.github.io.git - echo "/latest/" > .git/info/sparse-checkout - echo "/sitemap.xml" >> .git/info/sparse-checkout - git pull --depth=1 origin master - log_info "Copying documentation from ../docs/pmd-doc-${RELEASE_VERSION}/ to pmd-${RELEASE_VERSION}/ ..." - rsync -ah --stats ../docs/pmd-doc-${RELEASE_VERSION}/ pmd-${RELEASE_VERSION}/ - git status - echo "Executing: git add pmd-${RELEASE_VERSION}" - git add pmd-${RELEASE_VERSION} - echo "Executing: git commit..." - git commit -q -m "Added pmd-${RELEASE_VERSION}" - - log_info "Copying pmd-${RELEASE_VERSION} to latest ..." - git rm -qr latest - cp -a pmd-${RELEASE_VERSION} latest - echo "Executing: git add latest" - git add latest - echo "Executing: git commit..." - git commit -q -m "Copying pmd-${RELEASE_VERSION} to latest" - - log_info "Generating sitemap.xml" - ../.travis/sitemap_generator.sh > sitemap.xml - echo "Executing: git add sitemap.xml" - git add sitemap.xml - echo "Executing: git commit..." - git commit -q -m "Generated sitemap.xml" - - echo "Executing: git push origin master" - git push origin master -) - -# renders, and skips the first 6 lines - the Jekyll front-matter -RENDERED_RELEASE_NOTES=$(bundle exec .travis/render_release_notes.rb docs/pages/release_notes.md | tail -n +6) - -# Assumes, the release has already been created by travis github releases provider -RELEASE_ID=$(curl -s -H "Authorization: token ${GITHUB_OAUTH_TOKEN}" https://api.github.com/repos/pmd/pmd/releases/tags/pmd_releases/${RELEASE_VERSION}|jq ".id") -RELEASE_NAME="PMD ${RELEASE_VERSION} ($(date -u +%d-%B-%Y))" -RELEASE_BODY="$RENDERED_RELEASE_NOTES" -RELEASE_BODY="${RELEASE_BODY//'\'/\\\\}" -RELEASE_BODY="${RELEASE_BODY//$'\r'/}" -RELEASE_BODY="${RELEASE_BODY//$'\n'/\\r\\n}" -RELEASE_BODY="${RELEASE_BODY//'"'/\\\"}" -cat > release-edit-request.json <