Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
74624afcd2 | ||
|
|
d66ba5159b | ||
|
|
6f236bd2ff | ||
|
|
05b0499270 |
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,7 +13,9 @@ 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,17 +16,19 @@ 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 body = 'body'
|
const createBody = 'createBody'
|
||||||
|
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", () => {
|
||||||
@@ -43,7 +45,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, body, commit, draft, name, prerelease)
|
expect(createMock).toBeCalledWith(tag, createBody, commit, draft, createName, prerelease)
|
||||||
expect(uploadMock).not.toBeCalled()
|
expect(uploadMock).not.toBeCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -54,7 +56,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, body, commit, draft, name, prerelease)
|
expect(createMock).toBeCalledWith(tag, createBody, commit, draft, createName, prerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -70,7 +72,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, body, commit, draft, name, prerelease)
|
expect(createMock).toBeCalledWith(tag, createBody, commit, draft, createName, prerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -80,7 +82,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, body, commit, draft, name, prerelease)
|
expect(createMock).toBeCalledWith(tag, createBody, commit, draft, createName, prerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -95,7 +97,7 @@ describe("Action", () => {
|
|||||||
expect(error).toEqual("error")
|
expect(error).toEqual("error")
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, body, commit, draft, name, prerelease)
|
expect(createMock).toBeCalledWith(tag, createBody, commit, draft, createName, prerelease)
|
||||||
expect(uploadMock).not.toBeCalled()
|
expect(uploadMock).not.toBeCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -136,7 +138,7 @@ describe("Action", () => {
|
|||||||
expect(error).toEqual("error")
|
expect(error).toEqual("error")
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(updateMock).toBeCalledWith(id, tag, body, commit, draft, name, prerelease)
|
expect(updateMock).toBeCalledWith(id, tag, updateBody, commit, draft, updateName, prerelease)
|
||||||
expect(uploadMock).not.toBeCalled()
|
expect(uploadMock).not.toBeCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -151,7 +153,7 @@ describe("Action", () => {
|
|||||||
expect(error).toEqual("error")
|
expect(error).toEqual("error")
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, body, commit, draft, name, prerelease)
|
expect(createMock).toBeCalledWith(tag, createBody, commit, draft, createName, prerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -168,7 +170,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(updateMock).toBeCalledWith(id, tag, body, commit, draft, name, prerelease)
|
expect(updateMock).toBeCalledWith(id, tag, updateBody, commit, draft, updateName, prerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -178,7 +180,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(updateMock).toBeCalledWith(id, tag, body, commit, draft, name, prerelease)
|
expect(updateMock).toBeCalledWith(id, tag, updateBody, commit, draft, updateName, prerelease)
|
||||||
expect(uploadMock).not.toBeCalled()
|
expect(uploadMock).not.toBeCalled()
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -188,7 +190,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(updateMock).toBeCalledWith(id, tag, body, commit, draft, name, prerelease)
|
expect(updateMock).toBeCalledWith(id, tag, updateBody, commit, draft, updateName, prerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -238,15 +240,16 @@ describe("Action", () => {
|
|||||||
return {
|
return {
|
||||||
allowUpdates: allowUpdates,
|
allowUpdates: allowUpdates,
|
||||||
artifacts: inputArtifact,
|
artifacts: inputArtifact,
|
||||||
body: body,
|
createdReleaseBody: createBody,
|
||||||
|
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,
|
||||||
readArtifact: () => artifactData
|
updatedReleaseBody: updateBody,
|
||||||
|
updatedReleaseName: updateName
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const MockUploader = jest.fn<ArtifactUploader, any>(() => {
|
const MockUploader = jest.fn<ArtifactUploader, any>(() => {
|
||||||
@@ -261,4 +264,4 @@ describe("Action", () => {
|
|||||||
|
|
||||||
return new Action(inputs, releases, uploader)
|
return new Action(inputs, releases, uploader)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -30,7 +30,6 @@ 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: [
|
||||||
@@ -68,4 +67,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('body', () => {
|
describe('createdReleaseBody', () => {
|
||||||
it('returns input body', () => {
|
it('returns input body', () => {
|
||||||
mockGetInput
|
mockGetInput
|
||||||
.mockReturnValueOnce('false')
|
.mockReturnValueOnce('false')
|
||||||
.mockReturnValueOnce('body')
|
.mockReturnValueOnce('body')
|
||||||
expect(inputs.body).toBe('body')
|
expect(inputs.createdReleaseBody).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.body).toBe('file')
|
expect(inputs.createdReleaseBody).toBe('file')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns empty', () => {
|
it('returns empty', () => {
|
||||||
@@ -114,14 +114,38 @@ describe('Inputs', () => {
|
|||||||
.mockReturnValueOnce('false')
|
.mockReturnValueOnce('false')
|
||||||
.mockReturnValueOnce('')
|
.mockReturnValueOnce('')
|
||||||
.mockReturnValueOnce('')
|
.mockReturnValueOnce('')
|
||||||
expect(inputs.body).toBe('')
|
expect(inputs.createdReleaseBody).toBe('')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns null when omitted', () => {
|
it('returns undefined when omitted', () => {
|
||||||
mockGetInput
|
mockGetInput
|
||||||
.mockReturnValueOnce('true')
|
.mockReturnValueOnce('true')
|
||||||
.mockReturnValueOnce('body')
|
.mockReturnValueOnce('body')
|
||||||
expect(inputs.body).toBeUndefined()
|
expect(inputs.createdReleaseBody).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')
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -136,30 +160,6 @@ 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,6 +202,87 @@ 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,11 +40,19 @@ inputs:
|
|||||||
required: false
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
omitBody:
|
omitBody:
|
||||||
description: 'Indicates if the release body should be omitted. This is primarily useful for preserving the release body during updates.'
|
description: 'Indicates if the release body should be omitted.'
|
||||||
|
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. This is primarily useful for preserving the release name during updates.'
|
description: 'Indicates if the release name should be omitted.'
|
||||||
|
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.body, this.inputs.commit, this.inputs.draft, this.inputs.name, this.inputs.prerelease);
|
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);
|
||||||
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.body, this.inputs.commit, this.inputs.draft, this.inputs.name, this.inputs.prerelease);
|
const response = await this.releases.create(this.inputs.tag, this.inputs.createdReleaseBody, this.inputs.commit, this.inputs.draft, this.inputs.createdReleaseName, this.inputs.prerelease);
|
||||||
return response.data;
|
return response.data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,9 +33,15 @@ class CoreInputs {
|
|||||||
}
|
}
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
get body() {
|
get createdReleaseBody() {
|
||||||
if (CoreInputs.omitBody())
|
if (CoreInputs.omitBody)
|
||||||
return undefined;
|
return undefined;
|
||||||
|
return this.body;
|
||||||
|
}
|
||||||
|
static get omitBody() {
|
||||||
|
return core.getInput('omitBody') == 'true';
|
||||||
|
}
|
||||||
|
get body() {
|
||||||
const body = core.getInput('body');
|
const body = core.getInput('body');
|
||||||
if (body) {
|
if (body) {
|
||||||
return body;
|
return body;
|
||||||
@@ -46,27 +52,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 draft() {
|
get createdReleaseName() {
|
||||||
const draft = core.getInput('draft');
|
if (CoreInputs.omitName)
|
||||||
return draft == 'true';
|
return undefined;
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
static omitName() {
|
get draft() {
|
||||||
return core.getInput('omitName') == 'true';
|
const draft = core.getInput('draft');
|
||||||
|
return draft == 'true';
|
||||||
}
|
}
|
||||||
get prerelease() {
|
get prerelease() {
|
||||||
const preRelease = core.getInput('prerelease');
|
const preRelease = core.getInput('prerelease');
|
||||||
@@ -91,6 +97,22 @@ 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.body,
|
this.inputs.updatedReleaseBody,
|
||||||
this.inputs.commit,
|
this.inputs.commit,
|
||||||
this.inputs.draft,
|
this.inputs.draft,
|
||||||
this.inputs.name,
|
this.inputs.updatedReleaseName,
|
||||||
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.body,
|
this.inputs.createdReleaseBody,
|
||||||
this.inputs.commit,
|
this.inputs.commit,
|
||||||
this.inputs.draft,
|
this.inputs.draft,
|
||||||
this.inputs.name,
|
this.inputs.createdReleaseName,
|
||||||
this.inputs.prerelease
|
this.inputs.prerelease
|
||||||
)
|
)
|
||||||
|
|
||||||
return response.data
|
return response.data
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,14 +7,16 @@ 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 {
|
||||||
@@ -47,9 +49,16 @@ export class CoreInputs implements Inputs {
|
|||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
get body(): string | undefined {
|
get createdReleaseBody(): 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
|
||||||
@@ -63,22 +72,20 @@ 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 draft(): boolean {
|
get createdReleaseName(): string | undefined {
|
||||||
const draft = core.getInput('draft')
|
if (CoreInputs.omitName) return undefined
|
||||||
return draft == 'true'
|
return this.name
|
||||||
}
|
}
|
||||||
|
|
||||||
get name(): string | undefined {
|
private static get omitName(): boolean {
|
||||||
if (CoreInputs.omitName()) return undefined
|
return core.getInput('omitName') == 'true'
|
||||||
|
}
|
||||||
|
|
||||||
|
private get name(): string | undefined {
|
||||||
const name = core.getInput('name')
|
const name = core.getInput('name')
|
||||||
if (name) {
|
if (name) {
|
||||||
return name
|
return name
|
||||||
@@ -87,8 +94,9 @@ export class CoreInputs implements Inputs {
|
|||||||
return this.tag
|
return this.tag
|
||||||
}
|
}
|
||||||
|
|
||||||
private static omitName(): boolean {
|
get draft(): boolean {
|
||||||
return core.getInput('omitName') == 'true'
|
const draft = core.getInput('draft')
|
||||||
|
return draft == 'true'
|
||||||
}
|
}
|
||||||
|
|
||||||
get prerelease(): boolean {
|
get prerelease(): boolean {
|
||||||
@@ -120,6 +128,24 @@ 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