diff --git a/action.yml b/action.yml index f362d50..9489056 100644 --- a/action.yml +++ b/action.yml @@ -1,4 +1,4 @@ -name: 'Node 12 Template Action' +name: 'Release' description: 'Creates github releases' author: 'Nick Cipollo' inputs: diff --git a/src/Releases.ts b/src/Releases.ts index 1fdfef6..0706c4d 100644 --- a/src/Releases.ts +++ b/src/Releases.ts @@ -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> { + create( + tag: string, + body?: string, + commitHash?: string, + draft?: boolean, + name?: string + ): Promise> { 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> { + return this.git.repos.uploadReleaseAsset({ + url: assetUrl, + headers: { + "content-length": contentLength, + "content-type": contentType + }, + file: file, + name: name + }) + } }