REBELinBLUE\Deployer\Github\LatestRelease::latest PHP Method

latest() public method

Get the latest release from Github.
public latest ( ) : false | string
return false | string
    public function latest()
    {
        $cache_for = self::CACHE_TIME_IN_HOURS * 60;
        $release = $this->cache->remember('latest_version', $cache_for, function () {
            $request = Request::get($this->github_url)->timeoutIn(5)->expectsJson()->withAccept('application/vnd.github.v3+json');
            if (config('deployer.github_oauth_token')) {
                $request->withAuthorization('token ' . config('deployer.github_oauth_token'));
            }
            try {
                $response = $request->send();
            } catch (ConnectionErrorException $exception) {
                return false;
            }
            if ($response->hasErrors()) {
                return false;
            }
            return $response->body;
        });
        if (is_object($release)) {
            return $release->tag_name;
        }
        return false;
    }