Skip to content

Added support for pre-releases and drafts

Latest
Compare
Choose a tag to compare
@thedava thedava released this 28 Mar 17:48

Support for pre-releases and drafts

/**
 * @param bool $includePreReleases
 * @param bool $includeDrafts
 *
 * @return array|false
 */
public function getMostRecentReleaseInformation($includePreReleases = true, $includeDrafts = false)

Fetch the latest (stable) release

This method always returns the latest stable release (even if there are newer pre-releases and/or drafts).

$data = $assetFileDownloader->getReleaseInformation();

echo PHP_EOL, 'Release', PHP_EOL,
data['tag_name'], PHP_EOL,
'Draft: ', ($data['draft']) ? 'Yes' : 'No', PHP_EOL,
'PreRelease: ', ($data['prerelease']) ? 'Yes' : 'No', PHP_EOL;

Release
0.5.3.1
Draft: No
PreRelease: No

Fetch the latest release

This method returns the most recent release, even if it is a pre-release or a draft. This method can also return a stable release if it is the most recent.

Attention: Use this method only if you explicitly want to include pre-releases and/or drafts (e.g. for a beta update channel feature). It fetches all releases from the GitHub api internally and iterates over them until the first release matches the expectation.

$data = $assetFileDownloader->getMostRecentReleaseInformation();

echo PHP_EOL, 'PreRelease', PHP_EOL,
data['tag_name'], PHP_EOL,
'Draft: ', ($data['draft']) ? 'Yes' : 'No', PHP_EOL,
'PreRelease: ', ($data['prerelease']) ? 'Yes' : 'No', PHP_EOL;

PreRelease
0.6.3
Draft: No
PreRelease: Yes