Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2bea8f5693 |
4
.gitignore
vendored
4
.gitignore
vendored
@@ -1,5 +1,5 @@
|
|||||||
#node_modules/
|
# node_modules/
|
||||||
__tests__/runner/*
|
# __tests__/runner/*
|
||||||
|
|
||||||
# Created by https://www.gitignore.io/api/webstorm
|
# Created by https://www.gitignore.io/api/webstorm
|
||||||
# Edit at https://www.gitignore.io/?templates=webstorm
|
# Edit at https://www.gitignore.io/?templates=webstorm
|
||||||
|
|||||||
@@ -13,9 +13,7 @@ This action will create a github release and optionally upload an artifact to it
|
|||||||
- **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. This is primarily useful for preserving the release body during updates.
|
- **omitBody**: Indicates if the release body should be omitted. This is primarily useful for preserving the release body during updates.
|
||||||
- **omitBodyDuringUpdate**: Indicates if the release body should be omitted during updates. The body will still be applied for newly created releases. This will preserve the existing body during updates.
|
|
||||||
- **omitName**: Indicates if the release name should be omitted. This is primarily useful for preserving the release name during updates.
|
- **omitName**: Indicates if the release name should be omitted. This is primarily useful for preserving the release name during updates.
|
||||||
- **omitNameDuringUpdate**: Indicates if the release name should be omitted during updates. The name will still be applied for newly created releases. This will preserve the existing name during updates.
|
|
||||||
- **prerelease**: Optionally marks this release as prerelease. Set to true to enable.
|
- **prerelease**: Optionally marks this release as prerelease. Set to true to enable.
|
||||||
- **replacesArtifacts**: Indicates if existing release artifacts should be replaced. Defaults to true.
|
- **replacesArtifacts**: Indicates if existing release artifacts should be replaced. Defaults to true.
|
||||||
- **tag**: An optional tag for the release. If this is omitted the git ref will be used (if it is a tag).
|
- **tag**: An optional tag for the release. If this is omitted the git ref will be used (if it is a tag).
|
||||||
|
|||||||
@@ -16,19 +16,17 @@ const artifacts = [
|
|||||||
new Artifact('a/art1'),
|
new Artifact('a/art1'),
|
||||||
new Artifact('b/art2')
|
new Artifact('b/art2')
|
||||||
]
|
]
|
||||||
|
const artifactData = Buffer.from('blob', 'utf-8')
|
||||||
const createBody = 'createBody'
|
const body = 'body'
|
||||||
const createName = 'createName'
|
|
||||||
const commit = 'commit'
|
const commit = 'commit'
|
||||||
const draft = true
|
const draft = true
|
||||||
const id = 100
|
const id = 100
|
||||||
|
const name = 'name'
|
||||||
const prerelease = true
|
const prerelease = true
|
||||||
const releaseId = 101
|
const releaseId = 101
|
||||||
const replacesArtifacts = true
|
const replacesArtifacts = true
|
||||||
const tag = 'tag'
|
const tag = 'tag'
|
||||||
const token = 'token'
|
const token = 'token'
|
||||||
const updateBody = 'updateBody'
|
|
||||||
const updateName = 'updateName'
|
|
||||||
const url = 'http://api.example.com'
|
const url = 'http://api.example.com'
|
||||||
|
|
||||||
describe("Action", () => {
|
describe("Action", () => {
|
||||||
@@ -45,7 +43,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, createBody, commit, draft, createName, prerelease)
|
expect(createMock).toBeCalledWith(tag, body, commit, draft, name, prerelease)
|
||||||
expect(uploadMock).not.toBeCalled()
|
expect(uploadMock).not.toBeCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -56,7 +54,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, createBody, commit, draft, createName, prerelease)
|
expect(createMock).toBeCalledWith(tag, body, commit, draft, name, prerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -72,7 +70,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, createBody, commit, draft, createName, prerelease)
|
expect(createMock).toBeCalledWith(tag, body, commit, draft, name, prerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -82,7 +80,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, createBody, commit, draft, createName, prerelease)
|
expect(createMock).toBeCalledWith(tag, body, commit, draft, name, prerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -97,7 +95,7 @@ describe("Action", () => {
|
|||||||
expect(error).toEqual("error")
|
expect(error).toEqual("error")
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, createBody, commit, draft, createName, prerelease)
|
expect(createMock).toBeCalledWith(tag, body, commit, draft, name, prerelease)
|
||||||
expect(uploadMock).not.toBeCalled()
|
expect(uploadMock).not.toBeCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -138,7 +136,7 @@ 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, body, commit, draft, name, prerelease)
|
||||||
expect(uploadMock).not.toBeCalled()
|
expect(uploadMock).not.toBeCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -153,7 +151,7 @@ describe("Action", () => {
|
|||||||
expect(error).toEqual("error")
|
expect(error).toEqual("error")
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, createBody, commit, draft, createName, prerelease)
|
expect(createMock).toBeCalledWith(tag, body, commit, draft, name, prerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -170,7 +168,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(updateMock).toBeCalledWith(id, tag, updateBody, commit, draft, updateName, prerelease)
|
expect(updateMock).toBeCalledWith(id, tag, body, commit, draft, name, prerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -180,7 +178,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(updateMock).toBeCalledWith(id, tag, updateBody, commit, draft, updateName, prerelease)
|
expect(updateMock).toBeCalledWith(id, tag, body, commit, draft, name, prerelease)
|
||||||
expect(uploadMock).not.toBeCalled()
|
expect(uploadMock).not.toBeCalled()
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -190,7 +188,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(updateMock).toBeCalledWith(id, tag, updateBody, commit, draft, updateName, prerelease)
|
expect(updateMock).toBeCalledWith(id, tag, body, commit, draft, name, prerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -240,16 +238,15 @@ describe("Action", () => {
|
|||||||
return {
|
return {
|
||||||
allowUpdates: allowUpdates,
|
allowUpdates: allowUpdates,
|
||||||
artifacts: inputArtifact,
|
artifacts: inputArtifact,
|
||||||
createdReleaseBody: createBody,
|
body: body,
|
||||||
createdReleaseName: createName,
|
|
||||||
commit: commit,
|
commit: commit,
|
||||||
draft: draft,
|
draft: draft,
|
||||||
|
name: name,
|
||||||
prerelease: prerelease,
|
prerelease: prerelease,
|
||||||
replacesArtifacts: replacesArtifacts,
|
replacesArtifacts: replacesArtifacts,
|
||||||
tag: tag,
|
tag: tag,
|
||||||
token: token,
|
token: token,
|
||||||
updatedReleaseBody: updateBody,
|
readArtifact: () => artifactData
|
||||||
updatedReleaseName: updateName
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const MockUploader = jest.fn<ArtifactUploader, any>(() => {
|
const MockUploader = jest.fn<ArtifactUploader, any>(() => {
|
||||||
@@ -264,4 +261,4 @@ describe("Action", () => {
|
|||||||
|
|
||||||
return new Action(inputs, releases, uploader)
|
return new Action(inputs, releases, uploader)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -30,6 +30,7 @@ describe('ErrorMessage', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('generates message with errors', () => {
|
it('generates message with errors', () => {
|
||||||
|
const resource = "release"
|
||||||
const error = {
|
const error = {
|
||||||
message: 'something bad happened',
|
message: 'something bad happened',
|
||||||
errors: [
|
errors: [
|
||||||
@@ -67,4 +68,4 @@ describe('ErrorMessage', () => {
|
|||||||
const errorMessage = new ErrorMessage(error)
|
const errorMessage = new ErrorMessage(error)
|
||||||
expect(errorMessage.status).toBe(404)
|
expect(errorMessage.status).toBe(404)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -91,12 +91,12 @@ describe('Inputs', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('createdReleaseBody', () => {
|
describe('body', () => {
|
||||||
it('returns input body', () => {
|
it('returns input body', () => {
|
||||||
mockGetInput
|
mockGetInput
|
||||||
.mockReturnValueOnce('false')
|
.mockReturnValueOnce('false')
|
||||||
.mockReturnValueOnce('body')
|
.mockReturnValueOnce('body')
|
||||||
expect(inputs.createdReleaseBody).toBe('body')
|
expect(inputs.body).toBe('body')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns body file contents', () => {
|
it('returns body file contents', () => {
|
||||||
@@ -106,7 +106,7 @@ describe('Inputs', () => {
|
|||||||
.mockReturnValueOnce('a/path')
|
.mockReturnValueOnce('a/path')
|
||||||
mockReadFileSync.mockReturnValue('file')
|
mockReadFileSync.mockReturnValue('file')
|
||||||
|
|
||||||
expect(inputs.createdReleaseBody).toBe('file')
|
expect(inputs.body).toBe('file')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns empty', () => {
|
it('returns empty', () => {
|
||||||
@@ -114,38 +114,14 @@ describe('Inputs', () => {
|
|||||||
.mockReturnValueOnce('false')
|
.mockReturnValueOnce('false')
|
||||||
.mockReturnValueOnce('')
|
.mockReturnValueOnce('')
|
||||||
.mockReturnValueOnce('')
|
.mockReturnValueOnce('')
|
||||||
expect(inputs.createdReleaseBody).toBe('')
|
expect(inputs.body).toBe('')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns undefined when omitted', () => {
|
it('returns null when omitted', () => {
|
||||||
mockGetInput
|
mockGetInput
|
||||||
.mockReturnValueOnce('true')
|
.mockReturnValueOnce('true')
|
||||||
.mockReturnValueOnce('body')
|
.mockReturnValueOnce('body')
|
||||||
expect(inputs.createdReleaseBody).toBeUndefined()
|
expect(inputs.body).toBeUndefined()
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('createdReleaseName', () => {
|
|
||||||
it('returns input name', () => {
|
|
||||||
mockGetInput
|
|
||||||
.mockReturnValueOnce('false')
|
|
||||||
.mockReturnValueOnce('name')
|
|
||||||
expect(inputs.createdReleaseName).toBe('name')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns undefined when omitted', () => {
|
|
||||||
mockGetInput
|
|
||||||
.mockReturnValueOnce('true')
|
|
||||||
.mockReturnValueOnce('name')
|
|
||||||
expect(inputs.createdReleaseBody).toBeUndefined()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns tag', () => {
|
|
||||||
mockGetInput
|
|
||||||
.mockReturnValueOnce('false')
|
|
||||||
.mockReturnValueOnce('')
|
|
||||||
context.ref = 'refs/tags/sha-tag'
|
|
||||||
expect(inputs.createdReleaseName).toBe('sha-tag')
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -160,6 +136,30 @@ describe('Inputs', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('name', () => {
|
||||||
|
it('returns input name', () => {
|
||||||
|
mockGetInput
|
||||||
|
.mockReturnValueOnce('false')
|
||||||
|
.mockReturnValueOnce('name')
|
||||||
|
expect(inputs.name).toBe('name')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('returns null when omitted', () => {
|
||||||
|
mockGetInput
|
||||||
|
.mockReturnValueOnce('true')
|
||||||
|
.mockReturnValueOnce('name')
|
||||||
|
expect(inputs.body).toBeUndefined()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('returns tag', () => {
|
||||||
|
mockGetInput
|
||||||
|
.mockReturnValueOnce('false')
|
||||||
|
.mockReturnValueOnce('')
|
||||||
|
context.ref = 'refs/tags/sha-tag'
|
||||||
|
expect(inputs.name).toBe('sha-tag')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('prerelase', () => {
|
describe('prerelase', () => {
|
||||||
it('returns false', () => {
|
it('returns false', () => {
|
||||||
expect(inputs.prerelease).toBe(false)
|
expect(inputs.prerelease).toBe(false)
|
||||||
@@ -202,87 +202,6 @@ describe('Inputs', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('updatedReleaseBody', () => {
|
|
||||||
it('returns input body', () => {
|
|
||||||
mockGetInput
|
|
||||||
.mockReturnValueOnce('false')
|
|
||||||
.mockReturnValueOnce('false')
|
|
||||||
.mockReturnValueOnce('body')
|
|
||||||
expect(inputs.updatedReleaseBody).toBe('body')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns body file contents', () => {
|
|
||||||
mockGetInput
|
|
||||||
.mockReturnValueOnce('false')
|
|
||||||
.mockReturnValueOnce('false')
|
|
||||||
.mockReturnValueOnce('')
|
|
||||||
.mockReturnValueOnce('a/path')
|
|
||||||
mockReadFileSync.mockReturnValue('file')
|
|
||||||
|
|
||||||
expect(inputs.updatedReleaseBody).toBe('file')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns empty', () => {
|
|
||||||
mockGetInput
|
|
||||||
.mockReturnValueOnce('false')
|
|
||||||
.mockReturnValueOnce('false')
|
|
||||||
.mockReturnValueOnce('')
|
|
||||||
.mockReturnValueOnce('')
|
|
||||||
expect(inputs.updatedReleaseBody).toBe('')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns undefined when omitted', () => {
|
|
||||||
mockGetInput
|
|
||||||
.mockReturnValueOnce('true')
|
|
||||||
.mockReturnValueOnce('false')
|
|
||||||
.mockReturnValueOnce('body')
|
|
||||||
expect(inputs.updatedReleaseBody).toBeUndefined()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns undefined when omitted for update', () => {
|
|
||||||
mockGetInput
|
|
||||||
.mockReturnValueOnce('false')
|
|
||||||
.mockReturnValueOnce('true')
|
|
||||||
.mockReturnValueOnce('body')
|
|
||||||
expect(inputs.updatedReleaseBody).toBeUndefined()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
describe('updatedReleaseName', () => {
|
|
||||||
it('returns input name', () => {
|
|
||||||
mockGetInput
|
|
||||||
.mockReturnValueOnce('false')
|
|
||||||
.mockReturnValueOnce('false')
|
|
||||||
.mockReturnValueOnce('name')
|
|
||||||
expect(inputs.updatedReleaseName).toBe('name')
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns undefined when omitted', () => {
|
|
||||||
mockGetInput
|
|
||||||
.mockReturnValueOnce('true')
|
|
||||||
.mockReturnValueOnce('false')
|
|
||||||
.mockReturnValueOnce('name')
|
|
||||||
expect(inputs.updatedReleaseName).toBeUndefined()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns undefined when omitted for update', () => {
|
|
||||||
mockGetInput
|
|
||||||
.mockReturnValueOnce('false')
|
|
||||||
.mockReturnValueOnce('true')
|
|
||||||
.mockReturnValueOnce('name')
|
|
||||||
expect(inputs.updatedReleaseName).toBeUndefined()
|
|
||||||
})
|
|
||||||
|
|
||||||
it('returns tag', () => {
|
|
||||||
mockGetInput
|
|
||||||
.mockReturnValueOnce('false')
|
|
||||||
.mockReturnValueOnce('false')
|
|
||||||
.mockReturnValueOnce('')
|
|
||||||
context.ref = 'refs/tags/sha-tag'
|
|
||||||
expect(inputs.updatedReleaseName).toBe('sha-tag')
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
function createGlobber(): ArtifactGlobber {
|
function createGlobber(): ArtifactGlobber {
|
||||||
const MockGlobber = jest.fn<ArtifactGlobber, any>(() => {
|
const MockGlobber = jest.fn<ArtifactGlobber, any>(() => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
12
action.yml
12
action.yml
@@ -40,19 +40,11 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
omitBody:
|
omitBody:
|
||||||
description: 'Indicates if the release body should be omitted.'
|
description: 'Indicates if the release body should be omitted. This is primarily useful for preserving the release body during updates.'
|
||||||
required: false
|
|
||||||
default: 'false'
|
|
||||||
omitBodyDuringUpdate:
|
|
||||||
description: 'Indicates if the release body should be omitted during updates. The body will still be applied for newly created releases. This will preserve the existing body during updates.'
|
|
||||||
required: false
|
required: false
|
||||||
default: 'false'
|
default: 'false'
|
||||||
omitName:
|
omitName:
|
||||||
description: 'Indicates if the release name should be omitted.'
|
description: 'Indicates if the release name should be omitted. This is primarily useful for preserving the release name during updates.'
|
||||||
required: false
|
|
||||||
default: 'false'
|
|
||||||
omitNameDuringUpdate:
|
|
||||||
description: 'Indicates if the release name should be omitted during updates. The name will still be applied for newly created releases. This will preserve the existing name during updates.'
|
|
||||||
required: false
|
required: false
|
||||||
default: 'false'
|
default: 'false'
|
||||||
prerelease:
|
prerelease:
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ class Action {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
async updateRelease(id) {
|
async updateRelease(id) {
|
||||||
const response = await this.releases.update(id, this.inputs.tag, this.inputs.updatedReleaseBody, this.inputs.commit, this.inputs.draft, this.inputs.updatedReleaseName, this.inputs.prerelease);
|
const response = await this.releases.update(id, this.inputs.tag, this.inputs.body, this.inputs.commit, this.inputs.draft, this.inputs.name, this.inputs.prerelease);
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
noPublishedRelease(error) {
|
noPublishedRelease(error) {
|
||||||
@@ -61,7 +61,7 @@ class Action {
|
|||||||
return (_a = draftRelease) === null || _a === void 0 ? void 0 : _a.id;
|
return (_a = draftRelease) === null || _a === void 0 ? void 0 : _a.id;
|
||||||
}
|
}
|
||||||
async createRelease() {
|
async createRelease() {
|
||||||
const response = await this.releases.create(this.inputs.tag, this.inputs.createdReleaseBody, this.inputs.commit, this.inputs.draft, this.inputs.createdReleaseName, this.inputs.prerelease);
|
const response = await this.releases.create(this.inputs.tag, this.inputs.body, this.inputs.commit, this.inputs.draft, this.inputs.name, this.inputs.prerelease);
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,15 +33,9 @@ class CoreInputs {
|
|||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
get createdReleaseBody() {
|
|
||||||
if (CoreInputs.omitBody)
|
|
||||||
return undefined;
|
|
||||||
return this.body;
|
|
||||||
}
|
|
||||||
static get omitBody() {
|
|
||||||
return core.getInput('omitBody') == 'true';
|
|
||||||
}
|
|
||||||
get body() {
|
get body() {
|
||||||
|
if (CoreInputs.omitBody())
|
||||||
|
return undefined;
|
||||||
const body = core.getInput('body');
|
const body = core.getInput('body');
|
||||||
if (body) {
|
if (body) {
|
||||||
return body;
|
return body;
|
||||||
@@ -52,27 +46,27 @@ class CoreInputs {
|
|||||||
}
|
}
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
static omitBody() {
|
||||||
|
return core.getInput('omitBody') == 'true';
|
||||||
|
}
|
||||||
get commit() {
|
get commit() {
|
||||||
return core.getInput('commit');
|
return core.getInput('commit');
|
||||||
}
|
}
|
||||||
get createdReleaseName() {
|
get draft() {
|
||||||
if (CoreInputs.omitName)
|
const draft = core.getInput('draft');
|
||||||
return undefined;
|
return draft == 'true';
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
static get omitName() {
|
|
||||||
return core.getInput('omitName') == 'true';
|
|
||||||
}
|
}
|
||||||
get name() {
|
get name() {
|
||||||
|
if (CoreInputs.omitName())
|
||||||
|
return undefined;
|
||||||
const name = core.getInput('name');
|
const name = core.getInput('name');
|
||||||
if (name) {
|
if (name) {
|
||||||
return name;
|
return name;
|
||||||
}
|
}
|
||||||
return this.tag;
|
return this.tag;
|
||||||
}
|
}
|
||||||
get draft() {
|
static omitName() {
|
||||||
const draft = core.getInput('draft');
|
return core.getInput('omitName') == 'true';
|
||||||
return draft == 'true';
|
|
||||||
}
|
}
|
||||||
get prerelease() {
|
get prerelease() {
|
||||||
const preRelease = core.getInput('prerelease');
|
const preRelease = core.getInput('prerelease');
|
||||||
@@ -97,22 +91,6 @@ class CoreInputs {
|
|||||||
get token() {
|
get token() {
|
||||||
return core.getInput('token', { required: true });
|
return core.getInput('token', { required: true });
|
||||||
}
|
}
|
||||||
get updatedReleaseBody() {
|
|
||||||
if (CoreInputs.omitBody || CoreInputs.omitBodyDuringUpdate)
|
|
||||||
return undefined;
|
|
||||||
return this.body;
|
|
||||||
}
|
|
||||||
static get omitBodyDuringUpdate() {
|
|
||||||
return core.getInput('omitBodyDuringUpdate') == 'true';
|
|
||||||
}
|
|
||||||
get updatedReleaseName() {
|
|
||||||
if (CoreInputs.omitName || CoreInputs.omitNameDuringUpdate)
|
|
||||||
return undefined;
|
|
||||||
return this.name;
|
|
||||||
}
|
|
||||||
static get omitNameDuringUpdate() {
|
|
||||||
return core.getInput('omitNameDuringUpdate') == 'true';
|
|
||||||
}
|
|
||||||
stringFromFile(path) {
|
stringFromFile(path) {
|
||||||
return fs_1.readFileSync(path, 'utf-8');
|
return fs_1.readFileSync(path, 'utf-8');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,10 +47,10 @@ export class Action {
|
|||||||
const response = await this.releases.update(
|
const response = await this.releases.update(
|
||||||
id,
|
id,
|
||||||
this.inputs.tag,
|
this.inputs.tag,
|
||||||
this.inputs.updatedReleaseBody,
|
this.inputs.body,
|
||||||
this.inputs.commit,
|
this.inputs.commit,
|
||||||
this.inputs.draft,
|
this.inputs.draft,
|
||||||
this.inputs.updatedReleaseName,
|
this.inputs.name,
|
||||||
this.inputs.prerelease
|
this.inputs.prerelease
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -83,13 +83,13 @@ export class Action {
|
|||||||
private async createRelease(): Promise<ReposCreateReleaseResponse> {
|
private async createRelease(): Promise<ReposCreateReleaseResponse> {
|
||||||
const response = await this.releases.create(
|
const response = await this.releases.create(
|
||||||
this.inputs.tag,
|
this.inputs.tag,
|
||||||
this.inputs.createdReleaseBody,
|
this.inputs.body,
|
||||||
this.inputs.commit,
|
this.inputs.commit,
|
||||||
this.inputs.draft,
|
this.inputs.draft,
|
||||||
this.inputs.createdReleaseName,
|
this.inputs.name,
|
||||||
this.inputs.prerelease
|
this.inputs.prerelease
|
||||||
)
|
)
|
||||||
|
|
||||||
return response.data
|
return response.data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -7,16 +7,14 @@ import {Artifact} from './Artifact';
|
|||||||
export interface Inputs {
|
export interface Inputs {
|
||||||
readonly allowUpdates: boolean
|
readonly allowUpdates: boolean
|
||||||
readonly artifacts: Artifact[]
|
readonly artifacts: Artifact[]
|
||||||
|
readonly body?: string
|
||||||
readonly commit: string
|
readonly commit: string
|
||||||
readonly createdReleaseBody?: string
|
|
||||||
readonly createdReleaseName?: string
|
|
||||||
readonly draft: boolean
|
readonly draft: boolean
|
||||||
|
readonly name?: string
|
||||||
readonly prerelease: boolean
|
readonly prerelease: boolean
|
||||||
readonly replacesArtifacts: boolean
|
readonly replacesArtifacts: boolean
|
||||||
readonly tag: string
|
readonly tag: string
|
||||||
readonly token: string
|
readonly token: string
|
||||||
readonly updatedReleaseBody?: string
|
|
||||||
readonly updatedReleaseName?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CoreInputs implements Inputs {
|
export class CoreInputs implements Inputs {
|
||||||
@@ -49,16 +47,9 @@ export class CoreInputs implements Inputs {
|
|||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
get createdReleaseBody(): string | undefined {
|
get body(): string | undefined {
|
||||||
if (CoreInputs.omitBody) return undefined
|
if (CoreInputs.omitBody()) return undefined
|
||||||
return this.body
|
|
||||||
}
|
|
||||||
|
|
||||||
private static get omitBody(): boolean {
|
|
||||||
return core.getInput('omitBody') == 'true'
|
|
||||||
}
|
|
||||||
|
|
||||||
private get body() : string | undefined {
|
|
||||||
const body = core.getInput('body')
|
const body = core.getInput('body')
|
||||||
if (body) {
|
if (body) {
|
||||||
return body
|
return body
|
||||||
@@ -72,20 +63,22 @@ export class CoreInputs implements Inputs {
|
|||||||
return ''
|
return ''
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static omitBody(): boolean {
|
||||||
|
return core.getInput('omitBody') == 'true'
|
||||||
|
}
|
||||||
|
|
||||||
get commit(): string {
|
get commit(): string {
|
||||||
return core.getInput('commit')
|
return core.getInput('commit')
|
||||||
}
|
}
|
||||||
|
|
||||||
get createdReleaseName(): string | undefined {
|
get draft(): boolean {
|
||||||
if (CoreInputs.omitName) return undefined
|
const draft = core.getInput('draft')
|
||||||
return this.name
|
return draft == 'true'
|
||||||
}
|
}
|
||||||
|
|
||||||
private static get omitName(): boolean {
|
get name(): string | undefined {
|
||||||
return core.getInput('omitName') == 'true'
|
if (CoreInputs.omitName()) return undefined
|
||||||
}
|
|
||||||
|
|
||||||
private get name(): string | undefined {
|
|
||||||
const name = core.getInput('name')
|
const name = core.getInput('name')
|
||||||
if (name) {
|
if (name) {
|
||||||
return name
|
return name
|
||||||
@@ -94,9 +87,8 @@ export class CoreInputs implements Inputs {
|
|||||||
return this.tag
|
return this.tag
|
||||||
}
|
}
|
||||||
|
|
||||||
get draft(): boolean {
|
private static omitName(): boolean {
|
||||||
const draft = core.getInput('draft')
|
return core.getInput('omitName') == 'true'
|
||||||
return draft == 'true'
|
|
||||||
}
|
}
|
||||||
|
|
||||||
get prerelease(): boolean {
|
get prerelease(): boolean {
|
||||||
@@ -128,24 +120,6 @@ export class CoreInputs implements Inputs {
|
|||||||
return core.getInput('token', {required: true})
|
return core.getInput('token', {required: true})
|
||||||
}
|
}
|
||||||
|
|
||||||
get updatedReleaseBody(): string | undefined {
|
|
||||||
if (CoreInputs.omitBody || CoreInputs.omitBodyDuringUpdate) return undefined
|
|
||||||
return this.body
|
|
||||||
}
|
|
||||||
|
|
||||||
private static get omitBodyDuringUpdate(): boolean {
|
|
||||||
return core.getInput('omitBodyDuringUpdate') == 'true'
|
|
||||||
}
|
|
||||||
|
|
||||||
get updatedReleaseName(): string | undefined {
|
|
||||||
if (CoreInputs.omitName || CoreInputs.omitNameDuringUpdate) return undefined
|
|
||||||
return this.name
|
|
||||||
}
|
|
||||||
|
|
||||||
private static get omitNameDuringUpdate(): boolean {
|
|
||||||
return core.getInput('omitNameDuringUpdate') == 'true'
|
|
||||||
}
|
|
||||||
|
|
||||||
stringFromFile(path: string): string {
|
stringFromFile(path: string): string {
|
||||||
return readFileSync(path, 'utf-8')
|
return readFileSync(path, 'utf-8')
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user