$tag = $release->tag_name;
settype($repo->tags->$tag, "object");
$repo->tags->$tag->release = $release;
+ $this->github->listReleaseAssets($repo->full_name, $release->id, function($assets) use($release) {
+ $release->assets = $assets;
+ });
}
};
}
$call = new API\Releases\CreateReleaseAsset($this, compact("url", "asset", "type"));
return $call($callback);
}
+
+ function listReleaseAssets($repo, $id, callable $callback) {
+ $call = new API\Releases\ListReleaseAssets($this, compact("repo", "id"));
+ return $call($callback);
+ }
}
namespace app\Github\API\Releases;
-class ListReleaseAssets extends \app\Github\API\Call
+use app\Github\API\Call;
+use app\Github\Exception\RequestException;
+use app\Github\Links;
+use http\Client\Request;
+
+class ListReleaseAssets extends Call
{
function enqueue(callable $callback) {
- $url = $this->url->mod(uri_template("./repos/{+repo}/releases{/release}/assets", $this->args));
- $request = new \http\Client\Request("GET", $url, [
+ $url = $this->url->mod(uri_template("./repos/{+repo}/releases{/id}/assets", $this->args));
+ $request = new Request("GET", $url, [
"Authorization" => "token ". $this->api->getToken(),
"Accept" => $this->config->api->accept,
]);
$this->api->getClient()->enqueue($request, function($response) use($callback) {
if ($response->getResponseCode() >= 400 || null === ($json = json_decode($response->getBody()))) {
- throw new \app\Github\Exception\RequestException($response);
+ throw new RequestException($response);
}
$links = new Links($response->getHeader("Link"));
$this->saveToCache([$json, $links]);
</h3>
</div>
<div class="panel-body">
+ <div class="row">
+ <div class="col-md-8">
<?php if (!empty($v->release)) : ?>
<p><?= $this->md($v->release->body) ?></p>
<?php endif; ?>
</span>
<?php endif; ?>
</ul>
+ </div>
+ <div class="col-md-4">
+ <?php if (!empty($v->release->assets)) : ?>
+ <ul class="list-inline pull-right">
+ <?php foreach ($v->release->assets as $asset) : ?>
+ <?php if (fnmatch("*.ext.phar", $asset->name)) : ?>
+ <li>
+ <a class="btn btn-success" href="<?= $this->e($asset->browser_download_url) ?>">
+ <span class="octicon octicon-package"></span>
+ <?= $this->e($asset->name) ?>
+ </a>
+ </li>
+ <?php endif; ?>
+ <?php endforeach; ?>
+ </ul>
+ <?php endif; ?>
+ </div>
+ </div>
</div>
</div>
<?php endforeach; ?>