Skip to content

Commit

Permalink
build script
Browse files Browse the repository at this point in the history
  • Loading branch information
gharlan committed Jul 21, 2016
1 parent f4e520f commit fea159d
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions bin/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/usr/bin/env php
<?php

$dir = dirname(__DIR__);

require $dir.'/workflow.php';

$plist = $dir.'/info.plist';

exec(sprintf('/usr/libexec/PlistBuddy -c "Set :version %s" %s', Workflow::VERSION, escapeshellarg($plist)));

$changelog = file_get_contents($dir.'/CHANGELOG.md');
$changelog = str_replace("\n", '\n', $changelog);
exec(sprintf('/usr/libexec/PlistBuddy -c "Set :readme \"%s\"" %s', escapeshellcmd($changelog), escapeshellarg($plist)));

$zipFile = $dir.'/github.zip';
if (file_exists($zipFile)) {
unlink($zipFile);
}

$zip = new PharData($zipFile);

$files = array(
'action.php',
'CHANGELOG.md',
'curl.php',
'icon.png',
'info.plist',
'item.php',
'LICENSE',
'README.md',
'search.php',
'server.php',
'workflow.php',
);

foreach ($files as $file) {
$zip->addFile($dir.'/'.$file, $file);
}
foreach (glob($dir.'/icons/*.png') as $path) {
$zip->addFile($path, 'icons/'.basename($path));
}

$zip->compressFiles(Phar::GZ);

$workflow = $dir.'/github.alfredworkflow';
if (file_exists($workflow)) {
unlink($workflow);
}
rename($zipFile, $workflow);

0 comments on commit fea159d

Please sign in to comment.