Flesh out releases

This commit is contained in:
Nick Cipollo
2019-08-26 16:51:58 -04:00
parent 6c11905fe1
commit 0416a360c1
2 changed files with 30 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
name: 'Node 12 Template Action'
name: 'Release'
description: 'Creates github releases'
author: 'Nick Cipollo'
inputs:

View File

@@ -1,6 +1,6 @@
import { Context } from "@actions/github/lib/context";
import { GitHub } from "@actions/github";
import { Response, ReposCreateReleaseResponse } from "@octokit/rest";
import { AnyResponse, Response, ReposCreateReleaseResponse } from "@octokit/rest";
export class Releases {
context: Context
@@ -11,14 +11,39 @@ export class Releases {
this.git = git
}
async create(tag: string, commitHash?: string): Promise<Response<ReposCreateReleaseResponse>> {
create(
tag: string,
body?: string,
commitHash?: string,
draft?: boolean,
name?: string
): Promise<Response<ReposCreateReleaseResponse>> {
return this.git.repos.createRelease({
name: "Test release",
draft: true,
body: body,
name: name,
draft: draft,
owner: this.context.repo.owner,
repo: this.context.repo.repo,
target_commitish: commitHash,
tag_name: tag
})
}
uploadArtifact(
assetUrl: string,
contentLength: number,
contentType: string,
file: string,
name: string
): Promise<Response<AnyResponse>> {
return this.git.repos.uploadReleaseAsset({
url: assetUrl,
headers: {
"content-length": contentLength,
"content-type": contentType
},
file: file,
name: name
})
}
}