From 4fb0b408e2b2c4ba1f47dd5015c39703204b284a Mon Sep 17 00:00:00 2001 From: Daniel Rudolf Date: Sun, 5 Nov 2017 02:36:50 +0100 Subject: [PATCH] Build system: Improve and fix deployment --- .travis.yml | 17 ++++++----------- _build/create-release.sh | 2 +- _build/deploy-branch.sh | 3 +++ _build/deploy-release.sh | 15 +++++++++------ _build/deploy.sh | 6 ++++++ _build/install.sh | 19 +++++++++++++++++-- 6 files changed, 42 insertions(+), 20 deletions(-) create mode 100755 _build/deploy.sh diff --git a/.travis.yml b/.travis.yml index ef06156..8e0aa0a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -23,20 +23,13 @@ jobs: # Deployment stage - stage: deploy + sudo: required install: - '[ "$TRAVIS_PULL_REQUEST" == "false" ] || travis_terminate 0' - - '[[ ",$DEPLOY_PHPDOC_BRANCHES," == *,"$TRAVIS_BRANCH",* ]] || travis_terminate 0' - - install.sh + - '[ -n "$TRAVIS_TAG" ] || [[ ",$DEPLOY_PHPDOC_BRANCHES," == *,"$TRAVIS_BRANCH",* ]] || travis_terminate 0' + - install.sh --deploy script: - - deploy-branch.sh - - # Release stage - - stage: release - install: - - '[ -n "$TRAVIS_TAG" ] || travis_terminate 0' - - install.sh - script: - - deploy-release.sh + - deploy.sh before_deploy: - create-release.sh "pico-release-$TRAVIS_TAG.tar.gz" deploy: @@ -45,6 +38,8 @@ jobs: file: pico-release-$TRAVIS_TAG.tar.gz skip_cleanup: true draft: true + on: + tags: true # Ignore nightly build failures allow_failures: diff --git a/_build/create-release.sh b/_build/create-release.sh index f3e49e5..d9f21d6 100755 --- a/_build/create-release.sh +++ b/_build/create-release.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash set -e -. "$(dirname "$0")/functions/parse-version.sh.inc" +. "$(dirname "$0")/tools/functions/parse-version.sh.inc" export PATH="$(dirname "$0")/tools:$PATH" DEPLOYMENT_ID="${TRAVIS_TAG//\//_}" diff --git a/_build/deploy-branch.sh b/_build/deploy-branch.sh index a5ce2ca..8301932 100755 --- a/_build/deploy-branch.sh +++ b/_build/deploy-branch.sh @@ -13,6 +13,9 @@ DEPLOYMENT_DIR="$TRAVIS_BUILD_DIR/_build/deploy-$DEPLOYMENT_ID.git" VERSION="$(php -r 'require_once(__DIR__ . "/lib/Pico.php"); echo Pico::VERSION;')" MILESTONE="Pico$([[ "$VERSION" =~ ^([0-9]+\.[0-9]+)\. ]] && echo " ${BASH_REMATCH[1]}")" +echo "Deploying $TRAVIS_BRANCH branch ($MILESTONE)..." +echo + # clone repo github-clone.sh "$DEPLOYMENT_DIR" "https://github.com/$DEPLOY_REPO_SLUG.git" "$DEPLOY_REPO_BRANCH" diff --git a/_build/deploy-release.sh b/_build/deploy-release.sh index 4305ea9..48f3209 100755 --- a/_build/deploy-release.sh +++ b/_build/deploy-release.sh @@ -31,7 +31,7 @@ if [ "$DEPLOY_FULL" != "true" ]; then echo fi -. "$(dirname "$0")/functions/parse-version.sh.inc" +. "$(dirname "$0")/tools/functions/parse-version.sh.inc" export PATH="$(dirname "$0")/tools:$PATH" DEPLOYMENT_ID="${TRAVIS_TAG//\//_}" @@ -46,6 +46,12 @@ if ! parse_version "$TRAVIS_TAG"; then exit 1 fi +echo "Deploying Pico $VERSION_MILESTONE ($VERSION_STABILITY)..." +printf 'VERSION_FULL="%s"\n' "$VERSION_FULL" +printf 'VERSION_NAME="%s"\n' "$VERSION_NAME" +printf 'VERSION_ID="%s"\n' "$VERSION_ID" +echo + # clone repo github-clone.sh "$DEPLOYMENT_DIR" "https://github.com/$DEPLOY_REPO_SLUG.git" "$DEPLOY_REPO_BRANCH" @@ -56,14 +62,11 @@ github-setup.sh # generate phpDocs if [ "$DEPLOY_PHPDOC_RELEASES" == "true" ]; then - # get current Pico milestone - MILESTONE="Pico $VERSION_MILESTONE" - # generate phpDocs generate-phpdoc.sh \ "$TRAVIS_BUILD_DIR/.phpdoc.xml" \ "-" "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" \ - "$MILESTONE API Documentation ($TRAVIS_TAG)" + "Pico $VERSION_MILESTONE API Documentation ($TRAVIS_TAG)" if [ -n "$(git status --porcelain "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID")" ]; then # update phpDoc list @@ -79,7 +82,7 @@ if [ "$DEPLOY_PHPDOC_RELEASES" == "true" ]; then fi # don't update version badge, version file and cloc statistics for pre-releases -if [ "$VERSION_STABILITY" != "stable" ]; then +if [ "$VERSION_STABILITY" == "stable" ]; then # update version badge if [ "$DEPLOY_VERSION_BADGE" == "true" ]; then generate-badge.sh \ diff --git a/_build/deploy.sh b/_build/deploy.sh new file mode 100755 index 0000000..3d5e4b5 --- /dev/null +++ b/_build/deploy.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +if [ -n "$TRAVIS_TAG" ]; then + exec "$(dirname "$0")/deploy-release.sh" +else + exec "$(dirname "$0")/deploy-branch.sh" +fi diff --git a/_build/install.sh b/_build/install.sh index f352c89..dee3ee5 100755 --- a/_build/install.sh +++ b/_build/install.sh @@ -1,4 +1,19 @@ #!/usr/bin/env bash +set -e + +# setup build system +echo "Installing build dependencies..." + +case "$1" in + "--deploy") + sudo apt-get install -y cloc + ;; +esac + +echo + +# setup composer +echo "Setup Composer..." # let composer use our GITHUB_OAUTH_TOKEN if [ -n "$GITHUB_OAUTH_TOKEN" ]; then @@ -28,8 +43,8 @@ if [ -z "$COMPOSER_ROOT_VERSION" ] && [ -z "$TRAVIS_TAG" ] && [ "$TRAVIS_PULL_RE fi fi +echo + # install dependencies echo "Running \`composer install\`$([ -n "$COMPOSER_ROOT_VERSION" ] && echo -n " ($COMPOSER_ROOT_VERSION)")..." composer install --no-suggest - -exit $?