예제 #1
0
 function tearDown()
 {
     delete_download($this->dwn_id, false);
     parent::tearDown();
 }
#!/usr/bin/php
<?php 
$username_password = file_get_contents('.github_userpwd');
// Delete old downloads first
foreach (json_decode(file_get_contents('https://api.github.com/repos/gboudreau/Greyhole/downloads')) as $download) {
    delete_download($download->id, $download->name);
}
// Find files to upload
$version = $argv[1];
foreach (glob("release/*{$version}*") as $file) {
    $filename = basename($file);
    if (strpos($filename, 'hda-greyhole-') !== FALSE || strpos($filename, '.src.rpm') !== FALSE || strpos($filename, 'greyhole-web-app') !== FALSE || strpos($filename, '.armv5tel.') !== FALSE) {
        // Skip those files
        continue;
    }
    $file_type = get_file_type($filename);
    $description = "Greyhole {$version} ({$file_type})";
    echo "Uploading {$filename} with description {$description}...\n";
    // Create the download metadata on Github
    $response = create_download($filename, filesize($file), $description);
    // Upload the actual file on Amazon S3
    upload_file($file, $response);
}
function delete_download($id, $filename)
{
    global $username_password;
    $url = "https://api.github.com/repos/gboudreau/Greyhole/downloads/{$id}";
    echo "DELETE {$url} ({$filename})\n";
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');