Add prerelease
This commit is contained in:
@@ -12,6 +12,7 @@ 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.
|
||||||
|
- **prerelease**: Optionally marks this release as prerelease. Set to true to enable.
|
||||||
- **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).
|
||||||
- **token**: (**Required**) The Github token. Typically this will be `${{ secrets.GITHUB_TOKEN }}`.
|
- **token**: (**Required**) The Github token. Typically this will be `${{ secrets.GITHUB_TOKEN }}`.
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,7 @@ const commit = 'commit'
|
|||||||
const draft = true
|
const draft = true
|
||||||
const id = 100
|
const id = 100
|
||||||
const name = 'name'
|
const name = 'name'
|
||||||
|
const prerelease = true
|
||||||
const tag = 'tag'
|
const tag = 'tag'
|
||||||
const token = 'token'
|
const token = 'token'
|
||||||
const url = 'http://api.example.com'
|
const url = 'http://api.example.com'
|
||||||
@@ -36,7 +37,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, body, commit, draft, name)
|
expect(createMock).toBeCalledWith(tag, body, commit, draft, name, prerelease)
|
||||||
expect(uploadMock).not.toBeCalled()
|
expect(uploadMock).not.toBeCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -49,7 +50,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, body, commit, draft, name)
|
expect(createMock).toBeCalledWith(tag, body, commit, draft, name, prerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, url)
|
expect(uploadMock).toBeCalledWith(artifacts, url)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -58,7 +59,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, body, commit, draft, name)
|
expect(createMock).toBeCalledWith(tag, body, commit, draft, name, prerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, url)
|
expect(uploadMock).toBeCalledWith(artifacts, url)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -73,7 +74,7 @@ describe("Action", () => {
|
|||||||
expect(error).toEqual("error")
|
expect(error).toEqual("error")
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, body, commit, draft, name)
|
expect(createMock).toBeCalledWith(tag, body, commit, draft, name, prerelease)
|
||||||
expect(uploadMock).not.toBeCalled()
|
expect(uploadMock).not.toBeCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -114,7 +115,7 @@ describe("Action", () => {
|
|||||||
expect(error).toEqual("error")
|
expect(error).toEqual("error")
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(updateMock).toBeCalledWith(id, tag, body, commit, draft, name)
|
expect(updateMock).toBeCalledWith(id, tag, body, commit, draft, name, prerelease)
|
||||||
expect(uploadMock).not.toBeCalled()
|
expect(uploadMock).not.toBeCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -129,7 +130,7 @@ describe("Action", () => {
|
|||||||
expect(error).toEqual("error")
|
expect(error).toEqual("error")
|
||||||
}
|
}
|
||||||
|
|
||||||
expect(createMock).toBeCalledWith(tag, body, commit, draft, name)
|
expect(createMock).toBeCalledWith(tag, body, commit, draft, name, prerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, url)
|
expect(uploadMock).toBeCalledWith(artifacts, url)
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -138,7 +139,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(updateMock).toBeCalledWith(id, tag, body, commit, draft, name)
|
expect(updateMock).toBeCalledWith(id, tag, body, commit, draft, name, prerelease)
|
||||||
expect(uploadMock).not.toBeCalled()
|
expect(uploadMock).not.toBeCalled()
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -148,7 +149,7 @@ describe("Action", () => {
|
|||||||
|
|
||||||
await action.perform()
|
await action.perform()
|
||||||
|
|
||||||
expect(updateMock).toBeCalledWith(id, tag, body, commit, draft, name)
|
expect(updateMock).toBeCalledWith(id, tag, body, commit, draft, name, prerelease)
|
||||||
expect(uploadMock).toBeCalledWith(artifacts, url)
|
expect(uploadMock).toBeCalledWith(artifacts, url)
|
||||||
|
|
||||||
})
|
})
|
||||||
@@ -194,6 +195,7 @@ describe("Action", () => {
|
|||||||
commit: commit,
|
commit: commit,
|
||||||
draft: draft,
|
draft: draft,
|
||||||
name: name,
|
name: name,
|
||||||
|
prerelease: prerelease,
|
||||||
tag: tag,
|
tag: tag,
|
||||||
token: token,
|
token: token,
|
||||||
readArtifact: () => artifactData
|
readArtifact: () => artifactData
|
||||||
|
|||||||
@@ -133,6 +133,17 @@ describe('Inputs', () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('prerelase', () => {
|
||||||
|
it('returns false', () => {
|
||||||
|
expect(inputs.prerelease).toBe(false)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('returns true', () => {
|
||||||
|
mockGetInput.mockReturnValue('true')
|
||||||
|
expect(inputs.prerelease).toBe(true)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('tag', () => {
|
describe('tag', () => {
|
||||||
it('returns input tag', () => {
|
it('returns input tag', () => {
|
||||||
mockGetInput.mockReturnValue('tag')
|
mockGetInput.mockReturnValue('tag')
|
||||||
|
|||||||
@@ -29,6 +29,9 @@ inputs:
|
|||||||
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.'
|
||||||
default: ''
|
default: ''
|
||||||
|
prerelease:
|
||||||
|
description: "Optionally marks this release as prerelease. Set to true to enable."
|
||||||
|
default: ''
|
||||||
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).'
|
||||||
default: ''
|
default: ''
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class Action {
|
|||||||
}
|
}
|
||||||
createRelease() {
|
createRelease() {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const response = yield this.releases.create(this.inputs.tag, this.inputs.body, this.inputs.commit, this.inputs.draft, this.inputs.name);
|
const response = yield this.releases.create(this.inputs.tag, this.inputs.body, this.inputs.commit, this.inputs.draft, this.inputs.name, this.inputs.prerelease);
|
||||||
return response.data.upload_url;
|
return response.data.upload_url;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -58,7 +58,7 @@ class Action {
|
|||||||
}
|
}
|
||||||
updateRelease(id) {
|
updateRelease(id) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
const response = yield this.releases.update(id, this.inputs.tag, this.inputs.body, this.inputs.commit, this.inputs.draft, this.inputs.name);
|
const response = yield this.releases.update(id, this.inputs.tag, this.inputs.body, this.inputs.commit, this.inputs.draft, this.inputs.name, this.inputs.prerelease);
|
||||||
return response.data.upload_url;
|
return response.data.upload_url;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,6 +58,10 @@ class CoreInputs {
|
|||||||
}
|
}
|
||||||
return this.tag;
|
return this.tag;
|
||||||
}
|
}
|
||||||
|
get prerelease() {
|
||||||
|
const draft = core.getInput('prerelease');
|
||||||
|
return draft == 'true';
|
||||||
|
}
|
||||||
get tag() {
|
get tag() {
|
||||||
const tag = core.getInput('tag');
|
const tag = core.getInput('tag');
|
||||||
if (tag) {
|
if (tag) {
|
||||||
|
|||||||
@@ -14,13 +14,14 @@ class GithubReleases {
|
|||||||
this.context = context;
|
this.context = context;
|
||||||
this.git = git;
|
this.git = git;
|
||||||
}
|
}
|
||||||
create(tag, body, commitHash, draft, name) {
|
create(tag, body, commitHash, draft, name, prerelease) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return this.git.repos.createRelease({
|
return this.git.repos.createRelease({
|
||||||
body: body,
|
body: body,
|
||||||
name: name,
|
name: name,
|
||||||
draft: draft,
|
draft: draft,
|
||||||
owner: this.context.repo.owner,
|
owner: this.context.repo.owner,
|
||||||
|
prerelease: prerelease,
|
||||||
repo: this.context.repo.repo,
|
repo: this.context.repo.repo,
|
||||||
target_commitish: commitHash,
|
target_commitish: commitHash,
|
||||||
tag_name: tag
|
tag_name: tag
|
||||||
@@ -36,7 +37,7 @@ class GithubReleases {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
update(id, tag, body, commitHash, draft, name) {
|
update(id, tag, body, commitHash, draft, name, prerelease) {
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
return this.git.repos.updateRelease({
|
return this.git.repos.updateRelease({
|
||||||
release_id: id,
|
release_id: id,
|
||||||
@@ -44,6 +45,7 @@ class GithubReleases {
|
|||||||
name: name,
|
name: name,
|
||||||
draft: draft,
|
draft: draft,
|
||||||
owner: this.context.repo.owner,
|
owner: this.context.repo.owner,
|
||||||
|
prerelease: prerelease,
|
||||||
repo: this.context.repo.repo,
|
repo: this.context.repo.repo,
|
||||||
target_commitish: commitHash,
|
target_commitish: commitHash,
|
||||||
tag_name: tag
|
tag_name: tag
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ export class Action {
|
|||||||
this.inputs.body,
|
this.inputs.body,
|
||||||
this.inputs.commit,
|
this.inputs.commit,
|
||||||
this.inputs.draft,
|
this.inputs.draft,
|
||||||
this.inputs.name
|
this.inputs.name,
|
||||||
|
this.inputs.prerelease
|
||||||
)
|
)
|
||||||
|
|
||||||
return response.data.upload_url
|
return response.data.upload_url
|
||||||
@@ -64,7 +65,8 @@ export class Action {
|
|||||||
this.inputs.body,
|
this.inputs.body,
|
||||||
this.inputs.commit,
|
this.inputs.commit,
|
||||||
this.inputs.draft,
|
this.inputs.draft,
|
||||||
this.inputs.name
|
this.inputs.name,
|
||||||
|
this.inputs.prerelease
|
||||||
)
|
)
|
||||||
|
|
||||||
return response.data.upload_url
|
return response.data.upload_url
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ export interface Inputs {
|
|||||||
readonly commit: string
|
readonly commit: string
|
||||||
readonly draft: boolean
|
readonly draft: boolean
|
||||||
readonly name: string
|
readonly name: string
|
||||||
|
readonly prerelease: boolean
|
||||||
readonly tag: string
|
readonly tag: string
|
||||||
readonly token: string
|
readonly token: string
|
||||||
}
|
}
|
||||||
@@ -77,6 +78,11 @@ export class CoreInputs implements Inputs {
|
|||||||
return this.tag
|
return this.tag
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get prerelease(): boolean {
|
||||||
|
const draft = core.getInput('prerelease')
|
||||||
|
return draft == 'true'
|
||||||
|
}
|
||||||
|
|
||||||
get tag(): string {
|
get tag(): string {
|
||||||
const tag = core.getInput('tag')
|
const tag = core.getInput('tag')
|
||||||
if (tag) {
|
if (tag) {
|
||||||
|
|||||||
@@ -8,7 +8,8 @@ export interface Releases {
|
|||||||
body?: string,
|
body?: string,
|
||||||
commitHash?: string,
|
commitHash?: string,
|
||||||
draft?: boolean,
|
draft?: boolean,
|
||||||
name?: string
|
name?: string,
|
||||||
|
prerelease?: boolean
|
||||||
): Promise<Response<ReposCreateReleaseResponse>>
|
): Promise<Response<ReposCreateReleaseResponse>>
|
||||||
|
|
||||||
getByTag(tag: string): Promise<Response<ReposGetReleaseByTagResponse>>
|
getByTag(tag: string): Promise<Response<ReposGetReleaseByTagResponse>>
|
||||||
@@ -19,7 +20,8 @@ export interface Releases {
|
|||||||
body?: string,
|
body?: string,
|
||||||
commitHash?: string,
|
commitHash?: string,
|
||||||
draft?: boolean,
|
draft?: boolean,
|
||||||
name?: string
|
name?: string,
|
||||||
|
prerelease?: boolean
|
||||||
): Promise<Response<ReposCreateReleaseResponse>>
|
): Promise<Response<ReposCreateReleaseResponse>>
|
||||||
|
|
||||||
uploadArtifact(
|
uploadArtifact(
|
||||||
@@ -45,13 +47,15 @@ export class GithubReleases implements Releases {
|
|||||||
body?: string,
|
body?: string,
|
||||||
commitHash?: string,
|
commitHash?: string,
|
||||||
draft?: boolean,
|
draft?: boolean,
|
||||||
name?: string
|
name?: string,
|
||||||
|
prerelease?: boolean
|
||||||
): Promise<Response<ReposCreateReleaseResponse>> {
|
): Promise<Response<ReposCreateReleaseResponse>> {
|
||||||
return this.git.repos.createRelease({
|
return this.git.repos.createRelease({
|
||||||
body: body,
|
body: body,
|
||||||
name: name,
|
name: name,
|
||||||
draft: draft,
|
draft: draft,
|
||||||
owner: this.context.repo.owner,
|
owner: this.context.repo.owner,
|
||||||
|
prerelease: prerelease,
|
||||||
repo: this.context.repo.repo,
|
repo: this.context.repo.repo,
|
||||||
target_commitish: commitHash,
|
target_commitish: commitHash,
|
||||||
tag_name: tag
|
tag_name: tag
|
||||||
@@ -72,7 +76,8 @@ export class GithubReleases implements Releases {
|
|||||||
body?: string,
|
body?: string,
|
||||||
commitHash?: string,
|
commitHash?: string,
|
||||||
draft?: boolean,
|
draft?: boolean,
|
||||||
name?: string
|
name?: string,
|
||||||
|
prerelease?: boolean
|
||||||
): Promise<Response<ReposCreateReleaseResponse>> {
|
): Promise<Response<ReposCreateReleaseResponse>> {
|
||||||
return this.git.repos.updateRelease({
|
return this.git.repos.updateRelease({
|
||||||
release_id: id,
|
release_id: id,
|
||||||
@@ -80,6 +85,7 @@ export class GithubReleases implements Releases {
|
|||||||
name: name,
|
name: name,
|
||||||
draft: draft,
|
draft: draft,
|
||||||
owner: this.context.repo.owner,
|
owner: this.context.repo.owner,
|
||||||
|
prerelease: prerelease,
|
||||||
repo: this.context.repo.repo,
|
repo: this.context.repo.repo,
|
||||||
target_commitish: commitHash,
|
target_commitish: commitHash,
|
||||||
tag_name: tag
|
tag_name: tag
|
||||||
|
|||||||
Reference in New Issue
Block a user