Class RemoteRepoReleaseApi
Implements the friendly GitHub repository release related APIs.
Namespace: Neon.GitHub
Assembly: Neon.GitHub.dll
Syntax
public class RemoteRepoReleaseApi
Methods
AddAssetAsync(Release, Stream, string, string)
Uploads an asset stream to a GitHub release. Any existing asset with same name will be replaced.
note
This only works for unpublished releases where Draft=true
.
Declaration
public Task<ReleaseAsset> AddAssetAsync(Release release, Stream stream, string assetName, string contentType = "application/octet-stream")
Parameters
Type | Name | Description |
---|---|---|
Release | release | The target release. |
Stream | stream | The asset source stream. |
string | assetName | Specifies the file name to assign to the asset. |
string | contentType | Optionally specifies the asset's Content-Type. This defaults to: application/octet-stream |
Returns
Type | Description |
---|---|
Task<ReleaseAsset> | The new Octokit.ReleaseAsset. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the GitHubRepo has been disposed. |
AddAssetAsync(Release, string, string, string)
Uploads an asset file to a GitHub release. Any existing asset with same name will be replaced.
note
This only works for unpublished releases where Draft=true
.
Declaration
public Task<ReleaseAsset> AddAssetAsync(Release release, string assetPath, string assetName = null, string contentType = "application/octet-stream")
Parameters
Type | Name | Description |
---|---|---|
Release | release | The target release. |
string | assetPath | Path to the source asset file. |
string | assetName | Optionally specifies the file name to assign to the asset. This defaults to the file name in |
string | contentType | Optionally specifies the asset's Content-Type. This defaults to: application/octet-stream |
Returns
Type | Description |
---|---|
Task<ReleaseAsset> | The new Octokit.ReleaseAsset. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the GitHubRepo has been disposed. |
NotSupportedException | Thrown when the releas has already been published. |
AddMultipartAssetAsync(Release, string, string, string, string, bool, long)
Uploads a multi-part download to a release as an asset and then publishes the release.
Declaration
public Task<DownloadManifest> AddMultipartAssetAsync(Release release, string sourcePath, string version, string name = null, string filename = null, bool noMd5File = false, long maxPartSize = 78643200)
Parameters
Type | Name | Description |
---|---|---|
Release | release | The target release. |
string | sourcePath | Path to the file being uploaded. |
string | version | The download version. |
string | name | Optionally overrides the download file name specified by |
string | filename | Optionally overrides the download file name specified by |
bool | noMd5File | This method creates a file named [ |
long | maxPartSize | Optionally overrides the maximum part size (defaults to 75 MiB). |
Returns
Type | Description |
---|---|
Task<DownloadManifest> | The DownloadManifest. |
Remarks
The release passed must be unpublished and you may upload other assets before calling this.
note
Take care that any assets already published have names that won't conflict with the asset part names, which will be formatted like: part-##
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the GitHubRepo has been disposed. |
CreateAsync(string, string, string, bool, bool)
Creates a GitHub release.
Declaration
public Task<Release> CreateAsync(string tagName, string releaseName = null, string body = null, bool draft = false, bool prerelease = false)
Parameters
Type | Name | Description |
---|---|---|
string | tagName | Specifies the release name. |
string | releaseName | Optionally specifies the release name (defaults to |
string | body | Optionally specifies the markdown formatted release notes. |
bool | draft | Optionally indicates that the release won't be published immediately. |
bool | prerelease | Optionally indicates that the release is not production ready. |
Returns
Type | Description |
---|---|
Task<Release> | The new release. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the GitHubRepo has been disposed. |
DeleteAsync(string)
Removes a GitHub release by name, if it exists.
note
It's possible to have multiple releases with the same name. This method will remove all of them.
Declaration
public Task<bool> DeleteAsync(string releaseName)
Parameters
Type | Name | Description |
---|---|---|
string | releaseName | Specifies the release name. |
Returns
Type | Description |
---|---|
Task<bool> |
|
DownloadZipballAsync(string, Stream)
Returns the zipped source code (Zipball) for a published release.
note
The repository files in the Zipball are are persisted to a root folder named like REPONAME-COMMIT where REPONAME is the name of the GitHub repository and COMMIT is the latest commit for the repo.
Declaration
public Task DownloadZipballAsync(string releaseName, Stream output)
Parameters
Type | Name | Description |
---|---|---|
string | releaseName | Specifies the release name. |
Stream | output | Specifies the stream where the Zipball will be written. |
Returns
Type | Description |
---|---|
Task | The tracking Task. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the GitHubRepo has been disposed. |
InvalidOperationException | Thrown if the release does not exist or it has not been published. |
FindAsync(string)
Searches for a specific GitHub origin repository release.
Declaration
public Task<Release> FindAsync(string releaseName)
Parameters
Type | Name | Description |
---|---|---|
string | releaseName | Specifies the origin repository release name. |
Returns
Type | Description |
---|---|
Task<Release> | The requested Octokit.Release or |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the GitHubRepo has been disposed. |
GetAllAsync()
Returns all releases from the GitHub origin repository.
Declaration
public Task<IReadOnlyList<Release>> GetAllAsync()
Returns
Type | Description |
---|---|
Task<IReadOnlyList<Release>> | The list of releases. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the GitHubRepo has been disposed. |
GetAssetUri(Release, ReleaseAsset)
Returns the URI that can be used to download a GitHub release asset.
note
This works only for published releases.
Declaration
public string GetAssetUri(Release release, ReleaseAsset asset)
Parameters
Type | Name | Description |
---|---|---|
Release | release | The target release. |
ReleaseAsset | asset | The target asset. |
Returns
Type | Description |
---|---|
string | The asset URI. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the GitHubRepo has been disposed. |
InvalidOperationException | Thrown when the asset passed doesn't exist in the release. |
GetAsync(string)
Returns a specific GitHub origin repository release.
Declaration
public Task<Release> GetAsync(string releaseName)
Parameters
Type | Name | Description |
---|---|---|
string | releaseName | Specifies the origin repository release name. |
Returns
Type | Description |
---|---|
Task<Release> | The requested Octokit.Release. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the GitHubRepo has been disposed. |
NotFoundException | Thrown when the release does not exist. |
GetZipballUri(string)
Returns the URI for the zipped source code (Zipball) for a published release.
Declaration
public Task<string> GetZipballUri(string releaseName)
Parameters
Type | Name | Description |
---|---|---|
string | releaseName | Specifies the release name. |
Returns
Type | Description |
---|---|
Task<string> | The zipball URI. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the GitHubRepo has been disposed. |
InvalidOperationException | Thrown if the release does not exist or it has not been published. |
PublishAsync(string)
Publishes a release.
Declaration
public Task<Release> PublishAsync(string releaseName)
Parameters
Type | Name | Description |
---|---|---|
string | releaseName | Specifies the release name. |
Returns
Type | Description |
---|---|
Task<Release> | The published release. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the GitHubRepo has been disposed. |
InvalidOperationException | Thrown if the release doesn't exist or when it's already published. |
RefreshAsync(Release)
Returns the latest version of a release.
Declaration
public Task<Release> RefreshAsync(Release release)
Parameters
Type | Name | Description |
---|---|---|
Release | release | The release being refreshed. |
Returns
Type | Description |
---|---|
Task<Release> | The updated release. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Thrown when the relase no longer exists. |
UpdateAsync(Release, ReleaseUpdate)
Updates an existing GitHub release.
Declaration
public Task<Release> UpdateAsync(Release release, ReleaseUpdate releaseUpdate)
Parameters
Type | Name | Description |
---|---|---|
Release | release | Specifies the release being changed. |
ReleaseUpdate | releaseUpdate | Specifies the release revisions. |
Returns
Type | Description |
---|---|
Task<Release> | The updated release. |
Remarks
To update a release, you'll first need to:
- Create a new release or get and existing one.
- Obtain a Octokit.ReleaseUpdate by calling Octokit.Release.ToUpdate().
- Make your changes to the release update.
- Call UpdateAsync(Release, ReleaseUpdate), passing the original release along with the update.
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | Thrown when the GitHubRepo has been disposed. |