Add option to ignore prerelease on update (#96)
This commit is contained in:
@@ -18,6 +18,8 @@ This action will create a GitHub release and optionally upload an artifact to it
|
|||||||
- **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.
|
- **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.
|
- **omitName**: Indicates if the release name should be omitted.
|
||||||
- **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.
|
- **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.
|
||||||
|
- **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.
|
||||||
- **owner**: Optionally specify the owner of the repo where the release should be generated. Defaults to current repo's owner.
|
- **owner**: Optionally specify the owner of the repo where the release should be generated. Defaults to current repo's owner.
|
||||||
- **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`.
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ const commit = 'commit'
|
|||||||
const discussionCategory = 'discussionCategory'
|
const discussionCategory = 'discussionCategory'
|
||||||
const draft = true
|
const draft = true
|
||||||
const id = 100
|
const id = 100
|
||||||
const prerelease = true
|
const createPrerelease = true
|
||||||
|
const updatePrerelease = false
|
||||||
const releaseId = 101
|
const releaseId = 101
|
||||||
const replacesArtifacts = true
|
const replacesArtifacts = true
|
||||||
const tag = 'tag'
|
const tag = 'tag'
|
||||||
@@ -48,7 +49,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, createBody, commit, discussionCategory, draft, createName, prerelease)
|
expect(createMock).toBeCalledWith(tag, createBody, commit, discussionCategory, draft, createName, createPrerelease)
|
||||||
expect(uploadMock).not.toBeCalled()
|
expect(uploadMock).not.toBeCalled()
|
||||||
assertOutputApplied()
|
assertOutputApplied()
|
||||||
})
|
})
|
||||||
@@ -60,7 +61,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, createBody, commit, discussionCategory, draft, createName, prerelease)
|
expect(createMock).toBeCalledWith(tag, createBody, commit, discussionCategory, draft, createName, createPrerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
assertOutputApplied()
|
assertOutputApplied()
|
||||||
})
|
})
|
||||||
@@ -77,7 +78,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, createBody, commit, discussionCategory, draft, createName, prerelease)
|
expect(createMock).toBeCalledWith(tag, createBody, commit, discussionCategory, draft, createName, createPrerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
assertOutputApplied()
|
assertOutputApplied()
|
||||||
|
|
||||||
@@ -88,7 +89,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, createBody, commit, discussionCategory, draft, createName, prerelease)
|
expect(createMock).toBeCalledWith(tag, createBody, commit, discussionCategory, draft, createName, createPrerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
assertOutputApplied()
|
assertOutputApplied()
|
||||||
})
|
})
|
||||||
@@ -104,7 +105,7 @@ describe("Action", () => {
|
|||||||
expect(error).toEqual("error")
|
expect(error).toEqual("error")
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, createBody, commit, discussionCategory, draft, createName, prerelease)
|
expect(createMock).toBeCalledWith(tag, createBody, commit, discussionCategory, draft, createName, createPrerelease)
|
||||||
expect(uploadMock).not.toBeCalled()
|
expect(uploadMock).not.toBeCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -153,7 +154,7 @@ describe("Action", () => {
|
|||||||
discussionCategory,
|
discussionCategory,
|
||||||
draft,
|
draft,
|
||||||
updateName,
|
updateName,
|
||||||
prerelease
|
updatePrerelease
|
||||||
)
|
)
|
||||||
expect(uploadMock).not.toBeCalled()
|
expect(uploadMock).not.toBeCalled()
|
||||||
})
|
})
|
||||||
@@ -170,7 +171,7 @@ describe("Action", () => {
|
|||||||
expect(error).toEqual(expectedError)
|
expect(error).toEqual(expectedError)
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, createBody, commit, discussionCategory, draft, createName, prerelease)
|
expect(createMock).toBeCalledWith(tag, createBody, commit, discussionCategory, draft, createName, createPrerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -195,7 +196,7 @@ describe("Action", () => {
|
|||||||
discussionCategory,
|
discussionCategory,
|
||||||
draft,
|
draft,
|
||||||
updateName,
|
updateName,
|
||||||
prerelease
|
updatePrerelease
|
||||||
)
|
)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
assertOutputApplied()
|
assertOutputApplied()
|
||||||
@@ -214,7 +215,7 @@ describe("Action", () => {
|
|||||||
discussionCategory,
|
discussionCategory,
|
||||||
draft,
|
draft,
|
||||||
updateName,
|
updateName,
|
||||||
prerelease
|
updatePrerelease
|
||||||
)
|
)
|
||||||
expect(uploadMock).not.toBeCalled()
|
expect(uploadMock).not.toBeCalled()
|
||||||
assertOutputApplied()
|
assertOutputApplied()
|
||||||
@@ -233,7 +234,7 @@ describe("Action", () => {
|
|||||||
discussionCategory,
|
discussionCategory,
|
||||||
draft,
|
draft,
|
||||||
updateName,
|
updateName,
|
||||||
prerelease
|
updatePrerelease
|
||||||
)
|
)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
expect(uploadMock).toBeCalledWith(artifacts, releaseId, url)
|
||||||
assertOutputApplied()
|
assertOutputApplied()
|
||||||
@@ -295,13 +296,14 @@ describe("Action", () => {
|
|||||||
discussionCategory: discussionCategory,
|
discussionCategory: discussionCategory,
|
||||||
draft: draft,
|
draft: draft,
|
||||||
owner: "owner",
|
owner: "owner",
|
||||||
prerelease: prerelease,
|
createdPrerelease: createPrerelease,
|
||||||
replacesArtifacts: replacesArtifacts,
|
replacesArtifacts: replacesArtifacts,
|
||||||
repo: "repo",
|
repo: "repo",
|
||||||
tag: tag,
|
tag: tag,
|
||||||
token: token,
|
token: token,
|
||||||
updatedReleaseBody: updateBody,
|
updatedReleaseBody: updateBody,
|
||||||
updatedReleaseName: updateName
|
updatedReleaseName: updateName,
|
||||||
|
updatedPrerelease: updatePrerelease
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
const MockOutputs = jest.fn<Outputs, any>(() => {
|
const MockOutputs = jest.fn<Outputs, any>(() => {
|
||||||
|
|||||||
@@ -214,14 +214,14 @@ describe('Inputs', () => {
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('prerelase', () => {
|
describe('createdPrerelase', () => {
|
||||||
it('returns false', () => {
|
it('returns false', () => {
|
||||||
expect(inputs.prerelease).toBe(false)
|
expect(inputs.createdPrerelease).toBe(false)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns true', () => {
|
it('returns true', () => {
|
||||||
mockGetInput.mockReturnValue('true')
|
mockGetInput.mockReturnValue('true')
|
||||||
expect(inputs.prerelease).toBe(true)
|
expect(inputs.createdPrerelease).toBe(true)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -349,6 +349,29 @@ describe('Inputs', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('updatedPrerelease', () => {
|
||||||
|
it('returns false', () => {
|
||||||
|
mockGetInput
|
||||||
|
.mockReturnValueOnce('false')
|
||||||
|
.mockReturnValueOnce('false')
|
||||||
|
expect(inputs.updatedPrerelease).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('returns true', () => {
|
||||||
|
mockGetInput
|
||||||
|
.mockReturnValueOnce('false')
|
||||||
|
.mockReturnValueOnce('true')
|
||||||
|
expect(inputs.updatedPrerelease).toBe(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('returns undefined when omitted for update', () => {
|
||||||
|
mockGetInput
|
||||||
|
.mockReturnValueOnce('true')
|
||||||
|
.mockReturnValueOnce('false')
|
||||||
|
expect(inputs.updatedPrerelease).toBeUndefined()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
function createGlobber(): ArtifactGlobber {
|
function createGlobber(): ArtifactGlobber {
|
||||||
const MockGlobber = jest.fn<ArtifactGlobber, any>(() => {
|
const MockGlobber = jest.fn<ArtifactGlobber, any>(() => {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -44,13 +44,14 @@ describe.skip('Integration Test', () => {
|
|||||||
discussionCategory: 'Release',
|
discussionCategory: 'Release',
|
||||||
draft: false,
|
draft: false,
|
||||||
owner: "ncipollo",
|
owner: "ncipollo",
|
||||||
prerelease: false,
|
createdPrerelease: false,
|
||||||
replacesArtifacts: true,
|
replacesArtifacts: true,
|
||||||
repo: "actions-playground",
|
repo: "actions-playground",
|
||||||
tag: "release-action-test",
|
tag: "release-action-test",
|
||||||
token: getToken(),
|
token: getToken(),
|
||||||
updatedReleaseBody: "This release was generated by release-action's integration test",
|
updatedReleaseBody: "This release was generated by release-action's integration test",
|
||||||
updatedReleaseName: "Releases Action Integration Test"
|
updatedReleaseName: "Releases Action Integration Test",
|
||||||
|
updatedPrerelease: false
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
return new MockInputs();
|
return new MockInputs();
|
||||||
|
|||||||
@@ -63,6 +63,10 @@ inputs:
|
|||||||
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.'
|
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'
|
||||||
|
omitPrereleaseDuringUpdate:
|
||||||
|
description: '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.'
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
owner:
|
owner:
|
||||||
description: "Optionally specify the owner of the repo where the release should be generated. Defaults to current repo's owner."
|
description: "Optionally specify the owner of the repo where the release should be generated. Defaults to current repo's owner."
|
||||||
required: false
|
required: false
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ class Action {
|
|||||||
}
|
}
|
||||||
updateRelease(id) {
|
updateRelease(id) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return yield this.releases.update(id, this.inputs.tag, this.inputs.updatedReleaseBody, this.inputs.commit, this.inputs.discussionCategory, this.inputs.draft, this.inputs.updatedReleaseName, this.inputs.prerelease);
|
return yield this.releases.update(id, this.inputs.tag, this.inputs.updatedReleaseBody, this.inputs.commit, this.inputs.discussionCategory, this.inputs.draft, this.inputs.updatedReleaseName, this.inputs.updatedPrerelease);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
static noPublishedRelease(error) {
|
static noPublishedRelease(error) {
|
||||||
@@ -89,7 +89,7 @@ class Action {
|
|||||||
}
|
}
|
||||||
createRelease() {
|
createRelease() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return yield this.releases.create(this.inputs.tag, this.inputs.createdReleaseBody, this.inputs.commit, this.inputs.discussionCategory, this.inputs.draft, this.inputs.createdReleaseName, this.inputs.prerelease);
|
return yield this.releases.create(this.inputs.tag, this.inputs.createdReleaseBody, this.inputs.commit, this.inputs.discussionCategory, this.inputs.draft, this.inputs.createdReleaseName, this.inputs.createdPrerelease);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -105,10 +105,18 @@ class CoreInputs {
|
|||||||
}
|
}
|
||||||
return this.context.repo.owner;
|
return this.context.repo.owner;
|
||||||
}
|
}
|
||||||
get prerelease() {
|
get createdPrerelease() {
|
||||||
const preRelease = core.getInput('prerelease');
|
const preRelease = core.getInput('prerelease');
|
||||||
return preRelease == 'true';
|
return preRelease == 'true';
|
||||||
}
|
}
|
||||||
|
static get omitPrereleaseDuringUpdate() {
|
||||||
|
return core.getInput('omitPrereleaseDuringUpdate') == 'true';
|
||||||
|
}
|
||||||
|
get updatedPrerelease() {
|
||||||
|
if (CoreInputs.omitPrereleaseDuringUpdate)
|
||||||
|
return undefined;
|
||||||
|
return this.createdPrerelease;
|
||||||
|
}
|
||||||
get replacesArtifacts() {
|
get replacesArtifacts() {
|
||||||
const replaces = core.getInput('replacesArtifacts');
|
const replaces = core.getInput('replacesArtifacts');
|
||||||
return replaces == 'true';
|
return replaces == 'true';
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ export class Action {
|
|||||||
this.inputs.discussionCategory,
|
this.inputs.discussionCategory,
|
||||||
this.inputs.draft,
|
this.inputs.draft,
|
||||||
this.inputs.updatedReleaseName,
|
this.inputs.updatedReleaseName,
|
||||||
this.inputs.prerelease
|
this.inputs.updatedPrerelease
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -104,7 +104,7 @@ export class Action {
|
|||||||
this.inputs.discussionCategory,
|
this.inputs.discussionCategory,
|
||||||
this.inputs.draft,
|
this.inputs.draft,
|
||||||
this.inputs.createdReleaseName,
|
this.inputs.createdReleaseName,
|
||||||
this.inputs.prerelease
|
this.inputs.createdPrerelease
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,13 +14,14 @@ export interface Inputs {
|
|||||||
readonly discussionCategory?: string
|
readonly discussionCategory?: string
|
||||||
readonly draft: boolean
|
readonly draft: boolean
|
||||||
readonly owner: string
|
readonly owner: string
|
||||||
readonly prerelease: boolean
|
readonly createdPrerelease: boolean
|
||||||
readonly replacesArtifacts: boolean
|
readonly replacesArtifacts: boolean
|
||||||
readonly repo: string
|
readonly repo: string
|
||||||
readonly tag: string
|
readonly tag: string
|
||||||
readonly token: string
|
readonly token: string
|
||||||
readonly updatedReleaseBody?: string
|
readonly updatedReleaseBody?: string
|
||||||
readonly updatedReleaseName?: string
|
readonly updatedReleaseName?: string
|
||||||
|
readonly updatedPrerelease?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
export class CoreInputs implements Inputs {
|
export class CoreInputs implements Inputs {
|
||||||
@@ -124,11 +125,19 @@ export class CoreInputs implements Inputs {
|
|||||||
return this.context.repo.owner
|
return this.context.repo.owner
|
||||||
}
|
}
|
||||||
|
|
||||||
get prerelease(): boolean {
|
get createdPrerelease(): boolean {
|
||||||
const preRelease = core.getInput('prerelease')
|
const preRelease = core.getInput('prerelease')
|
||||||
return preRelease == 'true'
|
return preRelease == 'true'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static get omitPrereleaseDuringUpdate(): boolean {
|
||||||
|
return core.getInput('omitPrereleaseDuringUpdate') == 'true'
|
||||||
|
}
|
||||||
|
|
||||||
|
get updatedPrerelease(): boolean | undefined {
|
||||||
|
if (CoreInputs.omitPrereleaseDuringUpdate) return undefined
|
||||||
|
return this.createdPrerelease
|
||||||
|
}
|
||||||
get replacesArtifacts(): boolean {
|
get replacesArtifacts(): boolean {
|
||||||
const replaces = core.getInput('replacesArtifacts')
|
const replaces = core.getInput('replacesArtifacts')
|
||||||
return replaces == 'true'
|
return replaces == 'true'
|
||||||
|
|||||||
Reference in New Issue
Block a user