diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..00903db --- /dev/null +++ b/.gitattributes @@ -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 diff --git a/.travis.yml b/.travis.yml index ff01cd1..0471a73 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 diff --git a/_build/create-release-archive.sh b/_build/create-release-archive.sh new file mode 100755 index 0000000..e34dcb8 --- /dev/null +++ b/_build/create-release-archive.sh @@ -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