New travis build scripts

*   one for pull requests
*   one for pushes
*   one for releases
This commit is contained in:
Andreas Dangel 2017-02-24 20:05:05 +01:00
parent a37381e756
commit a0fe5222ad
5 changed files with 62 additions and 29 deletions

View File

@ -19,25 +19,25 @@ before_script:
- '[ "${TRAVIS_SECURE_ENV_VARS}" = "true" ] && [ "${TRAVIS_PULL_REQUEST}" = "false" ] && SHOULD_DEPLOY=yes || ( [ "${SHOULD_DEPLOY}" != "yes" ] && echo "Skipping Deploy" )'
- export SHOULD_DEPLOY
script:
- '[ "${SHOULD_DEPLOY}" = "yes" ] && mvn deploy --settings .travis/travis-settings.xml || ( [ "${SHOULD_DEPLOY}" != "yes" ] && echo "Skipping Deploy" )'
- '[ "${SHOULD_DEPLOY}" = "yes" ] || mvn verify'
- '[ "${SHOULD_DEPLOY}" = "yes" ] && mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarqube.com -Dsonar.login=${SONAR_TOKEN} || ( [ "${SHOULD_DEPLOY}" != "yes" ] && echo "Skipping Sonar" )'
- 'if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then bash .travis/build-pull-request.sh; fi'
- 'if [ "$TRAVIS_PULL_REQUEST" = "false" ] && [ "${TRAVIS_SECURE_ENV_VARS}" = "true" ]; then bash .travis/build-push.sh; fi'
after_success: true
before_deploy: true
deploy:
- provider: script
script: bash .travis/travis-deploy.sh
script: bash .travis/release.sh
skip_cleanup: true
on:
tags: true
condition: "${TRAVIS_SECURE_ENV_VARS} = true"
- provider: releases
api_key: ${GITHUB_OAUTH_TOKEN}
file:
- "pmd-dist/target/pmd-*.zip"
- "target/pmd-doc-*.zip"
file_glob: true
file: "pmd-dist/target/pmd-*.zip"
# - "pmd-dist/target/pmd-*.zip"
# - "target/pmd-doc-*.zip"
# TODO : This won't copy the changelog to GitHub
skip_cleanup: true
on:

View File

@ -0,0 +1,3 @@
#!/bin/bash
set -ev
mvn verify -B -V

34
.travis/build-push.sh Normal file
View File

@ -0,0 +1,34 @@
#!/bin/bash
set -ev
VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:2.2:evaluate -Dexpression=project.version|grep -Ev '(^\[|Download\w+:)')
if [[ "$VERSION" == *-SNAPSHOT ]]; then
mvn deploy -Possrh -B -V
else
mvn deploy -Possrh,pmd-release -B -V
fi
mvn site site:stage -Psite
# Uploading pmd distribution to sourceforge
(
cd target
mv staging pmd-doc-${VERSION}
zip -r pmd-doc-${VERSION}.zip pmd-doc-${VERSION}/
)
rsync -avh pmd-dist/target/pmd-*-${VERSION}.zip target/pmd-doc-${VERSION}.zip ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/
rsync -avh src/site/markdown/overview/changelog.md ${PMD_SF_USER}@web.sourceforge.net:/home/frs/project/pmd/pmd/${VERSION}/ReadMe.md
if [[ "$VERSION" == *-SNAPSHOT ]]; then
# Uploading snapshot site...
rsync -avh --stats --delete target/pmd-doc-${VERSION}/ ${PMD_SF_USER}@web.sourceforge.net:/home/project-web/pmd/htdocs/snapshot/
fi
if [[ "$VERSION" == *-SNAPSHOT ]]; then
# only do a clean build for sonar, if we are executing a snapshot build, otherwise we can't reuse the build from above for the release
mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent package sonar:sonar -Dsonar.host.url=https://sonarqube.com -Dsonar.login=${SONAR_TOKEN} -B -V
fi

18
.travis/release.sh Normal file
View File

@ -0,0 +1,18 @@
#!/bin/bash
set -ev
RELEASE_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:2.2:evaluate -Dexpression=project.version|grep -Ev '(^\[|Download\w+:)')
# Deploy to ossrh has already been done with the usual build. See build-push.sh
# 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...
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
# TODO: patch the release on github? Upload the changelog? https://developer.github.com/v3/repos/releases/#create-a-release
# TODO: deploy site from here? We could clone the site repo, and push using a secure token instead of a password...
# TODO: publish site on pmd.github.io
# TODO: Submit news on SF?

View File

@ -1,22 +0,0 @@
#!/bin/bash
RELEASE_VERSION=$(mvn org.apache.maven.plugins:maven-help-plugin:2.1.1:evaluate -Dexpression=project.version|grep -Ev '(^\[|Download\w+:)')
# closing on the staging area is still manual, add nexus-staging plugin and perform mvn nexus-staging:release?
mvn -B -Possrh sign release:perform -DreleaseProfiles=ossrh
mvn site site:stage -Psite
(
cd target
mv staging pmd-doc-${RELEASE_VERSION}
zip -r pmd-doc-${RELEASE_VERSION}.zip pmd-doc-${RELEASE_VERSION}/
)
echo
echo "Uploading the zip files to SourceForge..."
RSYNC_PASSWORD=${PMD_SF_PASSWORD} rsync -avhP pmd-dist/target/pmd-*-${RELEASE_VERSION}.zip target/pmd-doc-${RELEASE_VERSION}.zip $PMD_SF_USER@web.sourceforge.net:/home/frs/project/pmd/pmd/${RELEASE_VERSION}/
RSYNC_PASSWORD=${PMD_SF_PASSWORD} rsync -avhP src/site/markdown/overview/changelog.md $PMD_SF_USER@web.sourceforge.net:/home/frs/project/pmd/pmd/${RELEASE_VERSION}/ReadMe.md
echo
# TODO : deploy site from here? We could clone the site repo, and push using a secure token instead of a password...