Permalink
Browse files

Build System: Refactor source code and release archive creation

Resolves #313
  • Loading branch information...
1 parent 1bf1570 commit 827be2cb9cd814569df933ae329d9c11a01c9dc3 @PhrozenByte PhrozenByte committed Jul 24, 2016
Showing with 50 additions and 4 deletions.
  1. +7 −0 .gitattributes
  2. +1 −4 .travis.yml
  3. +42 −0 _build/create-release-archive.sh
View
@@ -0,0 +1,7 @@
+/_build export-ignore
+/.gitattributes export-ignore
+/.gitignore export-ignore
+/.phpcs.xml export-ignore
+/.phpdoc.xml export-ignore
+/.travis.yml export-ignore
+/index.php.dist export-ignore
View
@@ -27,10 +27,7 @@ after_success:
before_deploy:
- deploy-phpdoc-release.sh
- - composer install --no-dev --optimize-autoloader
- - find vendor/ -type d -path 'vendor/*/*/.git' -print0 | xargs -0 rm -rf
- - mv index.php.dist index.php
- - tar -czf "pico-release-$TRAVIS_TAG.tar.gz" README.md LICENSE.md CONTRIBUTING.md CHANGELOG.md composer.json composer.lock config content-sample lib plugins themes vendor .htaccess index.php
+ - create-release-archive.sh "$TRAVIS_TAG"
deploy:
provider: releases
@@ -0,0 +1,42 @@
+#!/usr/bin/env bash
+
+RELEASE="$1"
+ARCHIVE="pico-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
+
+# create release archive
+[ -n "$RELEASE" ] && ARCHIVE="pico-release-$RELEASE.tar.gz"
+echo "Creating release archive '$ARCHIVE'..."
+
+if [ -e "$ARCHIVE" ]; then
+ echo "Unable to create archive: File exists" >&2
+ exit 1
+fi
+
+INDEX_BACKUP="$(mktemp -u)"
+mv index.php "$INDEX_BACKUP"
+mv index.php.dist index.php
+
+tar -czf "$ARCHIVE" \
+ README.md LICENSE.md CONTRIBUTING.md CHANGELOG.md \
+ composer.json composer.lock \
+ config content-sample lib plugins themes vendor \
+ .htaccess index.php
+EXIT=$?
+
+mv index.php index.php.dist
+mv "$INDEX_BACKUP" index.php
+
+echo
+
+[ $EXIT -eq 0 ] || exit 1

0 comments on commit 827be2c

Please sign in to comment.