Browse Source

Build system: Various small improvements

Daniel Rudolf 7 years ago
parent
commit
498961b0c6
3 changed files with 33 additions and 23 deletions
  1. 6 7
      _build/deploy-branch.sh
  2. 21 15
      _build/deploy-release.sh
  3. 6 1
      _build/install.sh

+ 6 - 7
_build/deploy-branch.sh

@@ -1,4 +1,5 @@
 #!/usr/bin/env bash
 #!/usr/bin/env bash
+set -e
 
 
 export PATH="$(dirname "$0")/tools:$PATH"
 export PATH="$(dirname "$0")/tools:$PATH"
 
 
@@ -14,27 +15,27 @@ MILESTONE="Pico$([[ "$VERSION" =~ ^([0-9]+\.[0-9]+)\. ]] && echo " ${BASH_REMATC
 
 
 # clone repo
 # clone repo
 github-clone.sh "$DEPLOYMENT_DIR" "https://github.com/$DEPLOY_REPO_SLUG.git" "$DEPLOY_REPO_BRANCH"
 github-clone.sh "$DEPLOYMENT_DIR" "https://github.com/$DEPLOY_REPO_SLUG.git" "$DEPLOY_REPO_BRANCH"
-[ $? -eq 0 ] || exit 1
 
 
 cd "$DEPLOYMENT_DIR"
 cd "$DEPLOYMENT_DIR"
 
 
 # setup repo
 # setup repo
 github-setup.sh
 github-setup.sh
-[ $? -eq 0 ] || exit 1
 
 
 # generate phpDocs
 # generate phpDocs
 generate-phpdoc.sh \
 generate-phpdoc.sh \
     "$TRAVIS_BUILD_DIR/.phpdoc.xml" \
     "$TRAVIS_BUILD_DIR/.phpdoc.xml" \
     "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID.cache" "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" \
     "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID.cache" "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" \
     "$MILESTONE API Documentation ($TRAVIS_BRANCH branch)"
     "$MILESTONE API Documentation ($TRAVIS_BRANCH branch)"
-[ $? -eq 0 ] || exit 1
-[ -n "$(git status --porcelain "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID.cache")" ] || exit 0
+
+if [ -z "$(git status --porcelain "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID.cache")" ]; then
+    # nothing to do
+    exit 0
+fi
 
 
 # update phpDoc list
 # update phpDoc list
 update-phpdoc-list.sh \
 update-phpdoc-list.sh \
     "$DEPLOYMENT_DIR/_data/phpDoc.yml" \
     "$DEPLOYMENT_DIR/_data/phpDoc.yml" \
     "$TRAVIS_BRANCH" "branch" "<code>$TRAVIS_BRANCH</code> branch" "$(date +%s)"
     "$TRAVIS_BRANCH" "branch" "<code>$TRAVIS_BRANCH</code> branch" "$(date +%s)"
-[ $? -eq 0 ] || exit 1
 
 
 # commit phpDocs
 # commit phpDocs
 echo "Committing changes..."
 echo "Committing changes..."
@@ -45,9 +46,7 @@ git commit \
     --message="Update phpDocumentor class docs for $TRAVIS_BRANCH branch @ $TRAVIS_COMMIT" \
     --message="Update phpDocumentor class docs for $TRAVIS_BRANCH branch @ $TRAVIS_COMMIT" \
     "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID.cache" "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" \
     "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID.cache" "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" \
     "$DEPLOYMENT_DIR/_data/phpDoc.yml"
     "$DEPLOYMENT_DIR/_data/phpDoc.yml"
-[ $? -eq 0 ] || exit 1
 echo
 echo
 
 
 # deploy phpDocs
 # deploy phpDocs
 github-deploy.sh "$TRAVIS_REPO_SLUG" "heads/$TRAVIS_BRANCH" "$TRAVIS_COMMIT"
 github-deploy.sh "$TRAVIS_REPO_SLUG" "heads/$TRAVIS_BRANCH" "$TRAVIS_COMMIT"
-[ $? -eq 0 ] || exit 1

+ 21 - 15
_build/deploy-release.sh

@@ -1,21 +1,39 @@
 #!/usr/bin/env bash
 #!/usr/bin/env bash
+set -e
 
 
+DEPLOY_FULL="true"
 if [ "$DEPLOY_PHPDOC_RELEASES" != "true" ]; then
 if [ "$DEPLOY_PHPDOC_RELEASES" != "true" ]; then
     echo "Skipping phpDoc release deployment because it has been disabled"
     echo "Skipping phpDoc release deployment because it has been disabled"
+    DEPLOY_FULL="false"
 fi
 fi
 if [ "$DEPLOY_VERSION_BADGE" != "true" ]; then
 if [ "$DEPLOY_VERSION_BADGE" != "true" ]; then
     echo "Skipping version badge deployment because it has been disabled"
     echo "Skipping version badge deployment because it has been disabled"
+    DEPLOY_FULL="false"
 fi
 fi
 if [ "$DEPLOY_VERSION_FILE" != "true" ]; then
 if [ "$DEPLOY_VERSION_FILE" != "true" ]; then
     echo "Skipping version file deployment because it has been disabled"
     echo "Skipping version file deployment because it has been disabled"
+    DEPLOY_FULL="false"
 fi
 fi
-if [ "$DEPLOY_PHPDOC_RELEASES" != "true" ] || [ "$DEPLOY_VERSION_BADGE" != "true" ] || [ "$DEPLOY_VERSION_FILE" != "true" ] || [ "$DEPLOY_CLOC_STATS" != "true" ]; then
-    [ "$DEPLOY_PHPDOC_RELEASES" != "true" ] && [ "$DEPLOY_VERSION_BADGE" != "true" ] && [ "$DEPLOY_VERSION_FILE" != "true" ] && [ "$DEPLOY_CLOC_STATS" != "true" ] && exit 0 || echo
+if [ "$DEPLOY_CLOC_STATS" != "true" ]; then
+    echo "Skipping cloc statistics deployment because it has been disabled"
+    DEPLOY_FULL="false"
+fi
+
+if [ "$DEPLOY_FULL" != "true" ]; then
+    if [ "$DEPLOY_PHPDOC_RELEASES" != "true" ] \
+        && [ "$DEPLOY_VERSION_BADGE" != "true" ] \
+        && [ "$DEPLOY_VERSION_FILE" != "true" ] \
+        && [ "$DEPLOY_CLOC_STATS" != "true" ]
+    then
+        # nothing to do
+        exit 0
+    fi
+    echo
 fi
 fi
 
 
 export PATH="$(dirname "$0")/tools:$PATH"
 export PATH="$(dirname "$0")/tools:$PATH"
 
 
-DEPLOYMENT_ID="${TRAVIS_BRANCH//\//_}"
+DEPLOYMENT_ID="${TRAVIS_TAG//\//_}"
 DEPLOYMENT_DIR="$TRAVIS_BUILD_DIR/_build/deploy-$DEPLOYMENT_ID.git"
 DEPLOYMENT_DIR="$TRAVIS_BUILD_DIR/_build/deploy-$DEPLOYMENT_ID.git"
 
 
 [ -n "$DEPLOY_REPO_SLUG" ] || export DEPLOY_REPO_SLUG="$TRAVIS_REPO_SLUG"
 [ -n "$DEPLOY_REPO_SLUG" ] || export DEPLOY_REPO_SLUG="$TRAVIS_REPO_SLUG"
@@ -23,13 +41,11 @@ DEPLOYMENT_DIR="$TRAVIS_BUILD_DIR/_build/deploy-$DEPLOYMENT_ID.git"
 
 
 # clone repo
 # clone repo
 github-clone.sh "$DEPLOYMENT_DIR" "https://github.com/$DEPLOY_REPO_SLUG.git" "$DEPLOY_REPO_BRANCH"
 github-clone.sh "$DEPLOYMENT_DIR" "https://github.com/$DEPLOY_REPO_SLUG.git" "$DEPLOY_REPO_BRANCH"
-[ $? -eq 0 ] || exit 1
 
 
 cd "$DEPLOYMENT_DIR"
 cd "$DEPLOYMENT_DIR"
 
 
 # setup repo
 # setup repo
 github-setup.sh
 github-setup.sh
-[ $? -eq 0 ] || exit 1
 
 
 # generate phpDocs
 # generate phpDocs
 if [ "$DEPLOY_PHPDOC_RELEASES" == "true" ]; then
 if [ "$DEPLOY_PHPDOC_RELEASES" == "true" ]; then
@@ -41,14 +57,12 @@ if [ "$DEPLOY_PHPDOC_RELEASES" == "true" ]; then
         "$TRAVIS_BUILD_DIR/.phpdoc.xml" \
         "$TRAVIS_BUILD_DIR/.phpdoc.xml" \
         "-" "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" \
         "-" "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" \
         "$MILESTONE API Documentation ($TRAVIS_TAG)"
         "$MILESTONE API Documentation ($TRAVIS_TAG)"
-    [ $? -eq 0 ] || exit 1
 
 
     if [ -n "$(git status --porcelain "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID")" ]; then
     if [ -n "$(git status --porcelain "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID")" ]; then
         # update phpDoc list
         # update phpDoc list
         update-phpdoc-list.sh \
         update-phpdoc-list.sh \
             "$DEPLOYMENT_DIR/_data/phpDoc.yml" \
             "$DEPLOYMENT_DIR/_data/phpDoc.yml" \
             "$TRAVIS_TAG" "version" "Pico ${TRAVIS_TAG#v}" "$(date +%s)"
             "$TRAVIS_TAG" "version" "Pico ${TRAVIS_TAG#v}" "$(date +%s)"
-        [ $? -eq 0 ] || exit 1
 
 
         # commit phpDocs
         # commit phpDocs
         echo "Committing phpDoc changes..."
         echo "Committing phpDoc changes..."
@@ -56,7 +70,6 @@ if [ "$DEPLOY_PHPDOC_RELEASES" == "true" ]; then
         git commit \
         git commit \
             --message="Update phpDocumentor class docs for $TRAVIS_TAG" \
             --message="Update phpDocumentor class docs for $TRAVIS_TAG" \
             "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" "$DEPLOYMENT_DIR/_data/phpDoc.yml"
             "$DEPLOYMENT_DIR/phpDoc/$DEPLOYMENT_ID" "$DEPLOYMENT_DIR/_data/phpDoc.yml"
-        [ $? -eq 0 ] || exit 1
         echo
         echo
     fi
     fi
 fi
 fi
@@ -66,7 +79,6 @@ if [ "$DEPLOY_VERSION_BADGE" == "true" ]; then
     generate-badge.sh \
     generate-badge.sh \
         "$DEPLOYMENT_DIR/badges/pico-version.svg" \
         "$DEPLOYMENT_DIR/badges/pico-version.svg" \
         "release" "$TRAVIS_TAG" "blue"
         "release" "$TRAVIS_TAG" "blue"
-    [ $? -eq 0 ] || exit 1
 
 
     # commit version badge
     # commit version badge
     echo "Committing version badge..."
     echo "Committing version badge..."
@@ -74,7 +86,6 @@ if [ "$DEPLOY_VERSION_BADGE" == "true" ]; then
     git commit \
     git commit \
         --message="Update version badge for $TRAVIS_TAG" \
         --message="Update version badge for $TRAVIS_TAG" \
         "$DEPLOYMENT_DIR/badges/pico-version.svg"
         "$DEPLOYMENT_DIR/badges/pico-version.svg"
-    [ $? -eq 0 ] || exit 1
     echo
     echo
 fi
 fi
 
 
@@ -83,7 +94,6 @@ if [ "$DEPLOY_VERSION_FILE" == "true" ]; then
     update-version-file.sh \
     update-version-file.sh \
         "$DEPLOYMENT_DIR/_data/version.yml" \
         "$DEPLOYMENT_DIR/_data/version.yml" \
         "${TRAVIS_TAG#v}"
         "${TRAVIS_TAG#v}"
-    [ $? -eq 0 ] || exit 1
 
 
     # commit version file
     # commit version file
     echo "Committing version file..."
     echo "Committing version file..."
@@ -91,7 +101,6 @@ if [ "$DEPLOY_VERSION_FILE" == "true" ]; then
     git commit \
     git commit \
         --message="Update version file for $TRAVIS_TAG" \
         --message="Update version file for $TRAVIS_TAG" \
         "$DEPLOYMENT_DIR/_data/version.yml"
         "$DEPLOYMENT_DIR/_data/version.yml"
-    [ $? -eq 0 ] || exit 1
     echo
     echo
 fi
 fi
 
 
@@ -100,7 +109,6 @@ if [ "$DEPLOY_CLOC_STATS" == "true" ]; then
     update-cloc-stats.sh \
     update-cloc-stats.sh \
         "$DEPLOYMENT_DIR/_data/clocCore.yml" \
         "$DEPLOYMENT_DIR/_data/clocCore.yml" \
         "$DEPLOYMENT_DIR/_data/clocRelease.yml"
         "$DEPLOYMENT_DIR/_data/clocRelease.yml"
-    [ $? -eq 0 ] || exit 1
 
 
     # commit cloc statistics
     # commit cloc statistics
     echo "Commiting cloc statistics..."
     echo "Commiting cloc statistics..."
@@ -108,10 +116,8 @@ if [ "$DEPLOY_CLOC_STATS" == "true" ]; then
     git commit \
     git commit \
         --message="Update cloc statistics for $TRAVIS_TAG" \
         --message="Update cloc statistics for $TRAVIS_TAG" \
         "$DEPLOYMENT_DIR/_data/clocCore.yml" "$DEPLOYMENT_DIR/_data/clocRelease.yml"
         "$DEPLOYMENT_DIR/_data/clocCore.yml" "$DEPLOYMENT_DIR/_data/clocRelease.yml"
-    [ $? -eq 0 ] || exit 1
     echo
     echo
 fi
 fi
 
 
 # deploy
 # deploy
 github-deploy.sh "$TRAVIS_REPO_SLUG" "tags/$TRAVIS_TAG" "$TRAVIS_COMMIT"
 github-deploy.sh "$TRAVIS_REPO_SLUG" "tags/$TRAVIS_TAG" "$TRAVIS_COMMIT"
-[ $? -eq 0 ] || exit 1

+ 6 - 1
_build/install.sh

@@ -1,5 +1,10 @@
 #!/usr/bin/env bash
 #!/usr/bin/env bash
 
 
+# let composer use our GITHUB_OAUTH_TOKEN
+if [ -n "$GITHUB_OAUTH_TOKEN" ]; then
+    composer config --global github-oauth.github.com "$GITHUB_OAUTH_TOKEN"
+fi
+
 if [ "$1" == "--release" ]; then
 if [ "$1" == "--release" ]; then
     # install dependencies
     # install dependencies
     echo "Running \`composer install\`..."
     echo "Running \`composer install\`..."
@@ -40,6 +45,6 @@ fi
 
 
 # install dependencies
 # install dependencies
 echo "Running \`composer install\`$([ -n "$COMPOSER_ROOT_VERSION" ] && echo -n " ($COMPOSER_ROOT_VERSION)")..."
 echo "Running \`composer install\`$([ -n "$COMPOSER_ROOT_VERSION" ] && echo -n " ($COMPOSER_ROOT_VERSION)")..."
-composer install
+composer install --no-suggest
 
 
 exit $?
 exit $?