+
+ function createRelease($repo, $tag) {
+ return $this->queue(new API\Releases\CreateRelease($this, compact("repo", "tag")));
+ }
+
+ function publishRelease($repo, $id, $tag) {
+ return $this->queue(new API\Releases\PublishRelease($this, compact("repo", "id", "tag")));
+ }
+
+ function createReleaseAsset($url, $asset, $type) {
+ return $this->queue(new API\Releases\CreateReleaseAsset($this, compact("url", "asset", "type")));
+ }
+
+ function listReleaseAssets($repo, $id) {
+ return $this->queue(new API\Releases\ListReleaseAssets($this, compact("repo", "id")));
+ }
+
+ function uploadAssetForRelease($repo, $release, $config = null) {
+ return $this->listHooks($repo->full_name)->then(function($result) use($release, $repo, $config) {
+ list($repo->hooks) = $result;
+ $phar = new Pharext\Package(
+ $repo->clone_url,
+ $release->tag_name,
+ $repo->name,
+ $config ?: (array) $this->checkRepoHook($repo)->config
+ );
+ $name = $phar->build();
+ $url = uri_template($release->upload_url, compact("name"));
+ $promise = $this->createReleaseAsset($url, $phar, "application/phar");
+ if ($release->draft) {
+ return $promise->then(function($result) use($release, $repo) {
+ return $this->publishRelease($repo->full_name, $release->id, $release->tag_name);
+ });
+ }
+ return $promise;
+ });
+ }
+
+ function createReleaseFromTag($repo, $tag_name, $config = null) {
+ return $this->createRelease($repo->full_name, $tag_name)->then(function($result) use($repo, $config) {
+ list($release) = $result;
+ return $this->uploadAssetForRelease($repo, $release, $config);
+ });
+ }
+