public function git_upload($file) { require_once __root__ . '/SimpleVers/system/github/client/GitHubClient.php'; $owner = $this->owner; $repo = $this->github_repo; $username = $this->github_user; $password = $this->github_pass; $tag_name = basename($file); $target_commitish = 'master'; $name = $this->name; $body = $this->description; $draft = false; $prerelease = false; $client = new GitHubClient(); $client->setDebug(false); $client->setCredentials($username, $password); try { $release = $client->repos->releases->create($owner, $repo, $tag_name, $target_commitish, $name, $body, $draft, $prerelease); $releaseId = $release->getId(); $filePath = $file; $contentType = 'application/php'; $name = basename($file); try { $client->repos->releases->assets->upload($owner, $repo, $releaseId, $name, $contentType, $filePath); echo "<img src='/SimpleVers/interface/images/success.png'><h2>File successfully uploaded.</h2>"; } catch (Exception $e) { echo "Error: " . $e; } } catch (Exception $e) { echo "<img src='/SimpleVers/interface/images/cloud.png'><h2>This file seems to be already uploaded.</h2>"; } }
public function reuploadRelease() { require_once __DIR__ . '/vendor/tan-tan-kanarek/github-php-client/client/GitHubClient.php'; $client = new GitHubClient(); $client->setDebug(true); $client->setAuthType(GitHubClient::GITHUB_AUTH_TYPE_BASIC); $client->setCredentials('daviddeutsch', trim(file_get_contents(__DIR__ . '/../github-oauth.token'))); foreach (glob(__DIR__ . '/tmp/*.zip') as $path) { $file = $path; } $release = $client->repos->releases->get('valanx', 'aec', 'latest'); $client->repos->releases->assets->upload('valanx', 'aec', $release->getId(), basename($file), 'application/zip', $file); }