Fixes #6 Add support for updating releases
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
This action will create a github release and optionally upload an artifact to it.
|
This action will create a github release and optionally upload an artifact to it.
|
||||||
|
|
||||||
## Action Inputs
|
## Action Inputs
|
||||||
|
- **allowUpdates**: An optional flag which indicates if we should update a release if it already exists. Defaults to false.
|
||||||
- **artifact**: An optional set of paths representing artifacts to upload to the release. This may be a single path or a comma delimited list of paths (or globs).
|
- **artifact**: An optional set of paths representing artifacts to upload to the release. This may be a single path or a comma delimited list of paths (or globs).
|
||||||
- **artifacts**: An optional set of paths representing artifacts to upload to the release. This may be a single path or a comma delimited list of paths (or globs).
|
- **artifacts**: An optional set of paths representing artifacts to upload to the release. This may be a single path or a comma delimited list of paths (or globs).
|
||||||
- **artifactContentType**: The content type of the artifact. Defaults to raw.
|
- **artifactContentType**: The content type of the artifact. Defaults to raw.
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import { Releases } from "../src/Releases";
|
|||||||
import { ArtifactUploader } from "../src/ArtifactUploader";
|
import { ArtifactUploader } from "../src/ArtifactUploader";
|
||||||
|
|
||||||
const createMock = jest.fn()
|
const createMock = jest.fn()
|
||||||
|
const getMock = jest.fn()
|
||||||
|
const updateMock = jest.fn()
|
||||||
const uploadMock = jest.fn()
|
const uploadMock = jest.fn()
|
||||||
|
|
||||||
const artifacts = [
|
const artifacts = [
|
||||||
@@ -14,9 +16,8 @@ const artifacts = [
|
|||||||
const artifactData = Buffer.from('blob', 'utf-8')
|
const artifactData = Buffer.from('blob', 'utf-8')
|
||||||
const body = 'body'
|
const body = 'body'
|
||||||
const commit = 'commit'
|
const commit = 'commit'
|
||||||
const contentType = "raw"
|
|
||||||
const contentLength = 100
|
|
||||||
const draft = true
|
const draft = true
|
||||||
|
const id = 100
|
||||||
const name = 'name'
|
const name = 'name'
|
||||||
const tag = 'tag'
|
const tag = 'tag'
|
||||||
const token = 'token'
|
const token = 'token'
|
||||||
@@ -25,11 +26,13 @@ const url = 'http://api.example.com'
|
|||||||
describe("Action", () => {
|
describe("Action", () => {
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
createMock.mockClear()
|
createMock.mockClear()
|
||||||
|
getMock.mockClear()
|
||||||
|
updateMock.mockClear()
|
||||||
uploadMock.mockClear()
|
uploadMock.mockClear()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('creates release but does not upload if no artifact', async () => {
|
it('creates release but does not upload if no artifact', async () => {
|
||||||
const action = createAction(false)
|
const action = createAction(false, false)
|
||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
@@ -38,12 +41,7 @@ describe("Action", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('creates release then uploads artifact', async () => {
|
it('creates release then uploads artifact', async () => {
|
||||||
const action = createAction(true)
|
const action = createAction(false, true)
|
||||||
createMock.mockResolvedValue({
|
|
||||||
data: {
|
|
||||||
upload_url: url
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
@@ -52,7 +50,7 @@ describe("Action", () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('throws error when create fails', async () => {
|
it('throws error when create fails', async () => {
|
||||||
const action = createAction(true)
|
const action = createAction(false, true)
|
||||||
createMock.mockRejectedValue("error")
|
createMock.mockRejectedValue("error")
|
||||||
|
|
||||||
expect.hasAssertions()
|
expect.hasAssertions()
|
||||||
@@ -66,13 +64,56 @@ describe("Action", () => {
|
|||||||
expect(uploadMock).not.toBeCalled()
|
expect(uploadMock).not.toBeCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('throws error when get fails', async () => {
|
||||||
|
const action = createAction(true, false)
|
||||||
|
const error = {
|
||||||
|
errors: [
|
||||||
|
{
|
||||||
|
code: 'already_exists'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
createMock.mockRejectedValue(error)
|
||||||
|
getMock.mockRejectedValue("error")
|
||||||
|
expect.hasAssertions()
|
||||||
|
try {
|
||||||
|
await action.perform()
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).toEqual("error")
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(createMock).toBeCalledWith(tag, body, commit, draft, name)
|
||||||
|
expect(uploadMock).not.toBeCalled()
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
it('throws error when update fails', async () => {
|
||||||
|
const action = createAction(true, false)
|
||||||
|
const error = {
|
||||||
|
errors: [
|
||||||
|
{
|
||||||
|
code: 'already_exists'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
createMock.mockRejectedValue(error)
|
||||||
|
updateMock.mockRejectedValue("error")
|
||||||
|
expect.hasAssertions()
|
||||||
|
try {
|
||||||
|
await action.perform()
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).toEqual("error")
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(createMock).toBeCalledWith(tag, body, commit, draft, name)
|
||||||
|
expect(uploadMock).not.toBeCalled()
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
it('throws error when upload fails', async () => {
|
it('throws error when upload fails', async () => {
|
||||||
const action = createAction(true)
|
const action = createAction(false, true)
|
||||||
createMock.mockResolvedValue({
|
|
||||||
data: {
|
|
||||||
upload_url: url
|
|
||||||
}
|
|
||||||
})
|
|
||||||
uploadMock.mockRejectedValue("error")
|
uploadMock.mockRejectedValue("error")
|
||||||
|
|
||||||
expect.hasAssertions()
|
expect.hasAssertions()
|
||||||
@@ -86,7 +127,45 @@ describe("Action", () => {
|
|||||||
expect(uploadMock).toBeCalledWith(artifacts, url)
|
expect(uploadMock).toBeCalledWith(artifacts, url)
|
||||||
})
|
})
|
||||||
|
|
||||||
function createAction(hasArtifact: boolean): Action {
|
it('updates release but does not upload if no artifact', async () => {
|
||||||
|
const action = createAction(true, false)
|
||||||
|
const error = {
|
||||||
|
errors: [
|
||||||
|
{
|
||||||
|
code: 'already_exists'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
createMock.mockRejectedValue(error)
|
||||||
|
|
||||||
|
await action.perform()
|
||||||
|
|
||||||
|
expect(createMock).toBeCalledWith(tag, body, commit, draft, name)
|
||||||
|
expect(uploadMock).not.toBeCalled()
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
it('updates release then uploads artifact', async () => {
|
||||||
|
const action = createAction(true, true)
|
||||||
|
const error = {
|
||||||
|
errors: [
|
||||||
|
{
|
||||||
|
code: 'already_exists'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
createMock.mockRejectedValue(error)
|
||||||
|
|
||||||
|
await action.perform()
|
||||||
|
|
||||||
|
expect(createMock).toBeCalledWith(tag, body, commit, draft, name)
|
||||||
|
expect(uploadMock).toBeCalledWith(artifacts, url)
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
function createAction(allowUpdates: boolean, hasArtifact: boolean): Action {
|
||||||
let inputArtifact: Artifact[]
|
let inputArtifact: Artifact[]
|
||||||
if (hasArtifact) {
|
if (hasArtifact) {
|
||||||
inputArtifact = artifacts
|
inputArtifact = artifacts
|
||||||
@@ -96,11 +175,32 @@ describe("Action", () => {
|
|||||||
const MockReleases = jest.fn<Releases, any>(() => {
|
const MockReleases = jest.fn<Releases, any>(() => {
|
||||||
return {
|
return {
|
||||||
create: createMock,
|
create: createMock,
|
||||||
uploadArtifact: jest.fn()
|
getByTag: getMock,
|
||||||
|
update: updateMock,
|
||||||
|
uploadArtifact: uploadMock
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
createMock.mockResolvedValue({
|
||||||
|
data: {
|
||||||
|
upload_url: url
|
||||||
|
}
|
||||||
|
})
|
||||||
|
getMock.mockResolvedValue({
|
||||||
|
data: {
|
||||||
|
id: id
|
||||||
|
}
|
||||||
|
})
|
||||||
|
updateMock.mockResolvedValue({
|
||||||
|
data: {
|
||||||
|
upload_url: url
|
||||||
|
}
|
||||||
|
})
|
||||||
|
uploadMock.mockResolvedValue({})
|
||||||
|
|
||||||
const MockInputs = jest.fn<Inputs, any>(() => {
|
const MockInputs = jest.fn<Inputs, any>(() => {
|
||||||
return {
|
return {
|
||||||
|
allowUpdates: allowUpdates,
|
||||||
artifacts: inputArtifact,
|
artifacts: inputArtifact,
|
||||||
body: body,
|
body: body,
|
||||||
commit: commit,
|
commit: commit,
|
||||||
|
|||||||
@@ -1,6 +1,33 @@
|
|||||||
import { ErrorMessage } from "../src/ErrorMessage"
|
import { ErrorMessage } from "../src/ErrorMessage"
|
||||||
|
|
||||||
describe('ErrorMessage', () => {
|
describe('ErrorMessage', () => {
|
||||||
|
|
||||||
|
describe('has error with code', () => {
|
||||||
|
const error = {
|
||||||
|
message: 'something bad happened',
|
||||||
|
errors: [
|
||||||
|
{
|
||||||
|
code: 'missing',
|
||||||
|
resource: 'release'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'already_exists',
|
||||||
|
resource: 'release'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
it('does not have error', ()=> {
|
||||||
|
const errorMessage = new ErrorMessage(error)
|
||||||
|
expect(errorMessage.hasErrorWithCode('missing_field')).toBeFalsy()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('has error', ()=> {
|
||||||
|
const errorMessage = new ErrorMessage(error)
|
||||||
|
expect(errorMessage.hasErrorWithCode('missing')).toBeTruthy()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
it('generates message with errors', () => {
|
it('generates message with errors', () => {
|
||||||
const resource = "release"
|
const resource = "release"
|
||||||
const error = {
|
const error = {
|
||||||
|
|||||||
@@ -1,6 +1,17 @@
|
|||||||
import { GithubError } from "../src/GithubError"
|
import { GithubError } from "../src/GithubError"
|
||||||
|
|
||||||
describe('GithubError', () => {
|
describe('GithubError', () => {
|
||||||
|
|
||||||
|
it('provides error code', () => {
|
||||||
|
const error = {
|
||||||
|
code: "missing"
|
||||||
|
}
|
||||||
|
|
||||||
|
const githubError = new GithubError(error)
|
||||||
|
|
||||||
|
expect(githubError.code).toBe('missing')
|
||||||
|
})
|
||||||
|
|
||||||
it('generates missing resource error message', () => {
|
it('generates missing resource error message', () => {
|
||||||
const resource = "release"
|
const resource = "release"
|
||||||
const error = {
|
const error = {
|
||||||
|
|||||||
@@ -43,6 +43,17 @@ describe('Inputs', () => {
|
|||||||
expect(inputs.token).toBe('42')
|
expect(inputs.token).toBe('42')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('allowsUpdates', () => {
|
||||||
|
it('returns false', () => {
|
||||||
|
expect(inputs.allowUpdates).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('returns true', () => {
|
||||||
|
mockGetInput.mockReturnValue('true')
|
||||||
|
expect(inputs.allowUpdates).toBe(true)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('artifacts', () => {
|
describe('artifacts', () => {
|
||||||
it('returns empty artifacts', () => {
|
it('returns empty artifacts', () => {
|
||||||
mockGetInput.mockReturnValueOnce('')
|
mockGetInput.mockReturnValueOnce('')
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ name: 'Create Release'
|
|||||||
description: 'Creates github releases'
|
description: 'Creates github releases'
|
||||||
author: 'Nick Cipollo'
|
author: 'Nick Cipollo'
|
||||||
inputs:
|
inputs:
|
||||||
|
allowUpdates:
|
||||||
|
description: 'An optional flag which indicates if we should update a release if it already exists. Defaults to false.'
|
||||||
|
default: ''
|
||||||
artifact:
|
artifact:
|
||||||
description: 'An optional set of paths representing artifacts to upload to the release. This may be a single path or a comma delimited list of paths (or globs)'
|
description: 'An optional set of paths representing artifacts to upload to the release. This may be a single path or a comma delimited list of paths (or globs)'
|
||||||
default: ''
|
default: ''
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import { Inputs } from "./Inputs";
|
import { Inputs } from "./Inputs";
|
||||||
import { Releases } from "./Releases";
|
import { Releases } from "./Releases";
|
||||||
import { ArtifactUploader } from "./ArtifactUploader";
|
import { ArtifactUploader } from "./ArtifactUploader";
|
||||||
|
import { ErrorMessage } from "./ErrorMessage";
|
||||||
|
import { Response, ReposCreateReleaseResponse } from "@octokit/rest";
|
||||||
|
|
||||||
export class Action {
|
export class Action {
|
||||||
private inputs: Inputs
|
private inputs: Inputs
|
||||||
@@ -14,7 +16,28 @@ export class Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async perform() {
|
async perform() {
|
||||||
const createResult = await this.releases.create(
|
const uploadUrl = await this.createOrUpdateRelease()
|
||||||
|
|
||||||
|
const artifacts = this.inputs.artifacts
|
||||||
|
if (artifacts.length > 0) {
|
||||||
|
await this.uploader.uploadArtifacts(artifacts, uploadUrl)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async createOrUpdateRelease(): Promise<string> {
|
||||||
|
try {
|
||||||
|
return await this.createRelease()
|
||||||
|
} catch (error) {
|
||||||
|
if (this.releaseAlreadyExisted(error) && this.inputs.allowUpdates) {
|
||||||
|
return this.updateRelease()
|
||||||
|
} else {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async createRelease(): Promise<string> {
|
||||||
|
const response = await this.releases.create(
|
||||||
this.inputs.tag,
|
this.inputs.tag,
|
||||||
this.inputs.body,
|
this.inputs.body,
|
||||||
this.inputs.commit,
|
this.inputs.commit,
|
||||||
@@ -22,12 +45,27 @@ export class Action {
|
|||||||
this.inputs.name
|
this.inputs.name
|
||||||
)
|
)
|
||||||
|
|
||||||
const artifacts = this.inputs.artifacts
|
return response.data.upload_url
|
||||||
if (artifacts.length > 0) {
|
}
|
||||||
await this.uploader.uploadArtifacts(
|
|
||||||
artifacts,
|
private releaseAlreadyExisted(error: any): boolean {
|
||||||
createResult.data.upload_url
|
const errorMessage = new ErrorMessage(error)
|
||||||
)
|
return errorMessage.hasErrorWithCode('already_exists')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async updateRelease(): Promise<string> {
|
||||||
|
const getResponse = await this.releases.getByTag(this.inputs.tag)
|
||||||
|
const id = getResponse.data.id
|
||||||
|
|
||||||
|
const response = await this.releases.update(
|
||||||
|
id,
|
||||||
|
this.inputs.tag,
|
||||||
|
this.inputs.body,
|
||||||
|
this.inputs.commit,
|
||||||
|
this.inputs.draft,
|
||||||
|
this.inputs.name
|
||||||
|
)
|
||||||
|
|
||||||
|
return response.data.upload_url
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2,7 +2,7 @@ import { Artifact } from "./Artifact";
|
|||||||
import { Releases } from "./Releases";
|
import { Releases } from "./Releases";
|
||||||
|
|
||||||
export interface ArtifactUploader {
|
export interface ArtifactUploader {
|
||||||
uploadArtifacts(artifacts: Artifact[], uploadUrl: string): void
|
uploadArtifacts(artifacts: Artifact[], uploadUrl: string): Promise<void>
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GithubArtifactUploader implements ArtifactUploader {
|
export class GithubArtifactUploader implements ArtifactUploader {
|
||||||
|
|||||||
@@ -1,23 +1,15 @@
|
|||||||
import { GithubError } from "./GithubError"
|
import { GithubError } from "./GithubError"
|
||||||
|
|
||||||
export class ErrorMessage {
|
export class ErrorMessage {
|
||||||
error: any
|
private error: any
|
||||||
|
private githubErrors: GithubError[]
|
||||||
|
|
||||||
constructor(error: any) {
|
constructor(error: any) {
|
||||||
this.error = error
|
this.error = error
|
||||||
|
this.githubErrors = this.generateGithubErrors()
|
||||||
}
|
}
|
||||||
|
|
||||||
toString(): string {
|
private generateGithubErrors(): GithubError[] {
|
||||||
const message = this.error.message
|
|
||||||
const errors = this.githubErrors()
|
|
||||||
if (errors.length > 0) {
|
|
||||||
return `${message}\nErrors:\n${this.errorBulletedList(errors)}`
|
|
||||||
} else {
|
|
||||||
return message
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
githubErrors(): GithubError[] {
|
|
||||||
const errors = this.error.errors
|
const errors = this.error.errors
|
||||||
if (errors instanceof Array) {
|
if (errors instanceof Array) {
|
||||||
return errors.map((err) => new GithubError(err))
|
return errors.map((err) => new GithubError(err))
|
||||||
@@ -26,7 +18,21 @@ export class ErrorMessage {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
errorBulletedList(errors: GithubError[]): string {
|
hasErrorWithCode(code: String): boolean {
|
||||||
|
return this.githubErrors.some((err) => err.code == code)
|
||||||
|
}
|
||||||
|
|
||||||
|
toString(): string {
|
||||||
|
const message = this.error.message
|
||||||
|
const errors = this.githubErrors
|
||||||
|
if (errors.length > 0) {
|
||||||
|
return `${message}\nErrors:\n${this.errorBulletedList(errors)}`
|
||||||
|
} else {
|
||||||
|
return message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private errorBulletedList(errors: GithubError[]): string {
|
||||||
return errors.map((err) => `- ${err}`).join("\n")
|
return errors.map((err) => `- ${err}`).join("\n")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,17 @@
|
|||||||
export class GithubError {
|
export class GithubError {
|
||||||
error: any;
|
private error: any;
|
||||||
|
|
||||||
constructor(error: any) {
|
constructor(error: any) {
|
||||||
this.error = error
|
this.error = error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get code(): string {
|
||||||
|
return this.error.code
|
||||||
|
}
|
||||||
|
|
||||||
toString(): string {
|
toString(): string {
|
||||||
const code = this.error.code
|
const code = this.error.code
|
||||||
switch(code) {
|
switch (code) {
|
||||||
case 'missing':
|
case 'missing':
|
||||||
return this.missingResourceMessage()
|
return this.missingResourceMessage()
|
||||||
case 'missing_field':
|
case 'missing_field':
|
||||||
@@ -26,7 +30,7 @@ export class GithubError {
|
|||||||
const documentation = this.error.documentation_url
|
const documentation = this.error.documentation_url
|
||||||
|
|
||||||
let documentationMessage: string
|
let documentationMessage: string
|
||||||
if(documentation) {
|
if (documentation) {
|
||||||
documentationMessage = `\nPlease see ${documentation}.`
|
documentationMessage = `\nPlease see ${documentation}.`
|
||||||
} else {
|
} else {
|
||||||
documentationMessage = ""
|
documentationMessage = ""
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { ArtifactGlobber } from './ArtifactGlobber';
|
|||||||
import { Artifact } from './Artifact';
|
import { Artifact } from './Artifact';
|
||||||
|
|
||||||
export interface Inputs {
|
export interface Inputs {
|
||||||
|
readonly allowUpdates: boolean
|
||||||
readonly artifacts: Artifact[]
|
readonly artifacts: Artifact[]
|
||||||
readonly body: string
|
readonly body: string
|
||||||
readonly commit: string
|
readonly commit: string
|
||||||
@@ -23,6 +24,11 @@ export class CoreInputs implements Inputs {
|
|||||||
this.context = context
|
this.context = context
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get allowUpdates(): boolean {
|
||||||
|
const allow = core.getInput('allowUpdates')
|
||||||
|
return allow == 'true'
|
||||||
|
}
|
||||||
|
|
||||||
get artifacts(): Artifact[] {
|
get artifacts(): Artifact[] {
|
||||||
let artifacts = core.getInput('artifacts')
|
let artifacts = core.getInput('artifacts')
|
||||||
if (!artifacts) {
|
if (!artifacts) {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Context } from "@actions/github/lib/context";
|
import { Context } from "@actions/github/lib/context";
|
||||||
import { GitHub } from "@actions/github";
|
import { GitHub } from "@actions/github";
|
||||||
import { AnyResponse, Response, ReposCreateReleaseResponse } from "@octokit/rest";
|
import { AnyResponse, Response, ReposCreateReleaseResponse, ReposGetReleaseByTagResponse } from "@octokit/rest";
|
||||||
|
|
||||||
export interface Releases {
|
export interface Releases {
|
||||||
create(
|
create(
|
||||||
@@ -11,6 +11,17 @@ export interface Releases {
|
|||||||
name?: string
|
name?: string
|
||||||
): Promise<Response<ReposCreateReleaseResponse>>
|
): Promise<Response<ReposCreateReleaseResponse>>
|
||||||
|
|
||||||
|
getByTag(tag: string): Promise<Response<ReposGetReleaseByTagResponse>>
|
||||||
|
|
||||||
|
update(
|
||||||
|
id: number,
|
||||||
|
tag: string,
|
||||||
|
body?: string,
|
||||||
|
commitHash?: string,
|
||||||
|
draft?: boolean,
|
||||||
|
name?: string
|
||||||
|
): Promise<Response<ReposCreateReleaseResponse>>
|
||||||
|
|
||||||
uploadArtifact(
|
uploadArtifact(
|
||||||
assetUrl: string,
|
assetUrl: string,
|
||||||
contentLength: number,
|
contentLength: number,
|
||||||
@@ -20,7 +31,7 @@ export interface Releases {
|
|||||||
): Promise<Response<AnyResponse>>
|
): Promise<Response<AnyResponse>>
|
||||||
}
|
}
|
||||||
|
|
||||||
export class GithubReleases implements Releases{
|
export class GithubReleases implements Releases {
|
||||||
context: Context
|
context: Context
|
||||||
git: GitHub
|
git: GitHub
|
||||||
|
|
||||||
@@ -47,6 +58,34 @@ export class GithubReleases implements Releases{
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getByTag(tag: string): Promise<Response<ReposGetReleaseByTagResponse>> {
|
||||||
|
return this.git.repos.getReleaseByTag({
|
||||||
|
owner: this.context.repo.owner,
|
||||||
|
repo: this.context.repo.repo,
|
||||||
|
tag: tag
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async update(
|
||||||
|
id: number,
|
||||||
|
tag: string,
|
||||||
|
body?: string,
|
||||||
|
commitHash?: string,
|
||||||
|
draft?: boolean,
|
||||||
|
name?: string
|
||||||
|
): Promise<Response<ReposCreateReleaseResponse>> {
|
||||||
|
return this.git.repos.updateRelease({
|
||||||
|
release_id: id,
|
||||||
|
body: body,
|
||||||
|
name: name,
|
||||||
|
draft: draft,
|
||||||
|
owner: this.context.repo.owner,
|
||||||
|
repo: this.context.repo.repo,
|
||||||
|
target_commitish: commitHash,
|
||||||
|
tag_name: tag
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
async uploadArtifact(
|
async uploadArtifact(
|
||||||
assetUrl: string,
|
assetUrl: string,
|
||||||
contentLength: number,
|
contentLength: number,
|
||||||
|
|||||||
Reference in New Issue
Block a user