1
0
mirror of https://github.com/joaquinjsb/gitea-release-please-action synced 2026-05-05 10:37:47 +02:00

feat: add additional outputs (#106)

Opening a release PR now outputs a release #. Creating a GitHub release outputs
SemVer major/minor/patch values
This commit is contained in:
Benjamin E. Coe
2020-11-25 15:34:05 -05:00
committed by GitHub
parent dda9b7b3c4
commit c0f7d24cd0
6 changed files with 114 additions and 30 deletions

View File

@@ -41,11 +41,12 @@ describe('release-please-action', () => {
assert.deepStrictEqual(output, {
release_created: true,
upload_url: 'http://example.com',
tag_name: 'v1.0.0'
tag_name: 'v1.0.0',
pr: undefined
})
})
it('only opens PRs if, command set to release-pr', async () => {
it('only opens PR, if command set to release-pr', async () => {
const output = {}
core.setOutput = (name, value) => {
output[name] = value
@@ -81,7 +82,7 @@ describe('release-please-action', () => {
sinon.assert.calledOnce(releasePR)
})
it('only opens tags releases, if command set to github-release', async () => {
it('only creates GitHub release, if command set to github-release', async () => {
const output = {}
core.setOutput = (name, value) => {
output[name] = value
@@ -116,4 +117,74 @@ describe('release-please-action', () => {
sinon.assert.calledOnce(githubRelease)
sinon.assert.notCalled(releasePR)
})
it('sets approprite outputs when GitHub release created', async () => {
const expected = {
release_created: true,
upload_url: 'http://example.com',
html_url: 'http://example2.com',
tag_name: 'v1.0.0',
major: 1,
minor: 2,
patch: 3,
version: 'v1.2.3',
sha: 'abc123',
pr: 33
}
const output = {}
core.setOutput = (name, value) => {
output[name] = value
}
const input = {
'release-type': 'node',
command: 'github-release'
}
core.getInput = (name) => {
return input[name]
}
const githubRelease = sinon.stub().returns(expected)
action.getGitHubRelease = () => {
class Release {}
Release.prototype.createRelease = githubRelease
return Release
}
const releasePR = sinon.stub()
action.getReleasePRFactory = () => {
return {
buildStatic: () => {
return {
run: releasePR
}
}
}
}
await action.main()
assert.deepStrictEqual(output, expected)
})
it('sets appropriate outputs when release PR opened', async () => {
const output = {}
core.setOutput = (name, value) => {
output[name] = value
}
const input = {
'release-type': 'node',
command: 'release-pr'
}
core.getInput = (name) => {
return input[name]
}
const releasePR = sinon.stub().returns(95)
action.getReleasePRFactory = () => {
return {
buildStatic: () => {
return {
run: releasePR
}
}
}
}
await action.main()
assert.strictEqual(output.pr, 95)
})
})