Skip to content

Commit

Permalink
Fixes #185 Add omitDraftDuringUpdate input (#190)
Browse files Browse the repository at this point in the history
  • Loading branch information
ncipollo authored Mar 31, 2022
1 parent c309084 commit ffcd2d4
Show file tree
Hide file tree
Showing 13 changed files with 203 additions and 137 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,6 @@ fabric.properties
.idea/**/markdown-navigator/

# End of https://www.gitignore.io/api/webstorm

# Coverage
coverage
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ This action will create a GitHub release and optionally upload an artifact to it
| name | An optional name for the release. If this is omitted the tag will be used. | false | "" |
| omitBody | Indicates if the release body should be omitted. | false | false |
| 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. | false | false |
| omitDraftDuringUpdate | Indicates if the draft flag should be omitted during updates. The draft flag will still be applied for newly created releases. This will preserve the existing draft state during updates. | false | false |
| omitName | Indicates if the release name should be omitted. | false | false |
| 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. | false | false |
| omitPrereleaseDuringUpdate | Indicates if the prerelease flag should be omitted during updates. The prerelease flag will still be applied for newly created releases. This will preserve the existing prerelease state during updates. | false | false |
Expand Down
28 changes: 15 additions & 13 deletions __tests__/Action.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,21 @@ const artifacts = [
]

const createBody = 'createBody'
const createDraft = true
const createName = 'createName'
const commit = 'commit'
const discussionCategory = 'discussionCategory'
const draft = true
const generateReleaseNotes = true
const id = 100
const createPrerelease = true
const updatePrerelease = false
const releaseId = 101
const replacesArtifacts = true
const tag = 'tag'
const token = 'token'
const updateBody = 'updateBody'
const updateDraft = false
const updateName = 'updateName'
const updatePrerelease = false
const url = 'http://api.example.com'

describe("Action", () => {
Expand All @@ -56,7 +57,7 @@ describe("Action", () => {
createBody,
commit,
discussionCategory,
draft,
createDraft,
generateReleaseNotes,
createName,
createPrerelease)
Expand All @@ -76,7 +77,7 @@ describe("Action", () => {
createBody,
commit,
discussionCategory,
draft,
createDraft,
generateReleaseNotes,
createName,
createPrerelease)
Expand All @@ -101,7 +102,7 @@ describe("Action", () => {
createBody,
commit,
discussionCategory,
draft,
createDraft,
generateReleaseNotes,
createName,
createPrerelease
Expand All @@ -121,7 +122,7 @@ describe("Action", () => {
createBody,
commit,
discussionCategory,
draft,
createDraft,
generateReleaseNotes,
createName,
createPrerelease
Expand Down Expand Up @@ -164,7 +165,7 @@ describe("Action", () => {
createBody,
commit,
discussionCategory,
draft,
createDraft,
generateReleaseNotes,
createName,
createPrerelease
Expand Down Expand Up @@ -215,7 +216,7 @@ describe("Action", () => {
updateBody,
commit,
discussionCategory,
draft,
updateDraft,
updateName,
updatePrerelease
)
Expand All @@ -239,7 +240,7 @@ describe("Action", () => {
createBody,
commit,
discussionCategory,
draft,
createDraft,
generateReleaseNotes,
createName,
createPrerelease
Expand All @@ -266,7 +267,7 @@ describe("Action", () => {
updateBody,
commit,
discussionCategory,
draft,
updateDraft,
updateName,
updatePrerelease
)
Expand All @@ -285,7 +286,7 @@ describe("Action", () => {
updateBody,
commit,
discussionCategory,
draft,
updateDraft,
updateName,
updatePrerelease
)
Expand All @@ -304,7 +305,7 @@ describe("Action", () => {
updateBody,
commit,
discussionCategory,
draft,
updateDraft,
updateName,
updatePrerelease
)
Expand Down Expand Up @@ -362,11 +363,11 @@ describe("Action", () => {
allowUpdates: allowUpdates,
artifactErrorsFailBuild: true,
artifacts: inputArtifact,
createdDraft: createDraft,
createdReleaseBody: createBody,
createdReleaseName: createName,
commit: commit,
discussionCategory: discussionCategory,
draft: draft,
generateReleaseNotes: true,
owner: "owner",
createdPrerelease: createPrerelease,
Expand All @@ -375,6 +376,7 @@ describe("Action", () => {
repo: "repo",
tag: tag,
token: token,
updatedDraft: updateDraft,
updatedReleaseBody: updateBody,
updatedReleaseName: updateName,
updatedPrerelease: updatePrerelease
Expand Down
53 changes: 40 additions & 13 deletions __tests__/Inputs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe('Inputs', () => {

it('returns input.artifacts with default contentType', () => {
mockGetInput.mockReturnValueOnce('art1')
.mockReturnValueOnce('raw')
.mockReturnValueOnce('')
.mockReturnValueOnce('false')

expect(inputs.artifacts).toEqual(artifacts)
Expand All @@ -128,6 +128,17 @@ describe('Inputs', () => {
})
})

describe('createdDraft', () => {
it('returns false', () => {
expect(inputs.createdDraft).toBe(false)
})

it('returns true', () => {
mockGetInput.mockReturnValue('true')
expect(inputs.createdDraft).toBe(true)
})
})

describe('createdReleaseBody', () => {
it('returns input body', () => {
mockGetInput
Expand Down Expand Up @@ -174,7 +185,7 @@ describe('Inputs', () => {
mockGetInput
.mockReturnValueOnce('true')
.mockReturnValueOnce('name')
expect(inputs.createdReleaseBody).toBeUndefined()
expect(inputs.createdReleaseName).toBeUndefined()
})

it('returns tag', () => {
Expand All @@ -198,17 +209,6 @@ describe('Inputs', () => {
})
})

describe('draft', () => {
it('returns false', () => {
expect(inputs.draft).toBe(false)
})

it('returns true', () => {
mockGetInput.mockReturnValue('true')
expect(inputs.draft).toBe(true)
})
})

describe('generateReleaseNotes', () => {
it('returns returns true', function () {
mockGetInput.mockReturnValue("true")
Expand Down Expand Up @@ -299,6 +299,33 @@ describe('Inputs', () => {
})
})

describe('updatedDraft', () => {
it('returns false', () => {
expect(inputs.updatedDraft).toBe(false)
})

it('returns true', () => {
mockGetInput
.mockReturnValueOnce('false')
.mockReturnValue('true')
expect(inputs.updatedDraft).toBe(true)
})

it('returns true when omitted is blank', () => {
mockGetInput
.mockReturnValueOnce('')
.mockReturnValue('true')
expect(inputs.updatedDraft).toBe(true)
})

it('returns undefined when omitted for update', () => {
mockGetInput
.mockReturnValueOnce('true')
.mockReturnValueOnce('true')
expect(inputs.updatedDraft).toBeUndefined()
})
})

describe('updatedReleaseBody', () => {
it('returns input body', () => {
mockGetInput
Expand Down
3 changes: 2 additions & 1 deletion __tests__/Integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ describe.skip('Integration Test', () => {
allowUpdates: true,
artifactErrorsFailBuild: false,
artifacts: artifacts(),
createdDraft: false,
createdReleaseBody: "This release was generated by release-action's integration test",
createdReleaseName: "Releases Action Integration Test",
commit: undefined,
discussionCategory: 'Release',
draft: false,
generateReleaseNotes: true,
owner: "ncipollo",
createdPrerelease: false,
Expand All @@ -54,6 +54,7 @@ describe.skip('Integration Test', () => {
repo: "actions-playground",
tag: "release-action-test",
token: getToken(),
updatedDraft: false,
updatedReleaseBody: "This release was generated by release-action's integration test",
updatedReleaseName: "Releases Action Integration Test",
updatedPrerelease: false
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ inputs:
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
default: 'false'
omitDraftDuringUpdate:
description: 'Indicates if the draft flag should be omitted during updates. The draft flag will still be applied for newly created releases. This will preserve the existing draft state during updates.'
required: false
default: 'false'
omitName:
description: 'Indicates if the release name should be omitted.'
required: false
Expand Down
Loading

0 comments on commit ffcd2d4

Please sign in to comment.