1
0
mirror of https://github.com/joaquinjsb/gitea-release-please-action synced 2026-05-13 22:21:33 +02:00

feat(release-please): use latest release please version (#210)

This commit is contained in:
Ivan Santos
2021-02-12 16:55:35 -06:00
committed by GitHub
parent b7fac390e7
commit 484099d969
4 changed files with 712 additions and 859 deletions

View File

@@ -1,6 +1,6 @@
const core = require('@actions/core') const core = require('@actions/core')
const { GitHubRelease } = require('release-please/build/src/github-release') const { GitHubRelease } = require('release-please/build/src/github-release')
const { ReleasePRFactory } = require('release-please/build/src/release-pr-factory') const { ReleasePR } = require('release-please/build/src/release-pr')
const RELEASE_LABEL = 'autorelease: pending' const RELEASE_LABEL = 'autorelease: pending'
@@ -51,7 +51,9 @@ async function main () {
// Next we check for PRs merged since the last release, and groom the // Next we check for PRs merged since the last release, and groom the
// release PR: // release PR:
if (!command || command === 'release-pr') { if (!command || command === 'release-pr') {
const release = releasePlease.getReleasePRFactory().buildStatic(releaseType, { const GithubReleasePR = releasePlease.getReleasePR()
const release = new GithubReleasePR({
releaseType,
monorepoTags, monorepoTags,
packageName, packageName,
path, path,
@@ -65,6 +67,7 @@ async function main () {
versionFile, versionFile,
defaultBranch defaultBranch
}) })
const pr = await release.run() const pr = await release.run()
if (pr) { if (pr) {
core.setOutput('pr', pr) core.setOutput('pr', pr)
@@ -76,14 +79,14 @@ function getGitHubRelease () {
return GitHubRelease return GitHubRelease
} }
function getReleasePRFactory () { function getReleasePR () {
return ReleasePRFactory return ReleasePR
} }
const releasePlease = { const releasePlease = {
main, main,
getGitHubRelease, getGitHubRelease,
getReleasePRFactory getReleasePR
} }
if (require.main === module) { if (require.main === module) {

1432
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -26,14 +26,14 @@
"homepage": "https://github.com/bcoe/release-please-action#readme", "homepage": "https://github.com/bcoe/release-please-action#readme",
"dependencies": { "dependencies": {
"@actions/core": "^1.2.6", "@actions/core": "^1.2.6",
"release-please": "^9.3.0" "release-please": "^10.1.0"
}, },
"devDependencies": { "devDependencies": {
"@zeit/ncc": "^0.22.3", "@vercel/ncc": "^0.27.0",
"c8": "^7.3.5", "c8": "^7.5.0",
"mocha": "^8.2.1", "mocha": "^8.2.1",
"sinon": "^9.2.1", "sinon": "^9.2.4",
"standard": "^14.3.4" "standard": "^16.0.3"
}, },
"standard": { "standard": {
"ignore": "dist/" "ignore": "dist/"

View File

@@ -32,20 +32,28 @@ describe('release-please-action', () => {
}) })
return ReleaseStub return ReleaseStub
} }
const releasePR = sinon.stub().returns(25)
const buildStatic = sinon.stub().returns({ let GithubReleasePRStub = sinon.stub()
run: releasePR const runStub = sinon.stub().returns(25)
})
action.getReleasePRFactory = () => { action.getReleasePR = () => {
return { class GithubReleasePR {
buildStatic run () {}
} }
GithubReleasePRStub = sinon.spy(function () {
const instance = sinon.createStubInstance(GithubReleasePR)
instance.run = runStub
return instance
})
return GithubReleasePRStub
} }
await action.main() await action.main()
sinon.assert.calledOnce(createRelease) sinon.assert.calledOnce(createRelease)
sinon.assert.calledWith(ReleaseStub, sinon.match.hasOwn('defaultBranch', undefined)) sinon.assert.calledWith(ReleaseStub, sinon.match.hasOwn('defaultBranch', undefined))
sinon.assert.calledWith(buildStatic, 'node', sinon.match.hasOwn('defaultBranch', undefined)) sinon.assert.calledOnce(runStub)
sinon.assert.calledOnce(releasePR) sinon.assert.calledWith(GithubReleasePRStub, sinon.match.hasOwn('defaultBranch', undefined))
assert.deepStrictEqual(output, { assert.deepStrictEqual(output, {
release_created: true, release_created: true,
upload_url: 'http://example.com', upload_url: 'http://example.com',
@@ -83,20 +91,28 @@ describe('release-please-action', () => {
}) })
return ReleaseStub return ReleaseStub
} }
const releasePR = sinon.stub().returns(25)
const buildStatic = sinon.stub().returns({ let GithubReleasePRStub = sinon.stub()
run: releasePR const runStub = sinon.stub().returns(25)
})
action.getReleasePRFactory = () => { action.getReleasePR = () => {
return { class GithubReleasePR {
buildStatic run () {}
} }
GithubReleasePRStub = sinon.spy(function () {
const instance = sinon.createStubInstance(GithubReleasePR)
instance.run = runStub
return instance
})
return GithubReleasePRStub
} }
await action.main() await action.main()
sinon.assert.calledOnce(createRelease) sinon.assert.calledOnce(createRelease)
sinon.assert.calledWith(ReleaseStub, sinon.match.hasOwn('defaultBranch', 'dev')) sinon.assert.calledWith(ReleaseStub, sinon.match.hasOwn('defaultBranch', 'dev'))
sinon.assert.calledWith(buildStatic, 'node', sinon.match.hasOwn('defaultBranch', 'dev')) sinon.assert.calledOnce(runStub)
sinon.assert.calledOnce(releasePR) sinon.assert.calledWith(GithubReleasePRStub, sinon.match.hasOwn('defaultBranch', 'dev'))
assert.deepStrictEqual(output, { assert.deepStrictEqual(output, {
release_created: true, release_created: true,
upload_url: 'http://example.com', upload_url: 'http://example.com',
@@ -126,19 +142,25 @@ describe('release-please-action', () => {
Release.prototype.createRelease = githubRelease Release.prototype.createRelease = githubRelease
return Release return Release
} }
const releasePR = sinon.stub()
action.getReleasePRFactory = () => { let GithubReleasePRStub = sinon.stub()
return { const runStub = sinon.stub().returns(25)
buildStatic: () => {
return { action.getReleasePR = () => {
run: releasePR class GithubReleasePR {
} run () {}
}
} }
GithubReleasePRStub = sinon.spy(function () {
const instance = sinon.createStubInstance(GithubReleasePR)
instance.run = runStub
return instance
})
return GithubReleasePRStub
} }
await action.main() await action.main()
sinon.assert.notCalled(githubRelease) sinon.assert.notCalled(githubRelease)
sinon.assert.calledOnce(releasePR) sinon.assert.calledOnce(runStub)
}) })
it('only creates GitHub release, if command set to github-release', async () => { it('only creates GitHub release, if command set to github-release', async () => {
@@ -233,15 +255,19 @@ describe('release-please-action', () => {
core.getInput = (name) => { core.getInput = (name) => {
return input[name] return input[name]
} }
const releasePR = sinon.stub().returns(95) let GithubReleasePRStub = sinon.stub()
action.getReleasePRFactory = () => { const runStub = sinon.stub().returns(95)
return {
buildStatic: () => { action.getReleasePR = () => {
return { class GithubReleasePR {
run: releasePR run () {}
}
}
} }
GithubReleasePRStub = sinon.spy(function () {
const instance = sinon.createStubInstance(GithubReleasePR)
instance.run = runStub
return instance
})
return GithubReleasePRStub
} }
await action.main() await action.main()
assert.strictEqual(output.pr, 95) assert.strictEqual(output.pr, 95)
@@ -259,15 +285,19 @@ describe('release-please-action', () => {
core.getInput = (name) => { core.getInput = (name) => {
return input[name] return input[name]
} }
const releasePR = sinon.stub().returns(undefined) let GithubReleasePRStub = sinon.stub()
action.getReleasePRFactory = () => { const runStub = sinon.stub().returns(undefined)
return {
buildStatic: () => { action.getReleasePR = () => {
return { class GithubReleasePR {
run: releasePR run () {}
}
}
} }
GithubReleasePRStub = sinon.spy(function () {
const instance = sinon.createStubInstance(GithubReleasePR)
instance.run = runStub
return instance
})
return GithubReleasePRStub
} }
await action.main() await action.main()
assert.strictEqual(Object.hasOwnProperty.call(output, 'pr'), false) assert.strictEqual(Object.hasOwnProperty.call(output, 'pr'), false)