Improve build system; add _build/github-clone.sh

This commit is contained in:
Daniel Rudolf 2016-11-02 22:23:41 +01:00
parent a9eee00950
commit fad5d869ee
No known key found for this signature in database
GPG key ID: A061F02CD8DE4538
3 changed files with 41 additions and 6 deletions

View file

@ -22,15 +22,14 @@ DEPLOYMENT_DIR="$TRAVIS_BUILD_DIR/_build/deploy-$DEPLOYMENT_ID.git"
[ -n "$DEPLOY_REPO_BRANCH" ] || export DEPLOY_REPO_BRANCH="gh-pages"
# clone repo
echo "Cloning repo..."
git clone --branch="$DEPLOY_REPO_BRANCH" "https://github.com/$DEPLOY_REPO_SLUG.git" "$DEPLOYMENT_DIR"
github-clone.sh "$DEPLOYMENT_DIR" "https://github.com/$DEPLOY_REPO_SLUG.git" "$DEPLOY_REPO_BRANCH"
[ $? -eq 0 ] || exit 1
cd "$DEPLOYMENT_DIR"
echo
# setup repo
github-setup.sh
[ $? -eq 0 ] || exit 1
# generate phpDocs
generate-phpdoc.sh \
@ -44,6 +43,7 @@ generate-phpdoc.sh \
update-phpdoc-list.sh \
"$DEPLOYMENT_DIR/_data/phpDoc.yml" \
"$TRAVIS_BRANCH" "branch" "<code>$TRAVIS_BRANCH</code> branch" "$(date +%s)"
[ $? -eq 0 ] || exit 1
# commit phpDocs
echo "Committing changes..."

View file

@ -20,15 +20,14 @@ DEPLOYMENT_DIR="$TRAVIS_BUILD_DIR/_build/deploy-$DEPLOYMENT_ID.git"
[ -n "$DEPLOY_REPO_BRANCH" ] || export DEPLOY_REPO_BRANCH="gh-pages"
# clone repo
echo "Cloning repo..."
git clone --branch="$DEPLOY_REPO_BRANCH" "https://github.com/$DEPLOY_REPO_SLUG.git" "$DEPLOYMENT_DIR"
github-clone.sh "$DEPLOYMENT_DIR" "https://github.com/$DEPLOY_REPO_SLUG.git" "$DEPLOY_REPO_BRANCH"
[ $? -eq 0 ] || exit 1
cd "$DEPLOYMENT_DIR"
echo
# setup repo
github-setup.sh
[ $? -eq 0 ] || exit 1
# generate phpDocs
if [ "$DEPLOY_PHPDOC_RELEASES" == "true" ]; then
@ -43,6 +42,7 @@ if [ "$DEPLOY_PHPDOC_RELEASES" == "true" ]; then
update-phpdoc-list.sh \
"$DEPLOYMENT_DIR/_data/phpDoc.yml" \
"$TRAVIS_TAG" "version" "Pico ${TRAVIS_TAG#v}" "$(date +%s)"
[ $? -eq 0 ] || exit 1
# commit phpDocs
echo "Committing phpDoc changes..."
@ -60,6 +60,7 @@ if [ "$DEPLOY_VERSION_BADGE" == "true" ]; then
generate-badge.sh \
"$DEPLOYMENT_DIR/badges/pico-version.svg" \
"release" "$TRAVIS_TAG" "blue"
[ $? -eq 0 ] || exit 1
# commit version badge
echo "Committing version badge..."
@ -76,6 +77,7 @@ if [ "$DEPLOY_VERSION_FILE" == "true" ]; then
update-version-file.sh \
"$DEPLOYMENT_DIR/_data/version.yml" \
"${TRAVIS_TAG#v}"
[ $? -eq 0 ] || exit 1
# commit version file
echo "Committing version file..."

33
_build/github-clone.sh Executable file
View file

@ -0,0 +1,33 @@
#!/usr/bin/env bash
##
# Clones a Git repo
#
# @author Daniel Rudolf
# @link http://picocms.org
# @license http://opensource.org/licenses/MIT
#
set -e
# parameters
CLONE_TARGET_DIR="$1" # target directory
CLONE_REPO_URL="$2" # URL of the git repo to clone
CLONE_REPO_BRANCH="$3" # optional branch to checkout
# print parameters
echo "Cloning repo..."
printf 'CLONE_TARGET_DIR="%s"\n' "$CLONE_TARGET_DIR"
printf 'CLONE_REPO_URL="%s"\n' "$CLONE_REPO_URL"
printf 'CLONE_REPO_BRANCH="%s"\n' "$CLONE_REPO_BRANCH"
echo
# clone repo
git clone "$CLONE_REPO_URL" "$CLONE_TARGET_DIR"
# checkout branch
if [ -n "$CLONE_REPO_BRANCH" ]; then
git checkout "$CLONE_REPO_BRANCH"
fi
echo