Refactor phpDoc auto-deployment

This commit is contained in:
Daniel Rudolf 2015-11-23 21:46:36 +01:00
parent e79388118c
commit 7f4ad75245
3 changed files with 29 additions and 28 deletions

4
.gitignore vendored
View file

@ -10,6 +10,10 @@ desktop.ini
.DS_Store
._*
# Travis
/build/phpdoc-*/
/build/phpdoc-*.git/
# Composer
composer.lock
composer.phar

View file

@ -12,14 +12,11 @@ script:
- find . -type f -name '*.php' -print0 | xargs -0 -I file php -l file > /dev/null
before_deploy:
# Generate API documentation
- sh -c "php $TRAVIS_BUILD_DIR/vendor/bin/phpdoc -d $TRAVIS_BUILD_DIR -t $TRAVIS_BUILD_DIR/build/docs/$TRAVIS_TAG --ignore '*/vendor/*'"
# Send documentation to Github Pages
- sh -c "bash $TRAVIS_BUILD_DIR/build/deploy-phpdoc.sh;"
# remove req-dev depenedencies
- composer update --no-dev
# package Pico
- tar -czf "pico-release-$TRAVIS_TAG.tar.gz" .htaccess README.md CHANGELOG.md CONTRIBUTING.md composer.json composer.lock LICENSE config content-sample lib plugins themes vendor index.php
- composer install
- ./vendor/bin/phpdoc -d . -i 'vendor/*' -i 'plugins/*' -f 'plugins/DummyPlugin.php' -t "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" --title "Pico 1.0 API Documentation ($TRAVIS_TAG)"
- ./build/deploy-phpdoc.sh "picocms/Pico" "gh-pages" "$GITHUB_OAUTH_TOKEN" "$TRAVIS_BUILD_DIR/build/phpdoc-$TRAVIS_TAG" "phpDoc/$TRAVIS_TAG"
- composer install --no-dev
- tar -czf "pico-release-$TRAVIS_TAG.tar.gz" README.md LICENSE CONTRIBUTING.md CHANGELOG.md composer.json composer.lock config content-sample lib plugins themes vendor .htaccess index.php
deploy:
provider: releases

View file

@ -1,29 +1,29 @@
#!/usr/bin/env bash
# Modified from: https://gist.github.com/domenic/ec8b0fc8ab45f39403dd
# Exit with nonzero exit code if anything fails
set -e
# Clone Pico, then create & checkout gh-pages branch
git clone -b gh-pages "https://github.com/picocms/Pico.git $TRAVIS_BUILD_DIR/build/Pico"
# parameters
GITHUB_PROJECT="$1" # GitHub repo (e.g. picocms/Pico)
GITHUB_BRANCH="$2" # branch to use (e.g. gh-pages)
GITHUB_OAUTH_TOKEN="$3" # see https://github.com/settings/tokens
SOURCE_DIR="$4" # absolute path to phpDocs target directory
TARGET_DIR="$5" # relative path within the specified GitHub repo
# Inside this git repo we'll pretend to be a new user
# clone repo
GIT_DIR="$(dirname "$0")/$(basename "$SOURCE_DIR").git"
git clone -b "$GITHUB_BRANCH" "https://github.com/$GITHUB_PROJECT.git" "$GIT_DIR"
# setup git
cd "$GIT_DIR"
git config user.name "Travis CI"
git config user.email "travis-ci@picocms.org"
#copy new files to release number
cp -a $TRAVIS_BUILD_DIR/build/docs/$TRAVIS_TAG $TRAVIS_BUILD_DIR/build/Pico/phpDoc/$TRAVIS_TAG
#move old master files to old-stable
mv -f $TRAVIS_BUILD_DIR/build/Pico/phpDoc/master $TRAVIS_BUILD_DIR/build/Pico/phpDoc/old-stable
#copy new files to master
cp -a $TRAVIS_BUILD_DIR/build/docs/$TRAVIS_TAG $TRAVIS_BUILD_DIR/build/Pico/phpDoc/master
# copy phpdoc
[ -e "$TARGET_DIR" ] && echo "FATAL: $(basename "$0") target directory exists" && exit 1
cp -R "$SOURCE_DIR" "$TARGET_DIR"
# Add the files to our commit
git add $TRAVIS_BUILD_DIR/build/Pico/phpDoc/*
# commit changes
git add "$TARGET_DIR"
git commit -m "Add phpDocumentor class docs for Pico $TRAVIS_TAG"
# Commit the files with our commit message
git commit -m "Update Documentation for Pico $TRAVIS_TAG"
# Force push from the current repo's gh-pages branch to the remote repo's gh-pages branch.
# We redirect output to /dev/null to hide any sensitive data that might otherwise be exposed.
git push --force --quiet "https://${GITHUB_OAUTH_TOKEN}@github.com/picocms/Pico.git" master:gh-pages > /dev/null 2>&1
# push changes
git push --force --quiet "https://${GITHUB_OAUTH_TOKEN}@github.com/$GITHUB_PROJECT.git" "$GITHUB_BRANCH:$GITHUB_BRANCH" > /dev/null 2>&1