diff --git a/.travis.yml b/.travis.yml index 7fdc791..6732b1e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,26 +1,56 @@ -language: php -php: - - 5.4 - - 5.5 - - 5.6 - - 7.0 - - 7.1 - - nightly - - hhvm - - hhvm-nightly +dist: trusty +sudo: false -matrix: +language: php + +cache: + directories: + - $HOME/.composer/cache/files + +jobs: include: + # Test stage - php: 5.3 dist: precise + - php: 5.4 + - php: 5.5 + - php: 5.6 + - php: 7.0 + - php: 7.1 + - php: nightly + - php: hhvm + - php: hhvm-nightly + + # Deployment stage + - stage: deploy + install: + - '[ "$TRAVIS_PULL_REQUEST" == "false" ] || travis_terminate 0' + - '[[ ",$DEPLOY_PHPDOC_BRANCHES," == *,"$TRAVIS_BRANCH",* ]] || travis_terminate 0' + - install.sh + script: + - deploy-phpdoc-branch.sh + + # Release stage + - stage: release + install: + - '[ -n "$TRAVIS_TAG" ] || travis_terminate 0' + - install.sh --release + script: + - deploy-phpdoc-release.sh + before_deploy: + - create-release-archive.sh "pico-release-$TRAVIS_TAG.tar.gz" + deploy: + provider: releases + api_key: ${GITHUB_OAUTH_TOKEN} + file: pico-release-$TRAVIS_TAG.tar.gz + skip_cleanup: true + + # Ignore nightly build failures allow_failures: - php: nightly - php: hhvm-nightly fast-finish: true -notifications: - irc: "chat.freenode.net#picocms" - before_install: - export PATH="$TRAVIS_BUILD_DIR/_build:$PATH" @@ -33,21 +63,5 @@ before_script: script: - phpcs --standard=.phpcs.xml "$TRAVIS_BUILD_DIR" -after_success: - - deploy-phpdoc-branch.sh - -before_deploy: - - deploy-phpdoc-release.sh - - create-release-archive.sh "$TRAVIS_TAG" - -deploy: - provider: releases - api_key: ${GITHUB_OAUTH_TOKEN} - file: pico-release-$TRAVIS_TAG.tar.gz - skip_cleanup: true - on: - tags: true - php: 5.3 - -dist: trusty -sudo: false +notifications: + irc: "chat.freenode.net#picocms" diff --git a/_build/create-release-archive.sh b/_build/create-release-archive.sh index 62737d6..d5c2cd4 100755 --- a/_build/create-release-archive.sh +++ b/_build/create-release-archive.sh @@ -1,19 +1,6 @@ #!/usr/bin/env bash -RELEASE="$1" -ARCHIVE="pico-release.tar.gz" -[ -n "$RELEASE" ] && ARCHIVE="pico-release-$RELEASE.tar.gz" - -# install dependencies -echo "Running \`composer install\`..." -composer install --no-dev --optimize-autoloader -[ $? -eq 0 ] || exit 1 -echo - -# remove .git dirs -echo "Removing '.git' directories of dependencies..." -find vendor/ -type d -path 'vendor/*/*/.git' -print0 | xargs -0 rm -rf -echo +ARCHIVE="$1" # create release archive echo "Creating release archive '$ARCHIVE'..." diff --git a/_build/deploy-phpdoc-branch.sh b/_build/deploy-phpdoc-branch.sh index 0364c4f..31b4486 100755 --- a/_build/deploy-phpdoc-branch.sh +++ b/_build/deploy-phpdoc-branch.sh @@ -1,20 +1,5 @@ #!/usr/bin/env bash -if [ "$TRAVIS_PHP_VERSION" != "5.3" ]; then - echo "Skipping branch deployment because this is not on the required runtime" - exit 0 -fi - -if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then - echo "Skipping branch deployment because this pull request (#$TRAVIS_PULL_REQUEST) is not permitted to deploy" - exit 0 -fi - -if [[ ",$DEPLOY_PHPDOC_BRANCHES," != *,"$TRAVIS_BRANCH",* ]]; then - echo "Skipping phpDoc branch deployment because this branch ($TRAVIS_BRANCH) is not permitted to deploy" - exit 0 -fi - DEPLOYMENT_ID="${TRAVIS_BRANCH//\//_}" DEPLOYMENT_DIR="$TRAVIS_BUILD_DIR/_build/deploy-$DEPLOYMENT_ID.git" @@ -51,7 +36,7 @@ update-phpdoc-list.sh \ # commit phpDocs echo "Committing changes..." -git add \ +git add --all \ "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID.cache" "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" \ "$DEPLOYMENT_DIR/_data/phpDoc.yml" git commit \ diff --git a/_build/deploy-phpdoc-release.sh b/_build/deploy-phpdoc-release.sh index a56bb64..8188911 100755 --- a/_build/deploy-phpdoc-release.sh +++ b/_build/deploy-phpdoc-release.sh @@ -50,7 +50,7 @@ if [ "$DEPLOY_PHPDOC_RELEASES" == "true" ]; then # commit phpDocs echo "Committing phpDoc changes..." - git add "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" "$DEPLOYMENT_DIR/_data/phpDoc.yml" + git add --all "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" "$DEPLOYMENT_DIR/_data/phpDoc.yml" git commit \ --message="Update phpDocumentor class docs for $TRAVIS_TAG" \ "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" "$DEPLOYMENT_DIR/_data/phpDoc.yml" diff --git a/_build/github-deploy.sh b/_build/github-deploy.sh index 3734f20..b7ec649 100755 --- a/_build/github-deploy.sh +++ b/_build/github-deploy.sh @@ -16,6 +16,9 @@ CHECK_REPO_SLUG="$1" # optional GitHub repo (e.g. picocms/Pico) to check CHECK_REMOTE_REF="$2" # optional remote Git reference (e.g. heads/master) CHECK_LOCAL_COMMIT="$3" # optional local commit SHA1 +# environment variables +# GITHUB_OAUTH_TOKEN GitHub authentication token, see https://github.com/settings/tokens + # print parameters echo "Deploying repo..." printf 'CHECK_REPO_SLUG="%s"\n' "$CHECK_REPO_SLUG" @@ -34,12 +37,12 @@ fi # but it should give a basic protection without disabling concurrent builds completely if [ -n "$CHECK_REPO_SLUG" ] && [ -n "$CHECK_REMOTE_REF" ] && [ -n "$CHECK_LOCAL_COMMIT" ]; then # retrieve information using GitHub APIv3 - printf 'Checking latest commit...\n' + echo "Checking latest commit$([ -n "$GITHUB_OAUTH_TOKEN" ] && echo " (authorized)")..." CHECK_API_URL="https://api.github.com/repos/$CHECK_REPO_SLUG/git/refs/$CHECK_REMOTE_REF" if [ -n "$GITHUB_OAUTH_TOKEN" ]; then - CHECK_API_RESPONSE="$(wget -O- --header="Authorization: token $GITHUB_OAUTH_TOKEN" "$CHECK_API_URL" 2> /dev/null)" + CHECK_API_RESPONSE="$(curl --fail --silent --show-error --header "Authorization: token $GITHUB_OAUTH_TOKEN" "$CHECK_API_URL")" else - CHECK_API_RESPONSE="$(wget -O- "$CHECK_API_URL" 2> /dev/null)" + CHECK_API_RESPONSE="$(curl --fail --silent --show-error "$CHECK_API_URL")" fi # evaluate JSON response diff --git a/_build/install.sh b/_build/install.sh index aaa50a2..b469994 100755 --- a/_build/install.sh +++ b/_build/install.sh @@ -1,6 +1,19 @@ #!/usr/bin/env bash -set -e +if [ "$1" == "--release" ]; then + # install dependencies + echo "Running \`composer install\`..." + composer install --no-dev --optimize-autoloader + [ $? -eq 0 ] || exit 1 + echo + + # remove .git dirs + echo "Removing '.git' directories of dependencies..." + find vendor/ -type d -path 'vendor/*/*/.git' -print0 | xargs -0 rm -rf + echo + + exit 0 +fi # set COMPOSER_ROOT_VERSION when necessary if [ -z "$COMPOSER_ROOT_VERSION" ] && [ -z "$TRAVIS_TAG" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then @@ -28,3 +41,5 @@ fi # install dependencies echo "Running \`composer install\`$([ -n "$COMPOSER_ROOT_VERSION" ] && echo -n " ($COMPOSER_ROOT_VERSION)")..." composer install + +exit $?