Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7c50463644 | ||
|
|
ec90733eaa | ||
|
|
839c2ee3df | ||
|
|
a43fb1aa82 | ||
|
|
8f0b206fd3 | ||
|
|
9b14e2e2d3 | ||
|
|
af980963d6 |
28
.github/workflows/build.yml
vendored
Normal file
28
.github/workflows/build.yml
vendored
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
name: "PR Checks"
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check_pr:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
|
||||||
|
- name: "yarn install"
|
||||||
|
run: yarn install
|
||||||
|
|
||||||
|
- name: "yarn build"
|
||||||
|
run: yarn build
|
||||||
|
|
||||||
|
- name: "check for uncommitted changes"
|
||||||
|
# Ensure no changes, but ignore node_modules dir since dev/fresh ci deps installed.
|
||||||
|
run: |
|
||||||
|
git diff --exit-code --stat -- . ':!node_modules' \
|
||||||
|
|| (echo "##[error] found changed files after build. please 'yarn build && npm run format'" \
|
||||||
|
"and check in all changes" \
|
||||||
|
&& exit 1)
|
||||||
25
.github/workflows/checkin.yml
vendored
25
.github/workflows/checkin.yml
vendored
@@ -1,25 +0,0 @@
|
|||||||
name: "PR Checks"
|
|
||||||
on: [pull_request, push]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
check_pr:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v1
|
|
||||||
|
|
||||||
- name: "yarn install"
|
|
||||||
run: yarn install
|
|
||||||
|
|
||||||
- name: "yarn build"
|
|
||||||
run: yarn build
|
|
||||||
|
|
||||||
- name: "yarn test"
|
|
||||||
run: yarn test
|
|
||||||
|
|
||||||
- name: "check for uncommitted changes"
|
|
||||||
# Ensure no changes, but ignore node_modules dir since dev/fresh ci deps installed.
|
|
||||||
run: |
|
|
||||||
git diff --exit-code --stat -- . ':!node_modules' \
|
|
||||||
|| (echo "##[error] found changed files after build. please 'yarn build && npm run format'" \
|
|
||||||
"and check in all changes" \
|
|
||||||
&& exit 1)
|
|
||||||
14
.github/workflows/test.yml
vendored
Normal file
14
.github/workflows/test.yml
vendored
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
name: "Test"
|
||||||
|
on: [push, pull_request]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
check_pr:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
|
||||||
|
- name: "yarn install"
|
||||||
|
run: yarn install
|
||||||
|
|
||||||
|
- name: "yarn test"
|
||||||
|
run: yarn test
|
||||||
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,4 +1,4 @@
|
|||||||
#node_modules/
|
# node_modules/
|
||||||
__tests__/runner/*
|
__tests__/runner/*
|
||||||
|
|
||||||
# Created by https://www.gitignore.io/api/webstorm
|
# Created by https://www.gitignore.io/api/webstorm
|
||||||
|
|||||||
@@ -4,12 +4,14 @@ 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.
|
- **allowUpdates**: An optional flag which indicates if we should update a release if it already exists. Defaults to false.
|
||||||
|
- **artifactErrorsFailBuild**: An optional flag which indicates if artifact read or upload errors should fail the build.
|
||||||
- **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.
|
||||||
- **body**: An optional body for the release.
|
- **body**: An optional body for the release.
|
||||||
- **bodyFile**: An optional body file for the release. This should be the path to the file.
|
- **bodyFile**: An optional body file for the release. This should be the path to the file.
|
||||||
- **commit**: An optional commit reference. This will be used to create the tag if it does not exist.
|
- **commit**: An optional commit reference. This will be used to create the tag if it does not exist.
|
||||||
|
- **discussionCategory**: When provided this will generate a discussion of the specified category. The category must exist otherwise this will cause the action to fail. This isn't used with draft releases.
|
||||||
- **draft**: Optionally marks this release as a draft release. Set to `true` to enable.
|
- **draft**: Optionally marks this release as a draft release. Set to `true` to enable.
|
||||||
- **name**: An optional name for the release. If this is omitted the tag will be used.
|
- **name**: An optional name for the release. If this is omitted the tag will be used.
|
||||||
- **omitBody**: Indicates if the release body should be omitted.
|
- **omitBody**: Indicates if the release body should be omitted.
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const artifacts = [
|
|||||||
const createBody = 'createBody'
|
const createBody = 'createBody'
|
||||||
const createName = 'createName'
|
const createName = 'createName'
|
||||||
const commit = 'commit'
|
const commit = 'commit'
|
||||||
|
const discussionCategory = 'discussionCategory'
|
||||||
const draft = true
|
const draft = true
|
||||||
const id = 100
|
const id = 100
|
||||||
const prerelease = true
|
const prerelease = true
|
||||||
@@ -45,7 +46,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, createBody, commit, draft, createName, prerelease)
|
expect(createMock).toBeCalledWith(tag, createBody, commit, discussionCategory, draft, createName, prerelease)
|
||||||
expect(uploadMock).not.toBeCalled()
|
expect(uploadMock).not.toBeCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -56,7 +57,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, createBody, commit, draft, createName, prerelease)
|
expect(createMock).toBeCalledWith(tag, createBody, commit, discussionCategory, draft, createName, prerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -72,7 +73,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, createBody, commit, draft, createName, prerelease)
|
expect(createMock).toBeCalledWith(tag, createBody, commit, discussionCategory, draft, createName, prerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -82,7 +83,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, createBody, commit, draft, createName, prerelease)
|
expect(createMock).toBeCalledWith(tag, createBody, commit, discussionCategory, draft, createName, prerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -97,7 +98,7 @@ describe("Action", () => {
|
|||||||
expect(error).toEqual("error")
|
expect(error).toEqual("error")
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, createBody, commit, draft, createName, prerelease)
|
expect(createMock).toBeCalledWith(tag, createBody, commit, discussionCategory, draft, createName, prerelease)
|
||||||
expect(uploadMock).not.toBeCalled()
|
expect(uploadMock).not.toBeCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -138,22 +139,32 @@ describe("Action", () => {
|
|||||||
expect(error).toEqual("error")
|
expect(error).toEqual("error")
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(updateMock).toBeCalledWith(id, tag, updateBody, commit, draft, updateName, prerelease)
|
expect(updateMock).toBeCalledWith(
|
||||||
|
id,
|
||||||
|
tag,
|
||||||
|
updateBody,
|
||||||
|
commit,
|
||||||
|
discussionCategory,
|
||||||
|
draft,
|
||||||
|
updateName,
|
||||||
|
prerelease
|
||||||
|
)
|
||||||
expect(uploadMock).not.toBeCalled()
|
expect(uploadMock).not.toBeCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('throws error when upload fails', async () => {
|
it('throws error when upload fails', async () => {
|
||||||
const action = createAction(false, true)
|
const action = createAction(false, true)
|
||||||
uploadMock.mockRejectedValue("error")
|
const expectedError = {status: 404}
|
||||||
|
uploadMock.mockRejectedValue(expectedError)
|
||||||
|
|
||||||
expect.hasAssertions()
|
expect.hasAssertions()
|
||||||
try {
|
try {
|
||||||
await action.perform()
|
await action.perform()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect(error).toEqual("error")
|
expect(error).toEqual(expectedError)
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, createBody, commit, draft, createName, prerelease)
|
expect(createMock).toBeCalledWith(tag, createBody, commit, discussionCategory, draft, createName, prerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -170,7 +181,16 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(updateMock).toBeCalledWith(id, tag, updateBody, commit, draft, updateName, prerelease)
|
expect(updateMock).toBeCalledWith(
|
||||||
|
id,
|
||||||
|
tag,
|
||||||
|
updateBody,
|
||||||
|
commit,
|
||||||
|
discussionCategory,
|
||||||
|
draft,
|
||||||
|
updateName,
|
||||||
|
prerelease
|
||||||
|
)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -180,7 +200,16 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(updateMock).toBeCalledWith(id, tag, updateBody, commit, draft, updateName, prerelease)
|
expect(updateMock).toBeCalledWith(
|
||||||
|
id,
|
||||||
|
tag,
|
||||||
|
updateBody,
|
||||||
|
commit,
|
||||||
|
discussionCategory,
|
||||||
|
draft,
|
||||||
|
updateName,
|
||||||
|
prerelease
|
||||||
|
)
|
||||||
expect(uploadMock).not.toBeCalled()
|
expect(uploadMock).not.toBeCalled()
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -190,7 +219,16 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(updateMock).toBeCalledWith(id, tag, updateBody, commit, draft, updateName, prerelease)
|
expect(updateMock).toBeCalledWith(
|
||||||
|
id,
|
||||||
|
tag,
|
||||||
|
updateBody,
|
||||||
|
commit,
|
||||||
|
discussionCategory,
|
||||||
|
draft,
|
||||||
|
updateName,
|
||||||
|
prerelease
|
||||||
|
)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -239,10 +277,12 @@ describe("Action", () => {
|
|||||||
const MockInputs = jest.fn<Inputs, any>(() => {
|
const MockInputs = jest.fn<Inputs, any>(() => {
|
||||||
return {
|
return {
|
||||||
allowUpdates: allowUpdates,
|
allowUpdates: allowUpdates,
|
||||||
|
artifactErrorsFailBuild: true,
|
||||||
artifacts: inputArtifact,
|
artifacts: inputArtifact,
|
||||||
createdReleaseBody: createBody,
|
createdReleaseBody: createBody,
|
||||||
createdReleaseName: createName,
|
createdReleaseName: createName,
|
||||||
commit: commit,
|
commit: commit,
|
||||||
|
discussionCategory: discussionCategory,
|
||||||
draft: draft,
|
draft: draft,
|
||||||
owner: "owner",
|
owner: "owner",
|
||||||
prerelease: prerelease,
|
prerelease: prerelease,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
const warnMock = jest.fn()
|
const warnMock = jest.fn()
|
||||||
|
|
||||||
import { FileArtifactGlobber } from "../src/ArtifactGlobber"
|
import {FileArtifactGlobber} from "../src/ArtifactGlobber"
|
||||||
import { Globber } from "../src/Globber";
|
import {Globber} from "../src/Globber";
|
||||||
import { Artifact } from "../src/Artifact";
|
import {Artifact} from "../src/Artifact";
|
||||||
import untildify = require("untildify");
|
import untildify = require("untildify");
|
||||||
|
|
||||||
const contentType = "raw"
|
const contentType = "raw"
|
||||||
@@ -24,19 +24,19 @@ describe("ArtifactGlobber", () => {
|
|||||||
const expectedArtifacts =
|
const expectedArtifacts =
|
||||||
globResults.map((path) => new Artifact(path, contentType))
|
globResults.map((path) => new Artifact(path, contentType))
|
||||||
|
|
||||||
expect(globber.globArtifactString('~/path', 'raw'))
|
expect(globber.globArtifactString('~/path', 'raw', false))
|
||||||
.toEqual(expectedArtifacts)
|
.toEqual(expectedArtifacts)
|
||||||
expect(globMock).toBeCalledWith(untildify('~/path'))
|
expect(globMock).toBeCalledWith(untildify('~/path'))
|
||||||
expect(warnMock).not.toBeCalled()
|
expect(warnMock).not.toBeCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("globs simple path", () => {
|
it("globs simple path", () => {
|
||||||
const globber = createArtifactGlobber()
|
const globber = createArtifactGlobber()
|
||||||
|
|
||||||
const expectedArtifacts =
|
const expectedArtifacts =
|
||||||
globResults.map((path) => new Artifact(path, contentType))
|
globResults.map((path) => new Artifact(path, contentType))
|
||||||
|
|
||||||
expect(globber.globArtifactString('path', 'raw'))
|
expect(globber.globArtifactString('path', 'raw', false))
|
||||||
.toEqual(expectedArtifacts)
|
.toEqual(expectedArtifacts)
|
||||||
expect(globMock).toBeCalledWith('path')
|
expect(globMock).toBeCalledWith('path')
|
||||||
expect(warnMock).not.toBeCalled()
|
expect(warnMock).not.toBeCalled()
|
||||||
@@ -50,24 +50,28 @@ describe("ArtifactGlobber", () => {
|
|||||||
.concat(globResults)
|
.concat(globResults)
|
||||||
.map((path) => new Artifact(path, contentType))
|
.map((path) => new Artifact(path, contentType))
|
||||||
|
|
||||||
expect(globber.globArtifactString('path1,path2', 'raw'))
|
expect(globber.globArtifactString('path1,path2', 'raw', false))
|
||||||
.toEqual(expectedArtifacts)
|
.toEqual(expectedArtifacts)
|
||||||
expect(globMock).toBeCalledWith('path1')
|
expect(globMock).toBeCalledWith('path1')
|
||||||
expect(globMock).toBeCalledWith('path2')
|
expect(globMock).toBeCalledWith('path2')
|
||||||
expect(warnMock).not.toBeCalled()
|
expect(warnMock).not.toBeCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
it("warns when no glob results are produced", () => {
|
it("warns when no glob results are produced and empty results shouldn't throw", () => {
|
||||||
const globber = createArtifactGlobber([])
|
const globber = createArtifactGlobber([])
|
||||||
|
|
||||||
const expectedArtifacts =
|
expect(globber.globArtifactString('path', 'raw', false))
|
||||||
globResults.map((path) => new Artifact(path, contentType))
|
|
||||||
|
|
||||||
expect(globber.globArtifactString('path', 'raw'))
|
|
||||||
.toEqual([])
|
.toEqual([])
|
||||||
expect(warnMock).toBeCalled()
|
expect(warnMock).toBeCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it("throws when no glob results are produced and empty results shouild throw", () => {
|
||||||
|
const globber = createArtifactGlobber([])
|
||||||
|
expect(() => {
|
||||||
|
globber.globArtifactString('path', 'raw', true)
|
||||||
|
}).toThrow()
|
||||||
|
})
|
||||||
|
|
||||||
function createArtifactGlobber(results: string[] = globResults): FileArtifactGlobber {
|
function createArtifactGlobber(results: string[] = globResults): FileArtifactGlobber {
|
||||||
const MockGlobber = jest.fn<Globber, any>(() => {
|
const MockGlobber = jest.fn<Globber, any>(() => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { Artifact } from "../src/Artifact"
|
import {Artifact} from "../src/Artifact"
|
||||||
import { GithubArtifactUploader } from "../src/ArtifactUploader"
|
import {GithubArtifactUploader} from "../src/ArtifactUploader"
|
||||||
import { Releases } from "../src/Releases";
|
import {Releases} from "../src/Releases";
|
||||||
import { RequestError } from '@octokit/request-error'
|
import {RequestError} from '@octokit/request-error'
|
||||||
|
|
||||||
const artifacts = [
|
const artifacts = [
|
||||||
new Artifact('a/art1'),
|
new Artifact('a/art1'),
|
||||||
@@ -19,7 +19,9 @@ const uploadMock = jest.fn()
|
|||||||
jest.mock('fs', () => {
|
jest.mock('fs', () => {
|
||||||
return {
|
return {
|
||||||
readFileSync: () => fileContents,
|
readFileSync: () => fileContents,
|
||||||
statSync: () => { return { size: contentLength } }
|
statSync: () => {
|
||||||
|
return {size: contentLength}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -124,6 +126,19 @@ describe('ArtifactUploader', () => {
|
|||||||
expect(deleteMock).toBeCalledTimes(0)
|
expect(deleteMock).toBeCalledTimes(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('throws upload error when replacesExistingArtifacts is true', async () => {
|
||||||
|
mockListWithoutAssets()
|
||||||
|
mockUploadError()
|
||||||
|
const uploader = createUploader(true, true)
|
||||||
|
|
||||||
|
expect.hasAssertions()
|
||||||
|
try {
|
||||||
|
await uploader.uploadArtifacts(artifacts, releaseId, url)
|
||||||
|
} catch (error) {
|
||||||
|
expect(error).toEqual(Error("Failed to upload artifact art1. error."))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
it('throws error from replace', async () => {
|
it('throws error from replace', async () => {
|
||||||
mockDeleteError()
|
mockDeleteError()
|
||||||
mockListWithAssets()
|
mockListWithAssets()
|
||||||
@@ -155,7 +170,7 @@ describe('ArtifactUploader', () => {
|
|||||||
expect(deleteMock).toBeCalledTimes(0)
|
expect(deleteMock).toBeCalledTimes(0)
|
||||||
})
|
})
|
||||||
|
|
||||||
function createUploader(replaces: boolean): GithubArtifactUploader {
|
function createUploader(replaces: boolean, throws: boolean = false): GithubArtifactUploader {
|
||||||
const MockReleases = jest.fn<Releases, any>(() => {
|
const MockReleases = jest.fn<Releases, any>(() => {
|
||||||
return {
|
return {
|
||||||
create: jest.fn(),
|
create: jest.fn(),
|
||||||
@@ -167,7 +182,7 @@ describe('ArtifactUploader', () => {
|
|||||||
uploadArtifact: uploadMock
|
uploadArtifact: uploadMock
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return new GithubArtifactUploader(new MockReleases(), replaces)
|
return new GithubArtifactUploader(new MockReleases(), replaces, throws)
|
||||||
}
|
}
|
||||||
|
|
||||||
function mockDeleteError(): any {
|
function mockDeleteError(): any {
|
||||||
@@ -179,29 +194,37 @@ describe('ArtifactUploader', () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function mockListWithAssets() {
|
function mockListWithAssets() {
|
||||||
listArtifactsMock.mockResolvedValue({
|
listArtifactsMock.mockResolvedValue([
|
||||||
data: [
|
{
|
||||||
{
|
name: "art1",
|
||||||
name: "art1",
|
id: 1
|
||||||
id: 1
|
},
|
||||||
},
|
{
|
||||||
{
|
name: "art2",
|
||||||
name: "art2",
|
id: 2
|
||||||
id: 2
|
}
|
||||||
}
|
])
|
||||||
]
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function mockListWithoutAssets() {
|
function mockListWithoutAssets() {
|
||||||
listArtifactsMock.mockResolvedValue({ data: [] })
|
listArtifactsMock.mockResolvedValue([])
|
||||||
}
|
}
|
||||||
|
|
||||||
function mockUploadArtifact(status: number = 200, failures: number = 0) {
|
function mockUploadArtifact(status: number = 200, failures: number = 0) {
|
||||||
const error = new RequestError(`HTTP ${status}`, status, { headers: {}, request: { method: 'GET', url: '', headers: {} } })
|
const error = new RequestError(`HTTP ${status}`, status, {
|
||||||
|
headers: {},
|
||||||
|
request: {method: 'GET', url: '', headers: {}}
|
||||||
|
})
|
||||||
for (let index = 0; index < failures; index++) {
|
for (let index = 0; index < failures; index++) {
|
||||||
uploadMock.mockRejectedValueOnce(error)
|
uploadMock.mockRejectedValueOnce(error)
|
||||||
}
|
}
|
||||||
uploadMock.mockResolvedValue({})
|
uploadMock.mockResolvedValue({})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function mockUploadError() {
|
||||||
|
uploadMock.mockRejectedValue({
|
||||||
|
message: "error",
|
||||||
|
status: 502
|
||||||
|
})
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,70 +0,0 @@
|
|||||||
import { ErrorMessage } from "../src/ErrorMessage"
|
|
||||||
|
|
||||||
describe('ErrorMessage', () => {
|
|
||||||
|
|
||||||
describe('has error with code', () => {
|
|
||||||
const error = {
|
|
||||||
message: 'something bad happened',
|
|
||||||
errors: [
|
|
||||||
{
|
|
||||||
code: 'missing',
|
|
||||||
resource: 'release'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
code: 'already_exists',
|
|
||||||
resource: 'release'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
status: 422
|
|
||||||
}
|
|
||||||
|
|
||||||
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', () => {
|
|
||||||
const error = {
|
|
||||||
message: 'something bad happened',
|
|
||||||
errors: [
|
|
||||||
{
|
|
||||||
code: 'missing',
|
|
||||||
resource: 'release'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
code: 'already_exists',
|
|
||||||
resource: 'release'
|
|
||||||
}
|
|
||||||
],
|
|
||||||
status: 422
|
|
||||||
}
|
|
||||||
|
|
||||||
const errorMessage = new ErrorMessage(error)
|
|
||||||
|
|
||||||
const expectedString = "Error 422: something bad happened\nErrors:\n- release does not exist.\n- release already exists."
|
|
||||||
expect(errorMessage.toString()).toBe(expectedString)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('generates message without errors', () => {
|
|
||||||
const error = {
|
|
||||||
message: 'something bad happened',
|
|
||||||
status: 422
|
|
||||||
}
|
|
||||||
|
|
||||||
const errorMessage = new ErrorMessage(error)
|
|
||||||
|
|
||||||
expect(errorMessage.toString()).toBe('Error 422: something bad happened')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('provides error status', () => {
|
|
||||||
const error = { status: 404 }
|
|
||||||
const errorMessage = new ErrorMessage(error)
|
|
||||||
expect(errorMessage.status).toBe(404)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
@@ -1,99 +1,70 @@
|
|||||||
import { GithubError } from "../src/GithubError"
|
import { GithubError } from "../src/GithubError"
|
||||||
|
|
||||||
describe('GithubError', () => {
|
describe('ErrorMessage', () => {
|
||||||
|
|
||||||
it('provides error code', () => {
|
describe('has error with code', () => {
|
||||||
const error = {
|
const error = {
|
||||||
code: "missing"
|
message: 'something bad happened',
|
||||||
|
errors: [
|
||||||
|
{
|
||||||
|
code: 'missing',
|
||||||
|
resource: 'release'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'already_exists',
|
||||||
|
resource: 'release'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
status: 422
|
||||||
}
|
}
|
||||||
|
|
||||||
const githubError = new GithubError(error)
|
it('does not have error', () => {
|
||||||
|
|
||||||
expect(githubError.code).toBe('missing')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('generates missing resource error message', () => {
|
|
||||||
const resource = "release"
|
|
||||||
const error = {
|
|
||||||
code: "missing",
|
|
||||||
resource: resource
|
|
||||||
}
|
|
||||||
|
|
||||||
const githubError = new GithubError(error)
|
|
||||||
const message = githubError.toString()
|
|
||||||
|
|
||||||
expect(message).toBe(`${resource} does not exist.`)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('generates missing field error message', () => {
|
|
||||||
const resource = "release"
|
|
||||||
const field = "body"
|
|
||||||
const error = {
|
|
||||||
code: "missing_field",
|
|
||||||
field: field,
|
|
||||||
resource: resource
|
|
||||||
}
|
|
||||||
|
|
||||||
const githubError = new GithubError(error)
|
|
||||||
const message = githubError.toString()
|
|
||||||
|
|
||||||
expect(message).toBe(`The ${field} field on ${resource} is missing.`)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('generates invalid field error message', () => {
|
|
||||||
const resource = "release"
|
|
||||||
const field = "body"
|
|
||||||
const error = {
|
|
||||||
code: "invalid",
|
|
||||||
field: field,
|
|
||||||
resource: resource
|
|
||||||
}
|
|
||||||
|
|
||||||
const githubError = new GithubError(error)
|
|
||||||
const message = githubError.toString()
|
|
||||||
|
|
||||||
expect(message).toBe(`The ${field} field on ${resource} is an invalid format.`)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('generates resource already exists error message', () => {
|
|
||||||
const resource = "release"
|
|
||||||
const field = "body"
|
|
||||||
const error = {
|
|
||||||
code: "already_exists",
|
|
||||||
resource: resource
|
|
||||||
}
|
|
||||||
|
|
||||||
const githubError = new GithubError(error)
|
|
||||||
const message = githubError.toString()
|
|
||||||
|
|
||||||
expect(message).toBe(`${resource} already exists.`)
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('generates custom error message', () => {
|
|
||||||
it('with documentation url', () => {
|
|
||||||
const url = "https://api.example.com"
|
|
||||||
const error = {
|
|
||||||
code: "custom",
|
|
||||||
message: "foo",
|
|
||||||
documentation_url: url
|
|
||||||
}
|
|
||||||
|
|
||||||
const githubError = new GithubError(error)
|
const githubError = new GithubError(error)
|
||||||
const message = githubError.toString()
|
expect(githubError.hasErrorWithCode('missing_field')).toBeFalsy()
|
||||||
|
|
||||||
expect(message).toBe(`foo\nPlease see ${url}.`)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('without documentation url', () => {
|
it('has error', () => {
|
||||||
const error = {
|
|
||||||
code: "custom",
|
|
||||||
message: "foo"
|
|
||||||
}
|
|
||||||
|
|
||||||
const githubError = new GithubError(error)
|
const githubError = new GithubError(error)
|
||||||
const message = githubError.toString()
|
expect(githubError.hasErrorWithCode('missing')).toBeTruthy()
|
||||||
|
|
||||||
expect(message).toBe('foo')
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
it('generates message with errors', () => {
|
||||||
|
const error = {
|
||||||
|
message: 'something bad happened',
|
||||||
|
errors: [
|
||||||
|
{
|
||||||
|
code: 'missing',
|
||||||
|
resource: 'release'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
code: 'already_exists',
|
||||||
|
resource: 'release'
|
||||||
|
}
|
||||||
|
],
|
||||||
|
status: 422
|
||||||
|
}
|
||||||
|
|
||||||
|
const githubError = new GithubError(error)
|
||||||
|
|
||||||
|
const expectedString = "Error 422: something bad happened\nErrors:\n- release does not exist.\n- release already exists."
|
||||||
|
expect(githubError.toString()).toBe(expectedString)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('generates message without errors', () => {
|
||||||
|
const error = {
|
||||||
|
message: 'something bad happened',
|
||||||
|
status: 422
|
||||||
|
}
|
||||||
|
|
||||||
|
const githubError = new GithubError(error)
|
||||||
|
|
||||||
|
expect(githubError.toString()).toBe('Error 422: something bad happened')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('provides error status', () => {
|
||||||
|
const error = { status: 404 }
|
||||||
|
const githubError = new GithubError(error)
|
||||||
|
expect(githubError.status).toBe(404)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|||||||
98
__tests__/GithubErrorDetail.test.ts
Normal file
98
__tests__/GithubErrorDetail.test.ts
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
import { GithubErrorDetail } from "../src/GithubErrorDetail"
|
||||||
|
|
||||||
|
describe('GithubErrorDetail', () => {
|
||||||
|
|
||||||
|
it('provides error code', () => {
|
||||||
|
const error = {
|
||||||
|
code: "missing"
|
||||||
|
}
|
||||||
|
|
||||||
|
const detail = new GithubErrorDetail(error)
|
||||||
|
|
||||||
|
expect(detail.code).toBe('missing')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('generates missing resource error message', () => {
|
||||||
|
const resource = "release"
|
||||||
|
const error = {
|
||||||
|
code: "missing",
|
||||||
|
resource: resource
|
||||||
|
}
|
||||||
|
|
||||||
|
const detail = new GithubErrorDetail(error)
|
||||||
|
const message = detail.toString()
|
||||||
|
|
||||||
|
expect(message).toBe(`${resource} does not exist.`)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('generates missing field error message', () => {
|
||||||
|
const resource = "release"
|
||||||
|
const field = "body"
|
||||||
|
const error = {
|
||||||
|
code: "missing_field",
|
||||||
|
field: field,
|
||||||
|
resource: resource
|
||||||
|
}
|
||||||
|
|
||||||
|
const detail = new GithubErrorDetail(error)
|
||||||
|
const message = detail.toString()
|
||||||
|
|
||||||
|
expect(message).toBe(`The ${field} field on ${resource} is missing.`)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('generates invalid field error message', () => {
|
||||||
|
const resource = "release"
|
||||||
|
const field = "body"
|
||||||
|
const error = {
|
||||||
|
code: "invalid",
|
||||||
|
field: field,
|
||||||
|
resource: resource
|
||||||
|
}
|
||||||
|
|
||||||
|
const detail = new GithubErrorDetail(error)
|
||||||
|
const message = detail.toString()
|
||||||
|
|
||||||
|
expect(message).toBe(`The ${field} field on ${resource} is an invalid format.`)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('generates resource already exists error message', () => {
|
||||||
|
const resource = "release"
|
||||||
|
const error = {
|
||||||
|
code: "already_exists",
|
||||||
|
resource: resource
|
||||||
|
}
|
||||||
|
|
||||||
|
const detail = new GithubErrorDetail(error)
|
||||||
|
const message = detail.toString()
|
||||||
|
|
||||||
|
expect(message).toBe(`${resource} already exists.`)
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('generates custom error message', () => {
|
||||||
|
it('with documentation url', () => {
|
||||||
|
const url = "https://api.example.com"
|
||||||
|
const error = {
|
||||||
|
code: "custom",
|
||||||
|
message: "foo",
|
||||||
|
documentation_url: url
|
||||||
|
}
|
||||||
|
|
||||||
|
const detail = new GithubErrorDetail(error)
|
||||||
|
const message = detail.toString()
|
||||||
|
|
||||||
|
expect(message).toBe(`foo\nPlease see ${url}.`)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('without documentation url', () => {
|
||||||
|
const error = {
|
||||||
|
code: "custom",
|
||||||
|
message: "foo"
|
||||||
|
}
|
||||||
|
|
||||||
|
const detail = new GithubErrorDetail(error)
|
||||||
|
const message = detail.toString()
|
||||||
|
|
||||||
|
expect(message).toBe('foo')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -59,7 +59,28 @@ describe('Inputs', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('artifactErrorsFailBuild', () => {
|
||||||
|
it('returns false', () => {
|
||||||
|
expect(inputs.artifactErrorsFailBuild).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('returns true', () => {
|
||||||
|
mockGetInput.mockReturnValue('true')
|
||||||
|
expect(inputs.artifactErrorsFailBuild).toBe(true)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('artifacts', () => {
|
describe('artifacts', () => {
|
||||||
|
it('globber told to throw errors', () => {
|
||||||
|
mockGetInput.mockReturnValueOnce('art1')
|
||||||
|
.mockReturnValueOnce('contentType')
|
||||||
|
.mockReturnValueOnce('true')
|
||||||
|
|
||||||
|
expect(inputs.artifacts).toEqual(artifacts)
|
||||||
|
expect(mockGlob).toBeCalledTimes(1)
|
||||||
|
expect(mockGlob).toBeCalledWith('art1', 'contentType', true)
|
||||||
|
})
|
||||||
|
|
||||||
it('returns empty artifacts', () => {
|
it('returns empty artifacts', () => {
|
||||||
mockGetInput.mockReturnValueOnce('')
|
mockGetInput.mockReturnValueOnce('')
|
||||||
.mockReturnValueOnce('')
|
.mockReturnValueOnce('')
|
||||||
@@ -71,28 +92,32 @@ describe('Inputs', () => {
|
|||||||
it('returns input.artifacts', () => {
|
it('returns input.artifacts', () => {
|
||||||
mockGetInput.mockReturnValueOnce('art1')
|
mockGetInput.mockReturnValueOnce('art1')
|
||||||
.mockReturnValueOnce('contentType')
|
.mockReturnValueOnce('contentType')
|
||||||
|
.mockReturnValueOnce('false')
|
||||||
|
|
||||||
expect(inputs.artifacts).toEqual(artifacts)
|
expect(inputs.artifacts).toEqual(artifacts)
|
||||||
expect(mockGlob).toBeCalledTimes(1)
|
expect(mockGlob).toBeCalledTimes(1)
|
||||||
expect(mockGlob).toBeCalledWith('art1', 'contentType')
|
expect(mockGlob).toBeCalledWith('art1', 'contentType', false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns input.artifacts with default contentType', () => {
|
it('returns input.artifacts with default contentType', () => {
|
||||||
mockGetInput.mockReturnValueOnce('art1')
|
mockGetInput.mockReturnValueOnce('art1')
|
||||||
|
.mockReturnValueOnce('raw')
|
||||||
|
.mockReturnValueOnce('false')
|
||||||
|
|
||||||
expect(inputs.artifacts).toEqual(artifacts)
|
expect(inputs.artifacts).toEqual(artifacts)
|
||||||
expect(mockGlob).toBeCalledTimes(1)
|
expect(mockGlob).toBeCalledTimes(1)
|
||||||
expect(mockGlob).toBeCalledWith('art1', 'raw')
|
expect(mockGlob).toBeCalledWith('art1', 'raw', false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns input.artifact', () => {
|
it('returns input.artifact', () => {
|
||||||
mockGetInput.mockReturnValueOnce('')
|
mockGetInput.mockReturnValueOnce('')
|
||||||
.mockReturnValueOnce('art2')
|
.mockReturnValueOnce('art2')
|
||||||
.mockReturnValueOnce('contentType')
|
.mockReturnValueOnce('contentType')
|
||||||
|
.mockReturnValueOnce('false')
|
||||||
|
|
||||||
expect(inputs.artifacts).toEqual(artifacts)
|
expect(inputs.artifacts).toEqual(artifacts)
|
||||||
expect(mockGlob).toBeCalledTimes(1)
|
expect(mockGlob).toBeCalledTimes(1)
|
||||||
expect(mockGlob).toBeCalledWith('art2', 'contentType')
|
expect(mockGlob).toBeCalledWith('art2', 'contentType', false)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -154,6 +179,18 @@ describe('Inputs', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('discussionCategory', () => {
|
||||||
|
it('returns category', () => {
|
||||||
|
mockGetInput.mockReturnValue('Release')
|
||||||
|
expect(inputs.discussionCategory).toBe('Release')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('returns undefined', () => {
|
||||||
|
mockGetInput.mockReturnValue('')
|
||||||
|
expect(inputs.discussionCategory).toBe(undefined)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('draft', () => {
|
describe('draft', () => {
|
||||||
it('returns false', () => {
|
it('returns false', () => {
|
||||||
expect(inputs.draft).toBe(false)
|
expect(inputs.draft).toBe(false)
|
||||||
@@ -164,7 +201,7 @@ describe('Inputs', () => {
|
|||||||
expect(inputs.draft).toBe(true)
|
expect(inputs.draft).toBe(true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('owner', () => {
|
describe('owner', () => {
|
||||||
it('returns owner from context', function () {
|
it('returns owner from context', function () {
|
||||||
process.env.GITHUB_REPOSITORY = "owner/repo"
|
process.env.GITHUB_REPOSITORY = "owner/repo"
|
||||||
@@ -175,7 +212,7 @@ describe('Inputs', () => {
|
|||||||
mockGetInput.mockReturnValue("owner")
|
mockGetInput.mockReturnValue("owner")
|
||||||
expect(inputs.owner).toBe("owner")
|
expect(inputs.owner).toBe("owner")
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('prerelase', () => {
|
describe('prerelase', () => {
|
||||||
it('returns false', () => {
|
it('returns false', () => {
|
||||||
|
|||||||
@@ -18,7 +18,11 @@ describe.skip('Integration Test', () => {
|
|||||||
|
|
||||||
const inputs = getInputs()
|
const inputs = getInputs()
|
||||||
const releases = new GithubReleases(inputs, git)
|
const releases = new GithubReleases(inputs, git)
|
||||||
const uploader = new GithubArtifactUploader(releases, inputs.replacesArtifacts)
|
const uploader = new GithubArtifactUploader(
|
||||||
|
releases,
|
||||||
|
inputs.replacesArtifacts,
|
||||||
|
inputs.artifactErrorsFailBuild,
|
||||||
|
)
|
||||||
action = new Action(inputs, releases, uploader)
|
action = new Action(inputs, releases, uploader)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -30,10 +34,12 @@ describe.skip('Integration Test', () => {
|
|||||||
const MockInputs = jest.fn<Inputs, any>(() => {
|
const MockInputs = jest.fn<Inputs, any>(() => {
|
||||||
return {
|
return {
|
||||||
allowUpdates: true,
|
allowUpdates: true,
|
||||||
|
artifactErrorsFailBuild: false,
|
||||||
artifacts: artifacts(),
|
artifacts: artifacts(),
|
||||||
createdReleaseBody: "This release was generated by release-action's integration test",
|
createdReleaseBody: "This release was generated by release-action's integration test",
|
||||||
createdReleaseName: "Releases Action Integration Test",
|
createdReleaseName: "Releases Action Integration Test 2",
|
||||||
commit: "",
|
commit: "",
|
||||||
|
discussionCategory: 'Release',
|
||||||
draft: false,
|
draft: false,
|
||||||
owner: "ncipollo",
|
owner: "ncipollo",
|
||||||
prerelease: false,
|
prerelease: false,
|
||||||
@@ -42,17 +48,17 @@ describe.skip('Integration Test', () => {
|
|||||||
tag: "release-action-test",
|
tag: "release-action-test",
|
||||||
token: getToken(),
|
token: getToken(),
|
||||||
updatedReleaseBody: "This release was generated by release-action's integration test",
|
updatedReleaseBody: "This release was generated by release-action's integration test",
|
||||||
updatedReleaseName: "Releases Action Integration Test"
|
updatedReleaseName: "Releases Action Integration Test 2"
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return new MockInputs();
|
return new MockInputs();
|
||||||
}
|
}
|
||||||
|
|
||||||
function artifacts() {
|
function artifacts() {
|
||||||
const globber = new FileArtifactGlobber()
|
const globber = new FileArtifactGlobber()
|
||||||
const artifactPath = path.join(__dirname, 'Integration.test.ts')
|
const artifactPath = path.join(__dirname, 'Integration.test.ts')
|
||||||
const artifactString = `~/Desktop/test.txt,blarg.tx, ${artifactPath}`
|
const artifactString = `~/Desktop/test.txt,blarg.tx, ${artifactPath}`
|
||||||
return globber.globArtifactString(artifactString, "raw")
|
return globber.globArtifactString(artifactString, "raw", false)
|
||||||
}
|
}
|
||||||
|
|
||||||
function getToken(): string {
|
function getToken(): string {
|
||||||
|
|||||||
@@ -6,6 +6,10 @@ inputs:
|
|||||||
description: 'An optional flag which indicates if we should update a release if it already exists. Defaults to false.'
|
description: 'An optional flag which indicates if we should update a release if it already exists. Defaults to false.'
|
||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
|
artifactErrorsFailBuild:
|
||||||
|
description: 'An optional flag which indicates if artifact read or upload errors should fail the build.'
|
||||||
|
required: false
|
||||||
|
default: ''
|
||||||
artifact:
|
artifact:
|
||||||
deprecationMessage: Use 'artifacts' instead.
|
deprecationMessage: Use 'artifacts' instead.
|
||||||
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)'
|
||||||
@@ -30,6 +34,10 @@ inputs:
|
|||||||
commit:
|
commit:
|
||||||
description: "An optional commit reference. This will be used to create the tag if it does not exist."
|
description: "An optional commit reference. This will be used to create the tag if it does not exist."
|
||||||
required: false
|
required: false
|
||||||
|
default: ''
|
||||||
|
discussionCategory:
|
||||||
|
description: "When provided this will generate a discussion of the specified category. The category must exist otherwise this will cause the action to fail. This isn't used with draft releases"
|
||||||
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
draft:
|
draft:
|
||||||
description: "Optionally marks this release as a draft release. Set to true to enable."
|
description: "Optionally marks this release as a draft release. Set to true to enable."
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|||||||
};
|
};
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.Action = void 0;
|
exports.Action = void 0;
|
||||||
const ErrorMessage_1 = require("./ErrorMessage");
|
const GithubError_1 = require("./GithubError");
|
||||||
class Action {
|
class Action {
|
||||||
constructor(inputs, releases, uploader) {
|
constructor(inputs, releases, uploader) {
|
||||||
this.inputs = inputs;
|
this.inputs = inputs;
|
||||||
@@ -31,32 +31,38 @@ class Action {
|
|||||||
createOrUpdateRelease() {
|
createOrUpdateRelease() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
if (this.inputs.allowUpdates) {
|
if (this.inputs.allowUpdates) {
|
||||||
|
let getResponse;
|
||||||
try {
|
try {
|
||||||
const getResponse = yield this.releases.getByTag(this.inputs.tag);
|
getResponse = yield this.releases.getByTag(this.inputs.tag);
|
||||||
return yield this.updateRelease(getResponse.data.id);
|
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
if (Action.noPublishedRelease(error)) {
|
return yield this.checkForMissingReleaseError(error);
|
||||||
return yield this.updateDraftOrCreateRelease();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
throw error;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return yield this.updateRelease(getResponse.data.id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return yield this.createRelease();
|
return yield this.createRelease();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
checkForMissingReleaseError(error) {
|
||||||
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
|
if (Action.noPublishedRelease(error)) {
|
||||||
|
return yield this.updateDraftOrCreateRelease();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
updateRelease(id) {
|
updateRelease(id) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return yield this.releases.update(id, this.inputs.tag, this.inputs.updatedReleaseBody, this.inputs.commit, this.inputs.draft, this.inputs.updatedReleaseName, this.inputs.prerelease);
|
return yield this.releases.update(id, this.inputs.tag, this.inputs.updatedReleaseBody, this.inputs.commit, this.inputs.discussionCategory, this.inputs.draft, this.inputs.updatedReleaseName, this.inputs.prerelease);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static noPublishedRelease(error) {
|
static noPublishedRelease(error) {
|
||||||
const errorMessage = new ErrorMessage_1.ErrorMessage(error);
|
const githubError = new GithubError_1.GithubError(error);
|
||||||
return errorMessage.status == 404;
|
return githubError.status == 404;
|
||||||
}
|
}
|
||||||
updateDraftOrCreateRelease() {
|
updateDraftOrCreateRelease() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
@@ -80,8 +86,7 @@ class Action {
|
|||||||
}
|
}
|
||||||
createRelease() {
|
createRelease() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const response = yield this.releases.create(this.inputs.tag, this.inputs.createdReleaseBody, this.inputs.commit, this.inputs.draft, this.inputs.createdReleaseName, this.inputs.prerelease);
|
return yield this.releases.create(this.inputs.tag, this.inputs.createdReleaseBody, this.inputs.commit, this.inputs.discussionCategory, this.inputs.draft, this.inputs.createdReleaseName, this.inputs.prerelease);
|
||||||
return response;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,23 +31,31 @@ class FileArtifactGlobber {
|
|||||||
constructor(globber = new Globber_1.FileGlobber()) {
|
constructor(globber = new Globber_1.FileGlobber()) {
|
||||||
this.globber = globber;
|
this.globber = globber;
|
||||||
}
|
}
|
||||||
globArtifactString(artifact, contentType) {
|
globArtifactString(artifact, contentType, throwsWhenNoFiles) {
|
||||||
return artifact.split(',')
|
return artifact.split(',')
|
||||||
.map(path => FileArtifactGlobber.expandPath(path))
|
.map(path => FileArtifactGlobber.expandPath(path))
|
||||||
.map(pattern => this.globPattern(pattern))
|
.map(pattern => this.globPattern(pattern, throwsWhenNoFiles))
|
||||||
.reduce((accumulated, current) => accumulated.concat(current))
|
.reduce((accumulated, current) => accumulated.concat(current))
|
||||||
.map(path => new Artifact_1.Artifact(path, contentType));
|
.map(path => new Artifact_1.Artifact(path, contentType));
|
||||||
}
|
}
|
||||||
globPattern(pattern) {
|
globPattern(pattern, throwsWhenNoFiles) {
|
||||||
const paths = this.globber.glob(pattern);
|
const paths = this.globber.glob(pattern);
|
||||||
if (paths.length == 0) {
|
if (paths.length == 0) {
|
||||||
FileArtifactGlobber.reportGlobWarning(pattern);
|
if (throwsWhenNoFiles) {
|
||||||
|
FileArtifactGlobber.throwGlobError(pattern);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
FileArtifactGlobber.reportGlobWarning(pattern);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return paths;
|
return paths;
|
||||||
}
|
}
|
||||||
static reportGlobWarning(pattern) {
|
static reportGlobWarning(pattern) {
|
||||||
core.warning(`Artifact pattern :${pattern} did not match any files`);
|
core.warning(`Artifact pattern :${pattern} did not match any files`);
|
||||||
}
|
}
|
||||||
|
static throwGlobError(pattern) {
|
||||||
|
throw Error(`Artifact pattern :${pattern} did not match any files`);
|
||||||
|
}
|
||||||
static expandPath(path) {
|
static expandPath(path) {
|
||||||
return untildify_1.default(path);
|
return untildify_1.default(path);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,9 +31,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|||||||
exports.GithubArtifactUploader = void 0;
|
exports.GithubArtifactUploader = void 0;
|
||||||
const core = __importStar(require("@actions/core"));
|
const core = __importStar(require("@actions/core"));
|
||||||
class GithubArtifactUploader {
|
class GithubArtifactUploader {
|
||||||
constructor(releases, replacesExistingArtifacts = true) {
|
constructor(releases, replacesExistingArtifacts = true, throwsUploadErrors = false) {
|
||||||
this.releases = releases;
|
this.releases = releases;
|
||||||
this.replacesExistingArtifacts = replacesExistingArtifacts;
|
this.replacesExistingArtifacts = replacesExistingArtifacts;
|
||||||
|
this.throwsUploadErrors = throwsUploadErrors;
|
||||||
}
|
}
|
||||||
uploadArtifacts(artifacts, releaseId, uploadUrl) {
|
uploadArtifacts(artifacts, releaseId, uploadUrl) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
@@ -57,15 +58,19 @@ class GithubArtifactUploader {
|
|||||||
yield this.uploadArtifact(artifact, releaseId, uploadUrl, retry - 1);
|
yield this.uploadArtifact(artifact, releaseId, uploadUrl, retry - 1);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.warning(`Failed to upload artifact ${artifact.name}. ${error.message}.`);
|
if (this.throwsUploadErrors) {
|
||||||
|
throw Error(`Failed to upload artifact ${artifact.name}. ${error.message}.`);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
core.warning(`Failed to upload artifact ${artifact.name}. ${error.message}.`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
deleteUpdatedArtifacts(artifacts, releaseId) {
|
deleteUpdatedArtifacts(artifacts, releaseId) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const response = yield this.releases.listArtifactsForRelease(releaseId);
|
const releaseAssets = yield this.releases.listArtifactsForRelease(releaseId);
|
||||||
const releaseAssets = response.data;
|
|
||||||
const assetByName = {};
|
const assetByName = {};
|
||||||
releaseAssets.forEach(asset => {
|
releaseAssets.forEach(asset => {
|
||||||
assetByName[asset.name] = asset;
|
assetByName[asset.name] = asset;
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
"use strict";
|
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
|
||||||
exports.ErrorMessage = void 0;
|
|
||||||
const GithubError_1 = require("./GithubError");
|
|
||||||
class ErrorMessage {
|
|
||||||
constructor(error) {
|
|
||||||
this.error = error;
|
|
||||||
this.githubErrors = this.generateGithubErrors();
|
|
||||||
}
|
|
||||||
generateGithubErrors() {
|
|
||||||
const errors = this.error.errors;
|
|
||||||
if (errors instanceof Array) {
|
|
||||||
return errors.map((err) => new GithubError_1.GithubError(err));
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
get status() {
|
|
||||||
return this.error.status;
|
|
||||||
}
|
|
||||||
hasErrorWithCode(code) {
|
|
||||||
return this.githubErrors.some((err) => err.code == code);
|
|
||||||
}
|
|
||||||
toString() {
|
|
||||||
const message = this.error.message;
|
|
||||||
const errors = this.githubErrors;
|
|
||||||
const status = this.status;
|
|
||||||
if (errors.length > 0) {
|
|
||||||
return `Error ${status}: ${message}\nErrors:\n${this.errorBulletedList(errors)}`;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
return `Error ${status}: ${message}`;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
errorBulletedList(errors) {
|
|
||||||
return errors.map((err) => `- ${err}`).join("\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exports.ErrorMessage = ErrorMessage;
|
|
||||||
@@ -1,57 +1,40 @@
|
|||||||
"use strict";
|
"use strict";
|
||||||
Object.defineProperty(exports, "__esModule", { value: true });
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
exports.GithubError = void 0;
|
exports.GithubError = void 0;
|
||||||
|
const GithubErrorDetail_1 = require("./GithubErrorDetail");
|
||||||
class GithubError {
|
class GithubError {
|
||||||
constructor(error) {
|
constructor(error) {
|
||||||
this.error = error;
|
this.error = error;
|
||||||
|
this.githubErrors = this.generateGithubErrors();
|
||||||
}
|
}
|
||||||
get code() {
|
generateGithubErrors() {
|
||||||
return this.error.code;
|
const errors = this.error.errors;
|
||||||
}
|
if (errors instanceof Array) {
|
||||||
toString() {
|
return errors.map((err) => new GithubErrorDetail_1.GithubErrorDetail(err));
|
||||||
const code = this.error.code;
|
|
||||||
switch (code) {
|
|
||||||
case 'missing':
|
|
||||||
return this.missingResourceMessage();
|
|
||||||
case 'missing_field':
|
|
||||||
return this.missingFieldMessage();
|
|
||||||
case 'invalid':
|
|
||||||
return this.invalidFieldMessage();
|
|
||||||
case 'already_exists':
|
|
||||||
return this.resourceAlreadyExists();
|
|
||||||
default:
|
|
||||||
return this.customErrorMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
customErrorMessage() {
|
|
||||||
const message = this.error.message;
|
|
||||||
const documentation = this.error.documentation_url;
|
|
||||||
let documentationMessage;
|
|
||||||
if (documentation) {
|
|
||||||
documentationMessage = `\nPlease see ${documentation}.`;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
documentationMessage = "";
|
return [];
|
||||||
}
|
}
|
||||||
return `${message}${documentationMessage}`;
|
|
||||||
}
|
}
|
||||||
invalidFieldMessage() {
|
get status() {
|
||||||
const resource = this.error.resource;
|
return this.error.status;
|
||||||
const field = this.error.field;
|
|
||||||
return `The ${field} field on ${resource} is an invalid format.`;
|
|
||||||
}
|
}
|
||||||
missingResourceMessage() {
|
hasErrorWithCode(code) {
|
||||||
const resource = this.error.resource;
|
return this.githubErrors.some((err) => err.code == code);
|
||||||
return `${resource} does not exist.`;
|
|
||||||
}
|
}
|
||||||
missingFieldMessage() {
|
toString() {
|
||||||
const resource = this.error.resource;
|
const message = this.error.message;
|
||||||
const field = this.error.field;
|
const errors = this.githubErrors;
|
||||||
return `The ${field} field on ${resource} is missing.`;
|
const status = this.status;
|
||||||
|
if (errors.length > 0) {
|
||||||
|
return `Error ${status}: ${message}\nErrors:\n${this.errorBulletedList(errors)}`;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return `Error ${status}: ${message}`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
resourceAlreadyExists() {
|
errorBulletedList(errors) {
|
||||||
const resource = this.error.resource;
|
return errors.map((err) => `- ${err}`).join("\n");
|
||||||
return `${resource} already exists.`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
exports.GithubError = GithubError;
|
exports.GithubError = GithubError;
|
||||||
|
|||||||
57
lib/GithubErrorDetail.js
Normal file
57
lib/GithubErrorDetail.js
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.GithubErrorDetail = void 0;
|
||||||
|
class GithubErrorDetail {
|
||||||
|
constructor(error) {
|
||||||
|
this.error = error;
|
||||||
|
}
|
||||||
|
get code() {
|
||||||
|
return this.error.code;
|
||||||
|
}
|
||||||
|
toString() {
|
||||||
|
const code = this.error.code;
|
||||||
|
switch (code) {
|
||||||
|
case 'missing':
|
||||||
|
return this.missingResourceMessage();
|
||||||
|
case 'missing_field':
|
||||||
|
return this.missingFieldMessage();
|
||||||
|
case 'invalid':
|
||||||
|
return this.invalidFieldMessage();
|
||||||
|
case 'already_exists':
|
||||||
|
return this.resourceAlreadyExists();
|
||||||
|
default:
|
||||||
|
return this.customErrorMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
customErrorMessage() {
|
||||||
|
const message = this.error.message;
|
||||||
|
const documentation = this.error.documentation_url;
|
||||||
|
let documentationMessage;
|
||||||
|
if (documentation) {
|
||||||
|
documentationMessage = `\nPlease see ${documentation}.`;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
documentationMessage = "";
|
||||||
|
}
|
||||||
|
return `${message}${documentationMessage}`;
|
||||||
|
}
|
||||||
|
invalidFieldMessage() {
|
||||||
|
const resource = this.error.resource;
|
||||||
|
const field = this.error.field;
|
||||||
|
return `The ${field} field on ${resource} is an invalid format.`;
|
||||||
|
}
|
||||||
|
missingResourceMessage() {
|
||||||
|
const resource = this.error.resource;
|
||||||
|
return `${resource} does not exist.`;
|
||||||
|
}
|
||||||
|
missingFieldMessage() {
|
||||||
|
const resource = this.error.resource;
|
||||||
|
const field = this.error.field;
|
||||||
|
return `The ${field} field on ${resource} is missing.`;
|
||||||
|
}
|
||||||
|
resourceAlreadyExists() {
|
||||||
|
const resource = this.error.resource;
|
||||||
|
return `${resource} already exists.`;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
exports.GithubErrorDetail = GithubErrorDetail;
|
||||||
@@ -42,10 +42,14 @@ class CoreInputs {
|
|||||||
contentType = 'raw';
|
contentType = 'raw';
|
||||||
}
|
}
|
||||||
return this.artifactGlobber
|
return this.artifactGlobber
|
||||||
.globArtifactString(artifacts, contentType);
|
.globArtifactString(artifacts, contentType, this.artifactErrorsFailBuild);
|
||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
get artifactErrorsFailBuild() {
|
||||||
|
const allow = core.getInput('artifactErrorsFailBuild');
|
||||||
|
return allow == 'true';
|
||||||
|
}
|
||||||
get createdReleaseBody() {
|
get createdReleaseBody() {
|
||||||
if (CoreInputs.omitBody)
|
if (CoreInputs.omitBody)
|
||||||
return undefined;
|
return undefined;
|
||||||
@@ -73,6 +77,13 @@ class CoreInputs {
|
|||||||
return undefined;
|
return undefined;
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
get discussionCategory() {
|
||||||
|
const category = core.getInput('discussionCategory');
|
||||||
|
if (category) {
|
||||||
|
return category;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
static get omitName() {
|
static get omitName() {
|
||||||
return core.getInput('omitName') == 'true';
|
return core.getInput('omitName') == 'true';
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ const Releases_1 = require("./Releases");
|
|||||||
const Action_1 = require("./Action");
|
const Action_1 = require("./Action");
|
||||||
const ArtifactUploader_1 = require("./ArtifactUploader");
|
const ArtifactUploader_1 = require("./ArtifactUploader");
|
||||||
const ArtifactGlobber_1 = require("./ArtifactGlobber");
|
const ArtifactGlobber_1 = require("./ArtifactGlobber");
|
||||||
const ErrorMessage_1 = require("./ErrorMessage");
|
const GithubError_1 = require("./GithubError");
|
||||||
function run() {
|
function run() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
try {
|
try {
|
||||||
@@ -43,8 +43,8 @@ function run() {
|
|||||||
yield action.perform();
|
yield action.perform();
|
||||||
}
|
}
|
||||||
catch (error) {
|
catch (error) {
|
||||||
const errorMessage = new ErrorMessage_1.ErrorMessage(error);
|
const githubError = new GithubError_1.GithubError(error);
|
||||||
core.setFailed(errorMessage.toString());
|
core.setFailed(githubError.toString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -55,7 +55,7 @@ function createAction() {
|
|||||||
const globber = new ArtifactGlobber_1.FileArtifactGlobber();
|
const globber = new ArtifactGlobber_1.FileArtifactGlobber();
|
||||||
const inputs = new Inputs_1.CoreInputs(globber, context);
|
const inputs = new Inputs_1.CoreInputs(globber, context);
|
||||||
const releases = new Releases_1.GithubReleases(inputs, git);
|
const releases = new Releases_1.GithubReleases(inputs, git);
|
||||||
const uploader = new ArtifactUploader_1.GithubArtifactUploader(releases, inputs.replacesArtifacts);
|
const uploader = new ArtifactUploader_1.GithubArtifactUploader(releases, inputs.replacesArtifacts, inputs.artifactErrorsFailBuild);
|
||||||
return new Action_1.Action(inputs, releases, uploader);
|
return new Action_1.Action(inputs, releases, uploader);
|
||||||
}
|
}
|
||||||
run();
|
run();
|
||||||
|
|||||||
@@ -15,12 +15,13 @@ class GithubReleases {
|
|||||||
this.inputs = inputs;
|
this.inputs = inputs;
|
||||||
this.git = git;
|
this.git = git;
|
||||||
}
|
}
|
||||||
create(tag, body, commitHash, draft, name, prerelease) {
|
create(tag, body, commitHash, discussionCategory, draft, name, prerelease) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// noinspection TypeScriptValidateJSTypes
|
// noinspection TypeScriptValidateJSTypes
|
||||||
return this.git.repos.createRelease({
|
return this.git.repos.createRelease({
|
||||||
body: body,
|
body: body,
|
||||||
name: name,
|
name: name,
|
||||||
|
discussion_category_name: discussionCategory,
|
||||||
draft: draft,
|
draft: draft,
|
||||||
owner: this.inputs.owner,
|
owner: this.inputs.owner,
|
||||||
prerelease: prerelease,
|
prerelease: prerelease,
|
||||||
@@ -50,7 +51,7 @@ class GithubReleases {
|
|||||||
}
|
}
|
||||||
listArtifactsForRelease(releaseId) {
|
listArtifactsForRelease(releaseId) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return this.git.repos.listReleaseAssets({
|
return this.git.paginate(this.git.repos.listReleaseAssets, {
|
||||||
owner: this.inputs.owner,
|
owner: this.inputs.owner,
|
||||||
release_id: releaseId,
|
release_id: releaseId,
|
||||||
repo: this.inputs.repo
|
repo: this.inputs.repo
|
||||||
@@ -65,13 +66,14 @@ class GithubReleases {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
update(id, tag, body, commitHash, draft, name, prerelease) {
|
update(id, tag, body, commitHash, discussionCategory, draft, name, prerelease) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
// noinspection TypeScriptValidateJSTypes
|
// noinspection TypeScriptValidateJSTypes
|
||||||
return this.git.repos.updateRelease({
|
return this.git.repos.updateRelease({
|
||||||
release_id: id,
|
release_id: id,
|
||||||
body: body,
|
body: body,
|
||||||
name: name,
|
name: name,
|
||||||
|
discussion_category_name: discussionCategory,
|
||||||
draft: draft,
|
draft: draft,
|
||||||
owner: this.inputs.owner,
|
owner: this.inputs.owner,
|
||||||
prerelease: prerelease,
|
prerelease: prerelease,
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import {Inputs} from "./Inputs";
|
import {Inputs} from "./Inputs";
|
||||||
import {CreateReleaseResponse, Releases, UpdateReleaseResponse} from "./Releases";
|
import {CreateReleaseResponse, ReleaseByTagResponse, Releases, UpdateReleaseResponse} from "./Releases";
|
||||||
import {ArtifactUploader} from "./ArtifactUploader";
|
import {ArtifactUploader} from "./ArtifactUploader";
|
||||||
import {ErrorMessage} from "./ErrorMessage";
|
import {GithubError} from "./GithubError";
|
||||||
|
|
||||||
export class Action {
|
export class Action {
|
||||||
private inputs: Inputs
|
private inputs: Inputs
|
||||||
@@ -27,20 +27,26 @@ export class Action {
|
|||||||
|
|
||||||
private async createOrUpdateRelease(): Promise<CreateReleaseResponse | UpdateReleaseResponse> {
|
private async createOrUpdateRelease(): Promise<CreateReleaseResponse | UpdateReleaseResponse> {
|
||||||
if (this.inputs.allowUpdates) {
|
if (this.inputs.allowUpdates) {
|
||||||
|
let getResponse: ReleaseByTagResponse
|
||||||
try {
|
try {
|
||||||
const getResponse = await this.releases.getByTag(this.inputs.tag)
|
getResponse = await this.releases.getByTag(this.inputs.tag)
|
||||||
return await this.updateRelease(getResponse.data.id)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
if (Action.noPublishedRelease(error)) {
|
return await this.checkForMissingReleaseError(error)
|
||||||
return await this.updateDraftOrCreateRelease()
|
|
||||||
} else {
|
|
||||||
throw error
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return await this.updateRelease(getResponse.data.id)
|
||||||
} else {
|
} else {
|
||||||
return await this.createRelease()
|
return await this.createRelease()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async checkForMissingReleaseError(error: Error) : Promise<CreateReleaseResponse | UpdateReleaseResponse> {
|
||||||
|
if (Action.noPublishedRelease(error)) {
|
||||||
|
return await this.updateDraftOrCreateRelease()
|
||||||
|
} else {
|
||||||
|
throw error
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private async updateRelease(id: number): Promise<UpdateReleaseResponse> {
|
private async updateRelease(id: number): Promise<UpdateReleaseResponse> {
|
||||||
return await this.releases.update(
|
return await this.releases.update(
|
||||||
@@ -48,6 +54,7 @@ export class Action {
|
|||||||
this.inputs.tag,
|
this.inputs.tag,
|
||||||
this.inputs.updatedReleaseBody,
|
this.inputs.updatedReleaseBody,
|
||||||
this.inputs.commit,
|
this.inputs.commit,
|
||||||
|
this.inputs.discussionCategory,
|
||||||
this.inputs.draft,
|
this.inputs.draft,
|
||||||
this.inputs.updatedReleaseName,
|
this.inputs.updatedReleaseName,
|
||||||
this.inputs.prerelease
|
this.inputs.prerelease
|
||||||
@@ -55,8 +62,8 @@ export class Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static noPublishedRelease(error: any): boolean {
|
private static noPublishedRelease(error: any): boolean {
|
||||||
const errorMessage = new ErrorMessage(error)
|
const githubError = new GithubError(error)
|
||||||
return errorMessage.status == 404
|
return githubError.status == 404
|
||||||
}
|
}
|
||||||
|
|
||||||
private async updateDraftOrCreateRelease(): Promise<CreateReleaseResponse | UpdateReleaseResponse> {
|
private async updateDraftOrCreateRelease(): Promise<CreateReleaseResponse | UpdateReleaseResponse> {
|
||||||
@@ -78,15 +85,14 @@ export class Action {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private async createRelease(): Promise<CreateReleaseResponse> {
|
private async createRelease(): Promise<CreateReleaseResponse> {
|
||||||
const response = await this.releases.create(
|
return await this.releases.create(
|
||||||
this.inputs.tag,
|
this.inputs.tag,
|
||||||
this.inputs.createdReleaseBody,
|
this.inputs.createdReleaseBody,
|
||||||
this.inputs.commit,
|
this.inputs.commit,
|
||||||
|
this.inputs.discussionCategory,
|
||||||
this.inputs.draft,
|
this.inputs.draft,
|
||||||
this.inputs.createdReleaseName,
|
this.inputs.createdReleaseName,
|
||||||
this.inputs.prerelease
|
this.inputs.prerelease
|
||||||
)
|
)
|
||||||
|
|
||||||
return response
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import {Artifact} from "./Artifact";
|
|||||||
import untildify from "untildify";
|
import untildify from "untildify";
|
||||||
|
|
||||||
export interface ArtifactGlobber {
|
export interface ArtifactGlobber {
|
||||||
globArtifactString(artifact: string, contentType: string): Artifact[]
|
globArtifactString(artifact: string, contentType: string, throwsWhenNoFiles: boolean): Artifact[]
|
||||||
}
|
}
|
||||||
|
|
||||||
export class FileArtifactGlobber implements ArtifactGlobber {
|
export class FileArtifactGlobber implements ArtifactGlobber {
|
||||||
@@ -14,18 +14,22 @@ export class FileArtifactGlobber implements ArtifactGlobber {
|
|||||||
this.globber = globber
|
this.globber = globber
|
||||||
}
|
}
|
||||||
|
|
||||||
globArtifactString(artifact: string, contentType: string): Artifact[] {
|
globArtifactString(artifact: string, contentType: string, throwsWhenNoFiles: boolean): Artifact[] {
|
||||||
return artifact.split(',')
|
return artifact.split(',')
|
||||||
.map(path => FileArtifactGlobber.expandPath(path))
|
.map(path => FileArtifactGlobber.expandPath(path))
|
||||||
.map(pattern => this.globPattern(pattern))
|
.map(pattern => this.globPattern(pattern, throwsWhenNoFiles))
|
||||||
.reduce((accumulated, current) => accumulated.concat(current))
|
.reduce((accumulated, current) => accumulated.concat(current))
|
||||||
.map(path => new Artifact(path, contentType))
|
.map(path => new Artifact(path, contentType))
|
||||||
}
|
}
|
||||||
|
|
||||||
private globPattern(pattern: string): string[] {
|
private globPattern(pattern: string, throwsWhenNoFiles: boolean): string[] {
|
||||||
const paths = this.globber.glob(pattern)
|
const paths = this.globber.glob(pattern)
|
||||||
if (paths.length == 0) {
|
if (paths.length == 0) {
|
||||||
FileArtifactGlobber.reportGlobWarning(pattern)
|
if (throwsWhenNoFiles) {
|
||||||
|
FileArtifactGlobber.throwGlobError(pattern)
|
||||||
|
} else {
|
||||||
|
FileArtifactGlobber.reportGlobWarning(pattern)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return paths
|
return paths
|
||||||
}
|
}
|
||||||
@@ -34,6 +38,10 @@ export class FileArtifactGlobber implements ArtifactGlobber {
|
|||||||
core.warning(`Artifact pattern :${pattern} did not match any files`)
|
core.warning(`Artifact pattern :${pattern} did not match any files`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static throwGlobError(pattern: string) {
|
||||||
|
throw Error(`Artifact pattern :${pattern} did not match any files`)
|
||||||
|
}
|
||||||
|
|
||||||
private static expandPath(path: string): string {
|
private static expandPath(path: string): string {
|
||||||
return untildify(path)
|
return untildify(path)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ export class GithubArtifactUploader implements ArtifactUploader {
|
|||||||
constructor(
|
constructor(
|
||||||
private releases: Releases,
|
private releases: Releases,
|
||||||
private replacesExistingArtifacts: boolean = true,
|
private replacesExistingArtifacts: boolean = true,
|
||||||
|
private throwsUploadErrors: boolean = false,
|
||||||
) {
|
) {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -41,14 +42,17 @@ export class GithubArtifactUploader implements ArtifactUploader {
|
|||||||
core.warning(`Failed to upload artifact ${artifact.name}. ${error.message}. Retrying...`)
|
core.warning(`Failed to upload artifact ${artifact.name}. ${error.message}. Retrying...`)
|
||||||
await this.uploadArtifact(artifact, releaseId, uploadUrl, retry - 1)
|
await this.uploadArtifact(artifact, releaseId, uploadUrl, retry - 1)
|
||||||
} else {
|
} else {
|
||||||
core.warning(`Failed to upload artifact ${artifact.name}. ${error.message}.`)
|
if (this.throwsUploadErrors) {
|
||||||
|
throw Error(`Failed to upload artifact ${artifact.name}. ${error.message}.`)
|
||||||
|
} else {
|
||||||
|
core.warning(`Failed to upload artifact ${artifact.name}. ${error.message}.`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async deleteUpdatedArtifacts(artifacts: Artifact[], releaseId: number): Promise<void> {
|
private async deleteUpdatedArtifacts(artifacts: Artifact[], releaseId: number): Promise<void> {
|
||||||
const response = await this.releases.listArtifactsForRelease(releaseId)
|
const releaseAssets = await this.releases.listArtifactsForRelease(releaseId)
|
||||||
const releaseAssets = response.data
|
|
||||||
const assetByName: Record<string, { id: number; name: string }> = {}
|
const assetByName: Record<string, { id: number; name: string }> = {}
|
||||||
releaseAssets.forEach(asset => {
|
releaseAssets.forEach(asset => {
|
||||||
assetByName[asset.name] = asset
|
assetByName[asset.name] = asset
|
||||||
|
|||||||
@@ -1,44 +0,0 @@
|
|||||||
import {GithubError} from "./GithubError"
|
|
||||||
|
|
||||||
export class ErrorMessage {
|
|
||||||
private error: any
|
|
||||||
private githubErrors: GithubError[]
|
|
||||||
|
|
||||||
constructor(error: any) {
|
|
||||||
this.error = error
|
|
||||||
this.githubErrors = this.generateGithubErrors()
|
|
||||||
}
|
|
||||||
|
|
||||||
private generateGithubErrors(): GithubError[] {
|
|
||||||
const errors = this.error.errors
|
|
||||||
if (errors instanceof Array) {
|
|
||||||
return errors.map((err) => new GithubError(err))
|
|
||||||
} else {
|
|
||||||
return []
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
get status(): number {
|
|
||||||
return this.error.status
|
|
||||||
}
|
|
||||||
|
|
||||||
hasErrorWithCode(code: String): boolean {
|
|
||||||
return this.githubErrors.some((err) => err.code == code)
|
|
||||||
}
|
|
||||||
|
|
||||||
toString(): string {
|
|
||||||
const message = this.error.message
|
|
||||||
const errors = this.githubErrors
|
|
||||||
const status = this.status
|
|
||||||
if (errors.length > 0) {
|
|
||||||
return `Error ${status}: ${message}\nErrors:\n${this.errorBulletedList(errors)}`
|
|
||||||
} else {
|
|
||||||
return `Error ${status}: ${message}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private errorBulletedList(errors: GithubError[]): string {
|
|
||||||
return errors.map((err) => `- ${err}`).join("\n")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,65 +1,44 @@
|
|||||||
|
import {GithubErrorDetail} from "./GithubErrorDetail"
|
||||||
|
|
||||||
export class GithubError {
|
export class GithubError {
|
||||||
private error: any;
|
private error: any
|
||||||
|
private readonly githubErrors: GithubErrorDetail[]
|
||||||
|
|
||||||
constructor(error: any) {
|
constructor(error: any) {
|
||||||
this.error = error
|
this.error = error
|
||||||
|
this.githubErrors = this.generateGithubErrors()
|
||||||
}
|
}
|
||||||
|
|
||||||
get code(): string {
|
private generateGithubErrors(): GithubErrorDetail[] {
|
||||||
return this.error.code
|
const errors = this.error.errors
|
||||||
|
if (errors instanceof Array) {
|
||||||
|
return errors.map((err) => new GithubErrorDetail(err))
|
||||||
|
} else {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
get status(): number {
|
||||||
|
return this.error.status
|
||||||
|
}
|
||||||
|
|
||||||
|
hasErrorWithCode(code: String): boolean {
|
||||||
|
return this.githubErrors.some((err) => err.code == code)
|
||||||
}
|
}
|
||||||
|
|
||||||
toString(): string {
|
toString(): string {
|
||||||
const code = this.error.code
|
const message = this.error.message
|
||||||
switch (code) {
|
const errors = this.githubErrors
|
||||||
case 'missing':
|
const status = this.status
|
||||||
return this.missingResourceMessage()
|
if (errors.length > 0) {
|
||||||
case 'missing_field':
|
return `Error ${status}: ${message}\nErrors:\n${this.errorBulletedList(errors)}`
|
||||||
return this.missingFieldMessage()
|
|
||||||
case 'invalid':
|
|
||||||
return this.invalidFieldMessage()
|
|
||||||
case 'already_exists':
|
|
||||||
return this.resourceAlreadyExists()
|
|
||||||
default:
|
|
||||||
return this.customErrorMessage()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private customErrorMessage(): string {
|
|
||||||
const message = this.error.message;
|
|
||||||
const documentation = this.error.documentation_url
|
|
||||||
|
|
||||||
let documentationMessage: string
|
|
||||||
if (documentation) {
|
|
||||||
documentationMessage = `\nPlease see ${documentation}.`
|
|
||||||
} else {
|
} else {
|
||||||
documentationMessage = ""
|
return `Error ${status}: ${message}`
|
||||||
}
|
}
|
||||||
|
|
||||||
return `${message}${documentationMessage}`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private invalidFieldMessage(): string {
|
private errorBulletedList(errors: GithubErrorDetail[]): string {
|
||||||
const resource = this.error.resource
|
return errors.map((err) => `- ${err}`).join("\n")
|
||||||
const field = this.error.field
|
|
||||||
|
|
||||||
return `The ${field} field on ${resource} is an invalid format.`
|
|
||||||
}
|
|
||||||
|
|
||||||
private missingResourceMessage(): string {
|
|
||||||
const resource = this.error.resource
|
|
||||||
return `${resource} does not exist.`
|
|
||||||
}
|
|
||||||
|
|
||||||
private missingFieldMessage(): string {
|
|
||||||
const resource = this.error.resource
|
|
||||||
const field = this.error.field
|
|
||||||
|
|
||||||
return `The ${field} field on ${resource} is missing.`
|
|
||||||
}
|
|
||||||
|
|
||||||
private resourceAlreadyExists(): string {
|
|
||||||
const resource = this.error.resource
|
|
||||||
return `${resource} already exists.`
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
65
src/GithubErrorDetail.ts
Normal file
65
src/GithubErrorDetail.ts
Normal file
@@ -0,0 +1,65 @@
|
|||||||
|
export class GithubErrorDetail {
|
||||||
|
private error: any;
|
||||||
|
|
||||||
|
constructor(error: any) {
|
||||||
|
this.error = error
|
||||||
|
}
|
||||||
|
|
||||||
|
get code(): string {
|
||||||
|
return this.error.code
|
||||||
|
}
|
||||||
|
|
||||||
|
toString(): string {
|
||||||
|
const code = this.error.code
|
||||||
|
switch (code) {
|
||||||
|
case 'missing':
|
||||||
|
return this.missingResourceMessage()
|
||||||
|
case 'missing_field':
|
||||||
|
return this.missingFieldMessage()
|
||||||
|
case 'invalid':
|
||||||
|
return this.invalidFieldMessage()
|
||||||
|
case 'already_exists':
|
||||||
|
return this.resourceAlreadyExists()
|
||||||
|
default:
|
||||||
|
return this.customErrorMessage()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private customErrorMessage(): string {
|
||||||
|
const message = this.error.message;
|
||||||
|
const documentation = this.error.documentation_url
|
||||||
|
|
||||||
|
let documentationMessage: string
|
||||||
|
if (documentation) {
|
||||||
|
documentationMessage = `\nPlease see ${documentation}.`
|
||||||
|
} else {
|
||||||
|
documentationMessage = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
return `${message}${documentationMessage}`
|
||||||
|
}
|
||||||
|
|
||||||
|
private invalidFieldMessage(): string {
|
||||||
|
const resource = this.error.resource
|
||||||
|
const field = this.error.field
|
||||||
|
|
||||||
|
return `The ${field} field on ${resource} is an invalid format.`
|
||||||
|
}
|
||||||
|
|
||||||
|
private missingResourceMessage(): string {
|
||||||
|
const resource = this.error.resource
|
||||||
|
return `${resource} does not exist.`
|
||||||
|
}
|
||||||
|
|
||||||
|
private missingFieldMessage(): string {
|
||||||
|
const resource = this.error.resource
|
||||||
|
const field = this.error.field
|
||||||
|
|
||||||
|
return `The ${field} field on ${resource} is missing.`
|
||||||
|
}
|
||||||
|
|
||||||
|
private resourceAlreadyExists(): string {
|
||||||
|
const resource = this.error.resource
|
||||||
|
return `${resource} already exists.`
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,10 +6,12 @@ import {Artifact} from './Artifact';
|
|||||||
|
|
||||||
export interface Inputs {
|
export interface Inputs {
|
||||||
readonly allowUpdates: boolean
|
readonly allowUpdates: boolean
|
||||||
|
readonly artifactErrorsFailBuild: boolean
|
||||||
readonly artifacts: Artifact[]
|
readonly artifacts: Artifact[]
|
||||||
readonly commit: string
|
readonly commit: string
|
||||||
readonly createdReleaseBody?: string
|
readonly createdReleaseBody?: string
|
||||||
readonly createdReleaseName?: string
|
readonly createdReleaseName?: string
|
||||||
|
readonly discussionCategory?: string
|
||||||
readonly draft: boolean
|
readonly draft: boolean
|
||||||
readonly owner: string
|
readonly owner: string
|
||||||
readonly prerelease: boolean
|
readonly prerelease: boolean
|
||||||
@@ -46,11 +48,16 @@ export class CoreInputs implements Inputs {
|
|||||||
contentType = 'raw'
|
contentType = 'raw'
|
||||||
}
|
}
|
||||||
return this.artifactGlobber
|
return this.artifactGlobber
|
||||||
.globArtifactString(artifacts, contentType)
|
.globArtifactString(artifacts, contentType, this.artifactErrorsFailBuild)
|
||||||
}
|
}
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get artifactErrorsFailBuild(): boolean {
|
||||||
|
const allow = core.getInput('artifactErrorsFailBuild')
|
||||||
|
return allow == 'true'
|
||||||
|
}
|
||||||
|
|
||||||
get createdReleaseBody(): string | undefined {
|
get createdReleaseBody(): string | undefined {
|
||||||
if (CoreInputs.omitBody) return undefined
|
if (CoreInputs.omitBody) return undefined
|
||||||
return this.body
|
return this.body
|
||||||
@@ -60,7 +67,7 @@ export class CoreInputs implements Inputs {
|
|||||||
return core.getInput('omitBody') == 'true'
|
return core.getInput('omitBody') == 'true'
|
||||||
}
|
}
|
||||||
|
|
||||||
private get body() : string | undefined {
|
private get body(): string | undefined {
|
||||||
const body = core.getInput('body')
|
const body = core.getInput('body')
|
||||||
if (body) {
|
if (body) {
|
||||||
return body
|
return body
|
||||||
@@ -83,6 +90,14 @@ export class CoreInputs implements Inputs {
|
|||||||
return this.name
|
return this.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get discussionCategory(): string | undefined {
|
||||||
|
const category = core.getInput('discussionCategory')
|
||||||
|
if (category) {
|
||||||
|
return category
|
||||||
|
}
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
private static get omitName(): boolean {
|
private static get omitName(): boolean {
|
||||||
return core.getInput('omitName') == 'true'
|
return core.getInput('omitName') == 'true'
|
||||||
}
|
}
|
||||||
@@ -156,7 +171,7 @@ export class CoreInputs implements Inputs {
|
|||||||
}
|
}
|
||||||
|
|
||||||
get updatedReleaseName(): string | undefined {
|
get updatedReleaseName(): string | undefined {
|
||||||
if (CoreInputs.omitName || CoreInputs.omitNameDuringUpdate) return undefined
|
if (CoreInputs.omitName || CoreInputs.omitNameDuringUpdate) return undefined
|
||||||
return this.name
|
return this.name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,15 +5,15 @@ import { GithubReleases } from './Releases';
|
|||||||
import { Action } from './Action';
|
import { Action } from './Action';
|
||||||
import { GithubArtifactUploader } from './ArtifactUploader';
|
import { GithubArtifactUploader } from './ArtifactUploader';
|
||||||
import { FileArtifactGlobber } from './ArtifactGlobber';
|
import { FileArtifactGlobber } from './ArtifactGlobber';
|
||||||
import { ErrorMessage } from './ErrorMessage';
|
import { GithubError } from './GithubError';
|
||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
const action = createAction()
|
const action = createAction()
|
||||||
await action.perform()
|
await action.perform()
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const errorMessage = new ErrorMessage(error)
|
const githubError = new GithubError(error)
|
||||||
core.setFailed(errorMessage.toString());
|
core.setFailed(githubError.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ function createAction(): Action {
|
|||||||
|
|
||||||
const inputs = new CoreInputs(globber, context)
|
const inputs = new CoreInputs(globber, context)
|
||||||
const releases = new GithubReleases(inputs, git)
|
const releases = new GithubReleases(inputs, git)
|
||||||
const uploader = new GithubArtifactUploader(releases, inputs.replacesArtifacts)
|
const uploader = new GithubArtifactUploader(releases, inputs.replacesArtifacts, inputs.artifactErrorsFailBuild)
|
||||||
return new Action(inputs, releases, uploader)
|
return new Action(inputs, releases, uploader)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import {Inputs} from "./Inputs";
|
|||||||
export type CreateReleaseResponse = RestEndpointMethodTypes["repos"]["createRelease"]["response"]
|
export type CreateReleaseResponse = RestEndpointMethodTypes["repos"]["createRelease"]["response"]
|
||||||
export type ReleaseByTagResponse = RestEndpointMethodTypes["repos"]["getReleaseByTag"]["response"]
|
export type ReleaseByTagResponse = RestEndpointMethodTypes["repos"]["getReleaseByTag"]["response"]
|
||||||
export type ListReleasesResponse = RestEndpointMethodTypes["repos"]["listReleases"]["response"]
|
export type ListReleasesResponse = RestEndpointMethodTypes["repos"]["listReleases"]["response"]
|
||||||
export type ListReleaseAssetsResponse = RestEndpointMethodTypes["repos"]["listReleaseAssets"]["response"]
|
export type ListReleaseAssetsResponseData = RestEndpointMethodTypes["repos"]["listReleaseAssets"]["response"]["data"]
|
||||||
export type UpdateReleaseResponse = RestEndpointMethodTypes["repos"]["updateRelease"]["response"]
|
export type UpdateReleaseResponse = RestEndpointMethodTypes["repos"]["updateRelease"]["response"]
|
||||||
export type UploadArtifactResponse = RestEndpointMethodTypes["repos"]["uploadReleaseAsset"]["response"]
|
export type UploadArtifactResponse = RestEndpointMethodTypes["repos"]["uploadReleaseAsset"]["response"]
|
||||||
|
|
||||||
@@ -15,6 +15,7 @@ export interface Releases {
|
|||||||
tag: string,
|
tag: string,
|
||||||
body?: string,
|
body?: string,
|
||||||
commitHash?: string,
|
commitHash?: string,
|
||||||
|
discussionCategory?: string,
|
||||||
draft?: boolean,
|
draft?: boolean,
|
||||||
name?: string,
|
name?: string,
|
||||||
prerelease?: boolean
|
prerelease?: boolean
|
||||||
@@ -24,7 +25,7 @@ export interface Releases {
|
|||||||
|
|
||||||
getByTag(tag: string): Promise<ReleaseByTagResponse>
|
getByTag(tag: string): Promise<ReleaseByTagResponse>
|
||||||
|
|
||||||
listArtifactsForRelease(releaseId: number): Promise<ListReleaseAssetsResponse>
|
listArtifactsForRelease(releaseId: number): Promise<ListReleaseAssetsResponseData>
|
||||||
|
|
||||||
listReleases(): Promise<ListReleasesResponse>
|
listReleases(): Promise<ListReleasesResponse>
|
||||||
|
|
||||||
@@ -33,6 +34,7 @@ export interface Releases {
|
|||||||
tag: string,
|
tag: string,
|
||||||
body?: string,
|
body?: string,
|
||||||
commitHash?: string,
|
commitHash?: string,
|
||||||
|
discussionCategory?: string,
|
||||||
draft?: boolean,
|
draft?: boolean,
|
||||||
name?: string,
|
name?: string,
|
||||||
prerelease?: boolean
|
prerelease?: boolean
|
||||||
@@ -61,6 +63,7 @@ export class GithubReleases implements Releases {
|
|||||||
tag: string,
|
tag: string,
|
||||||
body?: string,
|
body?: string,
|
||||||
commitHash?: string,
|
commitHash?: string,
|
||||||
|
discussionCategory?: string,
|
||||||
draft?: boolean,
|
draft?: boolean,
|
||||||
name?: string,
|
name?: string,
|
||||||
prerelease?: boolean
|
prerelease?: boolean
|
||||||
@@ -69,6 +72,7 @@ export class GithubReleases implements Releases {
|
|||||||
return this.git.repos.createRelease({
|
return this.git.repos.createRelease({
|
||||||
body: body,
|
body: body,
|
||||||
name: name,
|
name: name,
|
||||||
|
discussion_category_name: discussionCategory,
|
||||||
draft: draft,
|
draft: draft,
|
||||||
owner: this.inputs.owner,
|
owner: this.inputs.owner,
|
||||||
prerelease: prerelease,
|
prerelease: prerelease,
|
||||||
@@ -98,8 +102,8 @@ export class GithubReleases implements Releases {
|
|||||||
|
|
||||||
async listArtifactsForRelease(
|
async listArtifactsForRelease(
|
||||||
releaseId: number
|
releaseId: number
|
||||||
): Promise<ListReleaseAssetsResponse> {
|
): Promise<ListReleaseAssetsResponseData> {
|
||||||
return this.git.repos.listReleaseAssets({
|
return this.git.paginate(this.git.repos.listReleaseAssets, {
|
||||||
owner: this.inputs.owner,
|
owner: this.inputs.owner,
|
||||||
release_id: releaseId,
|
release_id: releaseId,
|
||||||
repo: this.inputs.repo
|
repo: this.inputs.repo
|
||||||
@@ -118,6 +122,7 @@ export class GithubReleases implements Releases {
|
|||||||
tag: string,
|
tag: string,
|
||||||
body?: string,
|
body?: string,
|
||||||
commitHash?: string,
|
commitHash?: string,
|
||||||
|
discussionCategory?: string,
|
||||||
draft?: boolean,
|
draft?: boolean,
|
||||||
name?: string,
|
name?: string,
|
||||||
prerelease?: boolean
|
prerelease?: boolean
|
||||||
@@ -127,6 +132,7 @@ export class GithubReleases implements Releases {
|
|||||||
release_id: id,
|
release_id: id,
|
||||||
body: body,
|
body: body,
|
||||||
name: name,
|
name: name,
|
||||||
|
discussion_category_name: discussionCategory,
|
||||||
draft: draft,
|
draft: draft,
|
||||||
owner: this.inputs.owner,
|
owner: this.inputs.owner,
|
||||||
prerelease: prerelease,
|
prerelease: prerelease,
|
||||||
|
|||||||
Reference in New Issue
Block a user