Skip to content

Commit

Permalink
Update "makeLatest" so it's always defined
Browse files Browse the repository at this point in the history
  • Loading branch information
ncipollo committed Dec 11, 2022
1 parent 78ea7b5 commit a2e71bd
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 51 deletions.
56 changes: 28 additions & 28 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,35 +13,35 @@ This action will create a GitHub release and optionally upload an artifact to it
</div>

## Action Inputs
| Input name | Description | Required | Default Value |
|----------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------|----------------------|
| allowUpdates | An optional flag which indicates if we should update a release if it already exists. Defaults to false. | false | "" |
| artifactErrorsFailBuild | An optional flag which indicates if artifact read or upload errors should fail the build. | false | "" |
| artifacts | 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) | false | "" |
| artifactContentType | The content type of the artifact. Defaults to raw | false | "" |
| body | An optional body for the release. | false | "" |
| bodyFile | An optional body file for the release. This should be the path to the file. | false | "" |
| commit | An optional commit reference. This will be used to create the tag if it does not exist. | false | "" |
| discussionCategory | When provided this will generate a discussion of the specified category. The category must exist otherwise this will cause the action to fail. This isn't used with draft releases | false | "" |
| draft | Optionally marks this release as a draft release. Set to true to enable. | false | "" |
| generateReleaseNotes | Indicates if release notes should be automatically generated. | false | false |
| makeLatest | Indicates if the release should be the "latest" release or not. release. | false | "legacy" |
| 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 |
| owner | Optionally specify the owner of the repo where the release should be generated. Defaults to current repo's owner. | false | "current repo owner" |
| prerelease | Optionally marks this release as prerelease. Set to true to enable. | false | "" |
| removeArtifacts | Indicates if existing release artifacts should be removed. | false | false |
| replacesArtifacts | Indicates if existing release artifacts should be replaced. | false | true |
| repo | Optionally specify the repo where the release should be generated. | false | current repo |
| skipIfReleaseExists | When skipIfReleaseExists is enabled the action will be skipped if a non-draft release already exists for the provided tag. | false | false |
| tag | An optional tag for the release. If this is omitted the git ref will be used (if it is a tag). | false | "" |
| Input name | Description | Required | Default Value |
|----------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|------------|----------------------|
| allowUpdates | An optional flag which indicates if we should update a release if it already exists. Defaults to false. | false | "" |
| artifactErrorsFailBuild | An optional flag which indicates if artifact read or upload errors should fail the build. | false | "" |
| artifacts | 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) | false | "" |
| artifactContentType | The content type of the artifact. Defaults to raw | false | "" |
| body | An optional body for the release. | false | "" |
| bodyFile | An optional body file for the release. This should be the path to the file. | false | "" |
| commit | An optional commit reference. This will be used to create the tag if it does not exist. | false | "" |
| discussionCategory | When provided this will generate a discussion of the specified category. The category must exist otherwise this will cause the action to fail. This isn't used with draft releases | false | "" |
| draft | Optionally marks this release as a draft release. Set to true to enable. | false | "" |
| generateReleaseNotes | Indicates if release notes should be automatically generated. | false | false |
| makeLatest | Indicates if the release should be the "latest" release or not. | false | "legacy" |
| 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 |
| owner | Optionally specify the owner of the repo where the release should be generated. Defaults to current repo's owner. | false | "current repo owner" |
| prerelease | Optionally marks this release as prerelease. Set to true to enable. | false | "" |
| removeArtifacts | Indicates if existing release artifacts should be removed. | false | false |
| replacesArtifacts | Indicates if existing release artifacts should be replaced. | false | true |
| repo | Optionally specify the repo where the release should be generated. | false | current repo |
| skipIfReleaseExists | When skipIfReleaseExists is enabled the action will be skipped if a non-draft release already exists for the provided tag. | false | false |
| tag | An optional tag for the release. If this is omitted the git ref will be used (if it is a tag). | false | "" |
| token | The GitHub token. This will default to the GitHub app token. This is primarily useful if you want to use your personal token (for targeting other repos, etc). If you are using a personal access token it should have access to the `repo` scope. | false | github.token |
| updateOnlyUnreleased | When allowUpdates is enabled, this will fail the action if the release it is updating is not a draft or a prerelease. | false | false |
| updateOnlyUnreleased | When allowUpdates is enabled, this will fail the action if the release it is updating is not a draft or a prerelease. | false | false |

## Action Outputs
| Output name | Description |
Expand Down
5 changes: 0 additions & 5 deletions __tests__/Inputs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,11 +240,6 @@ describe('Inputs', () => {
mockGetInput.mockReturnValueOnce('true')
expect(inputs.makeLatest).toBe('true')
})

it('returns undefined when omitted', () => {
mockGetInput.mockReturnValueOnce('')
expect(inputs.makeLatest).toBeUndefined()
})
})

describe('owner', () => {
Expand Down
6 changes: 1 addition & 5 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -780,11 +780,7 @@ class CoreInputs {
return generate == 'true';
}
get makeLatest() {
const makeLatest = core.getInput('makeLatest');
if (makeLatest) {
return makeLatest;
}
return undefined;
return core.getInput('makeLatest');
}
get owner() {
let owner = core.getInput('owner');
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

6 changes: 1 addition & 5 deletions lib/Inputs.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,7 @@ class CoreInputs {
return generate == 'true';
}
get makeLatest() {
const makeLatest = core.getInput('makeLatest');
if (makeLatest) {
return makeLatest;
}
return undefined;
return core.getInput('makeLatest');
}
get owner() {
let owner = core.getInput('owner');
Expand Down
9 changes: 2 additions & 7 deletions src/Inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,8 @@ export class CoreInputs implements Inputs {
return generate == 'true'
}

get makeLatest(): string | undefined {
const makeLatest = core.getInput('makeLatest')
if (makeLatest) {
return makeLatest
}

return undefined
get makeLatest(): string {
return core.getInput('makeLatest')
}

get owner(): string {
Expand Down

0 comments on commit a2e71bd

Please sign in to comment.