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`).
pico-3.0-alpha
Daniel Rudolf 8 years ago
parent 31310429fb
commit 66cc087b6e
No known key found for this signature in database
GPG Key ID: A061F02CD8DE4538
  1. 7
      .travis.yml
  2. 30
      _build/install.sh

@ -21,11 +21,14 @@ matrix:
notifications:
irc: "chat.freenode.net#picocms"
before_install:
- export PATH="$TRAVIS_BUILD_DIR/_build:$PATH"
install:
- composer install
- install.sh
before_script:
- export PATH="$TRAVIS_BUILD_DIR/_build:$TRAVIS_BUILD_DIR/vendor/bin:$PATH"
- export PATH="$TRAVIS_BUILD_DIR/vendor/bin:$PATH"
script:
- phpcs --standard=.phpcs.xml "$TRAVIS_BUILD_DIR"

@ -0,0 +1,30 @@
#!/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
Loading…
Cancel
Save