mirror of
https://github.com/joaquinjsb/gitea-release-please-action
synced 2026-05-05 10:37:47 +02:00
feat(release-please): use latest release please version (#210)
This commit is contained in:
13
index.js
13
index.js
@@ -1,6 +1,6 @@
|
||||
const core = require('@actions/core')
|
||||
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'
|
||||
|
||||
@@ -51,7 +51,9 @@ async function main () {
|
||||
// Next we check for PRs merged since the last release, and groom the
|
||||
// release PR:
|
||||
if (!command || command === 'release-pr') {
|
||||
const release = releasePlease.getReleasePRFactory().buildStatic(releaseType, {
|
||||
const GithubReleasePR = releasePlease.getReleasePR()
|
||||
const release = new GithubReleasePR({
|
||||
releaseType,
|
||||
monorepoTags,
|
||||
packageName,
|
||||
path,
|
||||
@@ -65,6 +67,7 @@ async function main () {
|
||||
versionFile,
|
||||
defaultBranch
|
||||
})
|
||||
|
||||
const pr = await release.run()
|
||||
if (pr) {
|
||||
core.setOutput('pr', pr)
|
||||
@@ -76,14 +79,14 @@ function getGitHubRelease () {
|
||||
return GitHubRelease
|
||||
}
|
||||
|
||||
function getReleasePRFactory () {
|
||||
return ReleasePRFactory
|
||||
function getReleasePR () {
|
||||
return ReleasePR
|
||||
}
|
||||
|
||||
const releasePlease = {
|
||||
main,
|
||||
getGitHubRelease,
|
||||
getReleasePRFactory
|
||||
getReleasePR
|
||||
}
|
||||
|
||||
if (require.main === module) {
|
||||
|
||||
1432
package-lock.json
generated
1432
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
10
package.json
10
package.json
@@ -26,14 +26,14 @@
|
||||
"homepage": "https://github.com/bcoe/release-please-action#readme",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.6",
|
||||
"release-please": "^9.3.0"
|
||||
"release-please": "^10.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@zeit/ncc": "^0.22.3",
|
||||
"c8": "^7.3.5",
|
||||
"@vercel/ncc": "^0.27.0",
|
||||
"c8": "^7.5.0",
|
||||
"mocha": "^8.2.1",
|
||||
"sinon": "^9.2.1",
|
||||
"standard": "^14.3.4"
|
||||
"sinon": "^9.2.4",
|
||||
"standard": "^16.0.3"
|
||||
},
|
||||
"standard": {
|
||||
"ignore": "dist/"
|
||||
|
||||
@@ -32,20 +32,28 @@ describe('release-please-action', () => {
|
||||
})
|
||||
return ReleaseStub
|
||||
}
|
||||
const releasePR = sinon.stub().returns(25)
|
||||
const buildStatic = sinon.stub().returns({
|
||||
run: releasePR
|
||||
})
|
||||
action.getReleasePRFactory = () => {
|
||||
return {
|
||||
buildStatic
|
||||
|
||||
let GithubReleasePRStub = sinon.stub()
|
||||
const runStub = sinon.stub().returns(25)
|
||||
|
||||
action.getReleasePR = () => {
|
||||
class GithubReleasePR {
|
||||
run () {}
|
||||
}
|
||||
GithubReleasePRStub = sinon.spy(function () {
|
||||
const instance = sinon.createStubInstance(GithubReleasePR)
|
||||
instance.run = runStub
|
||||
return instance
|
||||
})
|
||||
return GithubReleasePRStub
|
||||
}
|
||||
|
||||
await action.main()
|
||||
|
||||
sinon.assert.calledOnce(createRelease)
|
||||
sinon.assert.calledWith(ReleaseStub, sinon.match.hasOwn('defaultBranch', undefined))
|
||||
sinon.assert.calledWith(buildStatic, 'node', sinon.match.hasOwn('defaultBranch', undefined))
|
||||
sinon.assert.calledOnce(releasePR)
|
||||
sinon.assert.calledOnce(runStub)
|
||||
sinon.assert.calledWith(GithubReleasePRStub, sinon.match.hasOwn('defaultBranch', undefined))
|
||||
assert.deepStrictEqual(output, {
|
||||
release_created: true,
|
||||
upload_url: 'http://example.com',
|
||||
@@ -83,20 +91,28 @@ describe('release-please-action', () => {
|
||||
})
|
||||
return ReleaseStub
|
||||
}
|
||||
const releasePR = sinon.stub().returns(25)
|
||||
const buildStatic = sinon.stub().returns({
|
||||
run: releasePR
|
||||
})
|
||||
action.getReleasePRFactory = () => {
|
||||
return {
|
||||
buildStatic
|
||||
|
||||
let GithubReleasePRStub = sinon.stub()
|
||||
const runStub = sinon.stub().returns(25)
|
||||
|
||||
action.getReleasePR = () => {
|
||||
class GithubReleasePR {
|
||||
run () {}
|
||||
}
|
||||
GithubReleasePRStub = sinon.spy(function () {
|
||||
const instance = sinon.createStubInstance(GithubReleasePR)
|
||||
instance.run = runStub
|
||||
return instance
|
||||
})
|
||||
return GithubReleasePRStub
|
||||
}
|
||||
|
||||
await action.main()
|
||||
|
||||
sinon.assert.calledOnce(createRelease)
|
||||
sinon.assert.calledWith(ReleaseStub, sinon.match.hasOwn('defaultBranch', 'dev'))
|
||||
sinon.assert.calledWith(buildStatic, 'node', sinon.match.hasOwn('defaultBranch', 'dev'))
|
||||
sinon.assert.calledOnce(releasePR)
|
||||
sinon.assert.calledOnce(runStub)
|
||||
sinon.assert.calledWith(GithubReleasePRStub, sinon.match.hasOwn('defaultBranch', 'dev'))
|
||||
assert.deepStrictEqual(output, {
|
||||
release_created: true,
|
||||
upload_url: 'http://example.com',
|
||||
@@ -126,19 +142,25 @@ describe('release-please-action', () => {
|
||||
Release.prototype.createRelease = githubRelease
|
||||
return Release
|
||||
}
|
||||
const releasePR = sinon.stub()
|
||||
action.getReleasePRFactory = () => {
|
||||
return {
|
||||
buildStatic: () => {
|
||||
return {
|
||||
run: releasePR
|
||||
}
|
||||
}
|
||||
|
||||
let GithubReleasePRStub = sinon.stub()
|
||||
const runStub = sinon.stub().returns(25)
|
||||
|
||||
action.getReleasePR = () => {
|
||||
class GithubReleasePR {
|
||||
run () {}
|
||||
}
|
||||
GithubReleasePRStub = sinon.spy(function () {
|
||||
const instance = sinon.createStubInstance(GithubReleasePR)
|
||||
instance.run = runStub
|
||||
return instance
|
||||
})
|
||||
return GithubReleasePRStub
|
||||
}
|
||||
|
||||
await action.main()
|
||||
sinon.assert.notCalled(githubRelease)
|
||||
sinon.assert.calledOnce(releasePR)
|
||||
sinon.assert.calledOnce(runStub)
|
||||
})
|
||||
|
||||
it('only creates GitHub release, if command set to github-release', async () => {
|
||||
@@ -233,15 +255,19 @@ describe('release-please-action', () => {
|
||||
core.getInput = (name) => {
|
||||
return input[name]
|
||||
}
|
||||
const releasePR = sinon.stub().returns(95)
|
||||
action.getReleasePRFactory = () => {
|
||||
return {
|
||||
buildStatic: () => {
|
||||
return {
|
||||
run: releasePR
|
||||
}
|
||||
}
|
||||
let GithubReleasePRStub = sinon.stub()
|
||||
const runStub = sinon.stub().returns(95)
|
||||
|
||||
action.getReleasePR = () => {
|
||||
class GithubReleasePR {
|
||||
run () {}
|
||||
}
|
||||
GithubReleasePRStub = sinon.spy(function () {
|
||||
const instance = sinon.createStubInstance(GithubReleasePR)
|
||||
instance.run = runStub
|
||||
return instance
|
||||
})
|
||||
return GithubReleasePRStub
|
||||
}
|
||||
await action.main()
|
||||
assert.strictEqual(output.pr, 95)
|
||||
@@ -259,15 +285,19 @@ describe('release-please-action', () => {
|
||||
core.getInput = (name) => {
|
||||
return input[name]
|
||||
}
|
||||
const releasePR = sinon.stub().returns(undefined)
|
||||
action.getReleasePRFactory = () => {
|
||||
return {
|
||||
buildStatic: () => {
|
||||
return {
|
||||
run: releasePR
|
||||
}
|
||||
}
|
||||
let GithubReleasePRStub = sinon.stub()
|
||||
const runStub = sinon.stub().returns(undefined)
|
||||
|
||||
action.getReleasePR = () => {
|
||||
class GithubReleasePR {
|
||||
run () {}
|
||||
}
|
||||
GithubReleasePRStub = sinon.spy(function () {
|
||||
const instance = sinon.createStubInstance(GithubReleasePR)
|
||||
instance.run = runStub
|
||||
return instance
|
||||
})
|
||||
return GithubReleasePRStub
|
||||
}
|
||||
await action.main()
|
||||
assert.strictEqual(Object.hasOwnProperty.call(output, 'pr'), false)
|
||||
|
||||
Reference in New Issue
Block a user