pico/_build/install.sh
Daniel Rudolf 66cc087b6e
Travis CI: Explicitly set root package version for branches
Due to the fact that Travis uses a shallow clone of Pico's Git repo, composer has no chance to detect on which branch it currently is. This was no big deal with Pico 1.0, however, Pico 2.0 depends on picocms/pico-deprecated and picocms/pico-theme. We use composer's `self.version` version constraint to sync the version numbers of these separate Git repos. Thus composer must know Pico's current version to resolve these dependencies. We try to guess the current version either using known branch aliases in Pico's `composer.json`, or using the `Pico::VERSION` constant (see `_build/install.sh`).
2017-06-14 02:11:32 +02:00

31 lines
1000 B
Bash
Executable File

#!/usr/bin/env bash
set -e
# set COMPOSER_ROOT_VERSION when necessary
if [ -z "$TRAVIS_TAG" ] && [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
PICO_VERSION_PATTERN="$(php -r "
\$json = json_decode(file_get_contents('$TRAVIS_BUILD_DIR/composer.json'), true);
if (\$json !== null) {
if (isset(\$json['extra']['branch-alias']['dev-$TRAVIS_BRANCH'])) {
echo 'dev-$TRAVIS_BRANCH';
}
}
")"
if [ -z "$PICO_VERSION_PATTERN" ]; then
PICO_VERSION_PATTERN="$(php -r "
require_once('$TRAVIS_BUILD_DIR/lib/Pico.php');
echo preg_replace('/\.[0-9]+-dev$/', '.x-dev', Pico::VERSION);
")"
fi
if [ -z "$COMPOSER_ROOT_VERSION" ] && [ -n "$PICO_VERSION_PATTERN" ]; then
export COMPOSER_ROOT_VERSION="$PICO_VERSION_PATTERN"
fi
fi
# install dependencies
echo "Running \`composer install\`$([ -n "$COMPOSER_ROOT_VERSION" ] && echo -n " ($COMPOSER_ROOT_VERSION)")..."
composer install