| 1 | <?php |
|---|
| 2 | /** |
|---|
| 3 | * Publishes a Bitten build to the public build server. |
|---|
| 4 | * |
|---|
| 5 | * @author Joel Low <lowjoel@users.sourceforge.net> |
|---|
| 6 | * @version $Id$ |
|---|
| 7 | */ |
|---|
| 8 | |
|---|
| 9 | if (count($argv) < 4) |
|---|
| 10 | { |
|---|
| 11 | echo 'There are insufficient arguments for BuildPublish.php.' . "\n\n" . |
|---|
| 12 | 'Usage: BuildPublish.php <branch name> <revision> <installer>'; |
|---|
| 13 | exit(1); |
|---|
| 14 | } |
|---|
| 15 | |
|---|
| 16 | require_once('Credentials.php'); |
|---|
| 17 | require_once('BuildBranch.php'); |
|---|
| 18 | require_once('BuildUtil.php'); |
|---|
| 19 | |
|---|
| 20 | $file = fopen($argv[3], 'rb'); |
|---|
| 21 | if (!$file) |
|---|
| 22 | { |
|---|
| 23 | echo 'The file ' . $argv[3] . ' could not be opened for reading.'; |
|---|
| 24 | exit(1); |
|---|
| 25 | } |
|---|
| 26 | |
|---|
| 27 | try |
|---|
| 28 | { |
|---|
| 29 | //Generate a filename for the installer. |
|---|
| 30 | $branches = BuildBranch::Get(); |
|---|
| 31 | if (!array_key_exists($argv[1], $branches)) |
|---|
| 32 | throw new Exception('The branch ' . $argv[1] . ' does not exist.'); |
|---|
| 33 | |
|---|
| 34 | define('SHELL_WEB_ROOT', 'sftp://web.sourceforge.net/home/groups/e/er/eraser/htdocs'); |
|---|
| 35 | define('HTTP_WEB_ROOT', 'http://eraser.sourceforge.net'); |
|---|
| 36 | |
|---|
| 37 | $branch = $branches[$argv[1]]; |
|---|
| 38 | $pathInfo = pathinfo($argv[3]); |
|---|
| 39 | $fileName = sprintf('Eraser %s.%d.%s', $branch->Version, $argv[2], $pathInfo['extension']); |
|---|
| 40 | $installerPath = sprintf('/builds/%s/%s', $branch->ID, $fileName); |
|---|
| 41 | |
|---|
| 42 | //Upload the installer to the URL. |
|---|
| 43 | Upload(SHELL_WEB_ROOT . $installerPath, $file, $sftp_username, $sftp_password); |
|---|
| 44 | |
|---|
| 45 | //Then update our website builds information |
|---|
| 46 | |
|---|
| 47 | } |
|---|
| 48 | catch (Exception $e) |
|---|
| 49 | { |
|---|
| 50 | echo $e->getMessage(); |
|---|
| 51 | exit(1); |
|---|
| 52 | } |
|---|
| 53 | |
|---|
| 54 | fclose($file); |
|---|
| 55 | ?> |
|---|