Skip to content

Commit

Permalink
Add publish input (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucacome committed Apr 28, 2023
1 parent efc52f6 commit f7c1b2e
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ jobs:
| `notes-header` | `string` | The header to use for the release notes. |
| `notes-footer` | `string` | The footer to use for the release notes. |
| `variables` | `list` | A list of variables to use in the header and footer. |
| `publish` | `boolean` | Whether to publish the release. (default `false`) |

## Outputs

Expand Down
2 changes: 2 additions & 0 deletions __tests__/notes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ describe('generateReleaseNotes', () => {
footer: 'footer with version {{version}} and baz {{baz}}',
variables: ['foo=bar', 'baz=qux'],
collapseAfter: 0,
publish: false,
}
const releaseData = {
releases: [],
Expand Down Expand Up @@ -117,6 +118,7 @@ describe('generateReleaseNotes', () => {
footer: 'footer with version {{version}}',
variables: [],
collapseAfter: 3,
publish: false,
}

const releaseData = {
Expand Down
1 change: 1 addition & 0 deletions __tests__/release.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ describe('createOrUpdateRelease', () => {
footer: 'footer',
variables: [],
collapseAfter: 0,
publish: false,
}
beforeEach(() => {
jest.clearAllMocks()
Expand Down
1 change: 1 addition & 0 deletions __tests__/version.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ describe('getVersionIncrease', () => {
footer: '',
variables: [],
collapseAfter: 0,
publish: false,
}

const releaseData = {
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ inputs:
description: 'Number of lines required for the section to be collapsed'
default: '0'
required: false
publish:
description: 'Whether to publish the release'
default: 'false'
required: false
outputs:
version:
description: 'The version of the release'
Expand Down
3 changes: 2 additions & 1 deletion dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export interface Inputs {
footer: string
variables: string[]
collapseAfter: number
publish: boolean
}

export function getInputs(): Inputs {
Expand All @@ -20,5 +21,6 @@ export function getInputs(): Inputs {
footer: core.getInput('notes-footer'),
variables: Util.getInputList('variables'),
collapseAfter: parseInt(core.getInput('collapse-after'), 10),
publish: core.getBooleanInput('publish'),
}
}
2 changes: 1 addition & 1 deletion src/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export async function createOrUpdateRelease(
return
}

const draft = releaseData.branch !== 'tag'
const draft = releaseData.branch !== 'tag' || !inputs.publish
releaseData.branch = (releaseData.branch === 'tag' && releaseDraft?.target_commitish) || releaseData.branch
core.debug(`releaseData.branch: ${releaseData.branch}`)
const newReleaseNotes = await generateReleaseNotes(client, inputs, releaseData)
Expand Down

0 comments on commit f7c1b2e

Please sign in to comment.