Class GitHubReleaseApi
Used to publish and manage GitHub releases.
Namespace: Neon.Deployment
Assembly: Neon.Deployment.dll
Syntax
public class GitHubReleaseApi
Remarks
note
This API doesn't currently support modifying assets of of published releases although GitHub does support this. We may add this functionality in the future.
Methods
Create(string, string, string, string, bool, bool, string)
Creates a GitHub release.
Declaration
public Release Create(string repo, string tagName, string releaseName = null, string body = null, bool draft = false, bool prerelease = false, string branch = null)
Parameters
Type | Name | Description |
---|---|---|
string | repo | Identifies the target repo. |
string | tagName | Specifies the tag to be referenced by the release. |
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. |
string | branch | Optionally identifies the branch to be tagged. This defaults to master or main when either of those branches are already present. |
Returns
Type | Description |
---|---|
Release | The newly created Release. |
Remarks
If the tagName
doesn't already exist in the repo, this method will
tag the latest commit on the specified branch
or else the defailt branch
in the target repo and before creating the release.
Find(string, Func<Release, bool>)
Returns the releases that satisfies a predicate.
Declaration
public List<Release> Find(string repo, Func<Release, bool> predicate)
Parameters
Type | Name | Description |
---|---|---|
string | repo | Identifies the target repository. |
Func<Release, bool> | predicate | The predicate. |
Returns
Type | Description |
---|---|
List<Release> | The list of matching releases. |
Get(string, string)
Retrieves a specific GitHub release.
Declaration
public Release Get(string repo, string tagName)
Parameters
Type | Name | Description |
---|---|---|
string | repo | Identifies the target repository. |
string | tagName | Specifies the tag for the target release. |
Returns
Type | Description |
---|---|
Release | The release information or |
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. |
List(string)
List the releases for a GitHub repo.
Declaration
public IReadOnlyList<Release> List(string repo)
Parameters
Type | Name | Description |
---|---|---|
string | repo |
Returns
Type | Description |
---|---|
IReadOnlyList<Release> | The list of releases. |
Remove(string, Release)
Deletes a GitHub release.
Declaration
public void Remove(string repo, Release release)
Parameters
Type | Name | Description |
---|---|---|
string | repo | Identifies the target repository. |
Release | release | The target release. |
Remarks
note
This fails silently if the release doesn't exist.
Update(string, Release, ReleaseUpdate)
Updates a GitHub release.
Declaration
public Release Update(string repo, Release release, ReleaseUpdate releaseUpdate)
Parameters
Type | Name | Description |
---|---|---|
string | repo | Identifies the target repository. |
Release | release | Specifies the release being updated. |
ReleaseUpdate | releaseUpdate | Specifies the revisions. |
Returns
Type | Description |
---|---|
Release | The updated release. |
Remarks
To update a release, you'll first need to:
- Obtain a Release referencing the target release returned from Create(string, string, string, string, bool, bool, string) or by listing or getting releases.
- Obtain a ReleaseUpdate by calling Release.ToUpdate.
- Make your changes to the release update.
- Call Update(string, Release, ReleaseUpdate), passing the original release along with the update.
UploadAsset(string, Release, Stream, string, string)
Uploads an asset stream to a GitHub release. Any existing asset with same name will be replaced.
Declaration
public ReleaseAsset UploadAsset(string repo, Release release, Stream assetStream, string assetName, string contentType = "application/octet-stream")
Parameters
Type | Name | Description |
---|---|---|
string | repo | Identifies the target repository. |
Release | release | The target release. |
Stream | assetStream | 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 |
---|---|
ReleaseAsset | The new ReleaseAsset. |
UploadAsset(string, Release, string, string, string)
Uploads an asset file to a GitHub release. Any existing asset with same name will be replaced.
Declaration
public ReleaseAsset UploadAsset(string repo, Release release, string assetPath, string assetName = null, string contentType = "application/octet-stream")
Parameters
Type | Name | Description |
---|---|---|
string | repo | Identifies the target repository. |
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 |
---|---|
ReleaseAsset | The new ReleaseAsset. |
Remarks
note
The current implementation only works for unpublished releases where Draft=true
.
Exceptions
Type | Condition |
---|---|
NotSupportedException | Thrown when the releas has already been published. |
UploadMultipartAsset(string, Release, string, string, string, string, bool, long)
Uploads a multi-part download to a release and then publishes the release.
Declaration
public DownloadManifest UploadMultipartAsset(string repo, Release release, string sourcePath, string version, string name = null, string filename = null, bool noMd5File = false, long maxPartSize = 78643200)
Parameters
Type | Name | Description |
---|---|---|
string | repo | Identifies the target repository. |
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 |
---|---|
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-##
note
Unlike the S3 implementation, this method uploads the parts to GitHub on a single thread.