#!/usr/bin/env php
<?php

/*
 * This file is part of the Behat.
 * (c) Konstantin Kudryashov <ever.zet@gmail.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

/**
 * Release script.
 *
 * Usage: bin/release 0.2.0 beta
 *
 * @author     Konstantin Kudryashov <ever.zet@gmail.com>
 */

system('rm -rf *.phar *.tgz');
system('wget -nc http://getcomposer.org/composer.phar');
system('php composer.phar update');

require_once __DIR__ . '/../vendor/autoload.php';

use Behat\Behat\Compiler;

if (!isset($argv[1])) {
  throw new RuntimeException('You must provide version.');
}
$version = $argv[1];

if (!isset($argv[2])) {
  throw new RuntimeException('You must provide stability status (alpha/beta/stable).');
}
$stability = $argv[2];

$phar = new Compiler\PharCompiler();
$phar->compile($version);
echo "PHAR package compiled: behat-$version.phar\n";

system("cp behat-$version.phar behat.phar");

exit(0);
