-
Notifications
You must be signed in to change notification settings - Fork 13
/
writerss.php
executable file
·93 lines (84 loc) · 2.79 KB
/
writerss.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/usr/bin/php
<?
/*
Call as:
./writerss.php <versionfile> <build means> <downloadfile> <dsaSignature>
Ex.:
./writerss.php Output/Stacksmith.app/Contents/Info.plist nightly Output/Stacksmith.tgz 'ND0CFBfeCa1JyW21nbkBwniaOzrN6EQuAb='
*/
date_default_timezone_set('Europe/Berlin');
$updatemessage = '';
$buildsinlist = 0;
$desirednumdays = date("N");
ob_start();
passthru("git log --since=\"$desirednumdays days ago\"");
$revisions = ob_get_clean();
preg_match_all("/(Date: | )(.*)/", $revisions, $matches, PREG_SET_ORDER);
$updatemessage = "";
$lastdate = "";
$num = sizeof( $matches );
$haveul = false;
for( $x = 0; $x < $num; $x++ )
{
if( $matches[$x][1] == "Date: " )
{
$thedate = date( "Y-m-d", strtotime($matches[$x][2]));
if( $thedate != $lastdate )
{
if( $haveul )
{
$updatemessage .= "</ul>\n";
$haveul = false;
}
$updatemessage .= "<h3>".htmlentities($thedate)."</h3>\n";
$lastdate = $thedate;
}
}
else
{
if( !$haveul )
{
$updatemessage .= "<ul>\n";
$haveul = true;
}
$updatemessage .= "<li>".htmlentities($matches[$x][2])."</li>\n";
}
}
if( $haveul )
{
$updatemessage .= "</ul>\n";
}
$infoplist = file_get_contents($argv[1]);
$matches = array();
preg_match( '/<key>CFBundleVersion<\\/key>[\r\n]*/', $infoplist, $matches, PREG_OFFSET_CAPTURE );
$newoffs = $matches[0][1] +strlen($matches[0][0]);
preg_match( '/<string>(.*)?<\\/string>/', $infoplist, $matches, 0, $newoffs );
$theversion = $matches[1];
echo " Version: $theversion\n";
echo " Build: $argv[2]\n";
$actualversion = $theversion;
$tag = str_replace( "__", "_", str_replace( ".", "_", str_replace( " ", "_", str_replace( "(", "_", str_replace( ")", "_", str_replace( "a", "_a", $theversion ) ) ) ) ) );
$tag = trim ( $tag, " _\t\n\r\0\x0B" );
$downloadurl="https://github.com/uliwitness/Stacksmith/releases/download/Stacksmith_$tag/".basename($argv[3]);
$feedstr = "<?xml version=\"1.0\"?>
<rss version=\"2.0\"
xmlns:sparkle=\"http://sparkle.andymatuschak.org/rss/1.0/modules/sparkle/\">
<channel>
<title>Stacksmith ".$argv[2]." Appcast</title>
<link>http://stacksmith.org/</link>
<description>Updates for Stacksmith</description>
<item>
<title>Stacksmith $actualversion</title>
<link>$downloadurl</link>
<description>".$updatemessage."</description>
<enclosure url=\"$downloadurl\" length=\"".filesize($argv[3])."\" type=\"application/octet-stream\" sparkle:dsaSignature=\"".$argv[4]."\" />
<sparkle:version>$actualversion</sparkle:version>
</item>
</channel>
</rss>";
$fpath = dirname($argv[0]).'/../Output/'.$argv[2].'_feed.rss';
$fd = fopen($fpath,"w");
fwrite($fd,$feedstr);
fclose($fd);
echo "Written to: $fpath\n";
?>