Fixes #15 Add omitBody and omitName
This commit is contained in:
@@ -12,6 +12,8 @@ This action will create a github release and optionally upload an artifact to it
|
|||||||
- **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.
|
||||||
- **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.
|
||||||
|
- **omitName**: Indicates if the release name should be omitted. This is primarily useful for preserving the release 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).
|
||||||
|
|||||||
@@ -93,20 +93,36 @@ describe('Inputs', () => {
|
|||||||
|
|
||||||
describe('body', () => {
|
describe('body', () => {
|
||||||
it('returns input body', () => {
|
it('returns input body', () => {
|
||||||
mockGetInput.mockReturnValue('body')
|
mockGetInput
|
||||||
|
.mockReturnValueOnce('false')
|
||||||
|
.mockReturnValueOnce('body')
|
||||||
expect(inputs.body).toBe('body')
|
expect(inputs.body).toBe('body')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns body file contents', () => {
|
it('returns body file contents', () => {
|
||||||
mockGetInput.mockReturnValueOnce('').mockReturnValueOnce('a/path')
|
mockGetInput
|
||||||
|
.mockReturnValueOnce('false')
|
||||||
|
.mockReturnValueOnce('')
|
||||||
|
.mockReturnValueOnce('a/path')
|
||||||
mockReadFileSync.mockReturnValue('file')
|
mockReadFileSync.mockReturnValue('file')
|
||||||
|
|
||||||
expect(inputs.body).toBe('file')
|
expect(inputs.body).toBe('file')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns empty', () => {
|
it('returns empty', () => {
|
||||||
|
mockGetInput
|
||||||
|
.mockReturnValueOnce('false')
|
||||||
|
.mockReturnValueOnce('')
|
||||||
|
.mockReturnValueOnce('')
|
||||||
expect(inputs.body).toBe('')
|
expect(inputs.body).toBe('')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('returns null when omitted', () => {
|
||||||
|
mockGetInput
|
||||||
|
.mockReturnValueOnce('true')
|
||||||
|
.mockReturnValueOnce('body')
|
||||||
|
expect(inputs.body).toBeUndefined()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('draft', () => {
|
describe('draft', () => {
|
||||||
@@ -122,12 +138,23 @@ describe('Inputs', () => {
|
|||||||
|
|
||||||
describe('name', () => {
|
describe('name', () => {
|
||||||
it('returns input name', () => {
|
it('returns input name', () => {
|
||||||
mockGetInput.mockReturnValue('name')
|
mockGetInput
|
||||||
|
.mockReturnValueOnce('false')
|
||||||
|
.mockReturnValueOnce('name')
|
||||||
expect(inputs.name).toBe('name')
|
expect(inputs.name).toBe('name')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
it('returns null when omitted', () => {
|
||||||
|
mockGetInput
|
||||||
|
.mockReturnValueOnce('true')
|
||||||
|
.mockReturnValueOnce('name')
|
||||||
|
expect(inputs.body).toBeUndefined()
|
||||||
|
})
|
||||||
|
|
||||||
it('returns tag', () => {
|
it('returns tag', () => {
|
||||||
mockGetInput.mockReturnValue('')
|
mockGetInput
|
||||||
|
.mockReturnValueOnce('false')
|
||||||
|
.mockReturnValueOnce('')
|
||||||
context.ref = 'refs/tags/sha-tag'
|
context.ref = 'refs/tags/sha-tag'
|
||||||
expect(inputs.name).toBe('sha-tag')
|
expect(inputs.name).toBe('sha-tag')
|
||||||
})
|
})
|
||||||
|
|||||||
20
action.yml
20
action.yml
@@ -4,40 +4,60 @@ author: 'Nick Cipollo'
|
|||||||
inputs:
|
inputs:
|
||||||
allowUpdates:
|
allowUpdates:
|
||||||
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
|
||||||
default: ''
|
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)'
|
||||||
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
artifacts:
|
artifacts:
|
||||||
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)'
|
||||||
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
artifactContentType:
|
artifactContentType:
|
||||||
description: 'The content type of the artifact. Defaults to raw'
|
description: 'The content type of the artifact. Defaults to raw'
|
||||||
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
body:
|
body:
|
||||||
description: 'An optional body for the release.'
|
description: 'An optional body for the release.'
|
||||||
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
bodyFile:
|
bodyFile:
|
||||||
description: 'An optional body file for the release. This should be the path to the file'
|
description: 'An optional body file for the release. This should be the path to the file'
|
||||||
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
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
|
||||||
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."
|
||||||
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
name:
|
name:
|
||||||
description: 'An optional name for the release. If this is omitted the tag will be used.'
|
description: 'An optional name for the release. If this is omitted the tag will be used.'
|
||||||
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
|
omitBody:
|
||||||
|
description: 'Indicates if the release body should be omitted. This is primarily useful for preserving the release body during updates.'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
omitName:
|
||||||
|
description: 'Indicates if the release name should be omitted. This is primarily useful for preserving the release name during updates.'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
prerelease:
|
prerelease:
|
||||||
description: "Optionally marks this release as prerelease. Set to true to enable."
|
description: "Optionally marks this release as prerelease. Set to true to enable."
|
||||||
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
replacesArtifacts:
|
replacesArtifacts:
|
||||||
description: "Indicates if existing release artifacts should be replaced. Defaults to true."
|
description: "Indicates if existing release artifacts should be replaced. Defaults to true."
|
||||||
|
required: false
|
||||||
default: 'true'
|
default: 'true'
|
||||||
tag:
|
tag:
|
||||||
description: 'An optional tag for the release. If this is omitted the git ref will be used (if it is a tag).'
|
description: 'An optional tag for the release. If this is omitted the git ref will be used (if it is a tag).'
|
||||||
|
required: false
|
||||||
default: ''
|
default: ''
|
||||||
token:
|
token:
|
||||||
description: 'The Github token.'
|
description: 'The Github token.'
|
||||||
|
|||||||
@@ -7,10 +7,10 @@ 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 body?: string
|
||||||
readonly commit: string
|
readonly commit: string
|
||||||
readonly draft: boolean
|
readonly draft: boolean
|
||||||
readonly name: string
|
readonly name?: string
|
||||||
readonly prerelease: boolean
|
readonly prerelease: boolean
|
||||||
readonly replacesArtifacts: boolean
|
readonly replacesArtifacts: boolean
|
||||||
readonly tag: string
|
readonly tag: string
|
||||||
@@ -47,7 +47,9 @@ export class CoreInputs implements Inputs {
|
|||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
|
|
||||||
get body(): string {
|
get body(): string | undefined {
|
||||||
|
if (CoreInputs.omitBody()) return undefined
|
||||||
|
|
||||||
const body = core.getInput('body')
|
const body = core.getInput('body')
|
||||||
if (body) {
|
if (body) {
|
||||||
return body
|
return body
|
||||||
@@ -61,6 +63,10 @@ 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')
|
||||||
}
|
}
|
||||||
@@ -70,7 +76,9 @@ export class CoreInputs implements Inputs {
|
|||||||
return draft == 'true'
|
return draft == 'true'
|
||||||
}
|
}
|
||||||
|
|
||||||
get name(): string {
|
get name(): string | undefined {
|
||||||
|
if (CoreInputs.omitName()) return undefined
|
||||||
|
|
||||||
const name = core.getInput('name')
|
const name = core.getInput('name')
|
||||||
if (name) {
|
if (name) {
|
||||||
return name
|
return name
|
||||||
@@ -79,6 +87,10 @@ export class CoreInputs implements Inputs {
|
|||||||
return this.tag
|
return this.tag
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static omitName(): boolean {
|
||||||
|
return core.getInput('omitName') == 'true'
|
||||||
|
}
|
||||||
|
|
||||||
get prerelease(): boolean {
|
get prerelease(): boolean {
|
||||||
const preRelease = core.getInput('prerelease')
|
const preRelease = core.getInput('prerelease')
|
||||||
return preRelease == 'true'
|
return preRelease == 'true'
|
||||||
|
|||||||
Reference in New Issue
Block a user