Skip to content

Commit 18a5426

Browse files
committed
feat(release-please): add default branch input option
1 parent a9e0f67 commit 18a5426

3 files changed

Lines changed: 61 additions & 1 deletion

File tree

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ inputs:
3838
version-file:
3939
description: 'provide a path to a version file to increment (used by ruby releaser)'
4040
required: false
41+
default-branch:
42+
description: 'branch to open pull release PR against (detected by default)'
43+
required: false
4144
runs:
4245
using: 'node12'
4346
main: 'dist/index.js'

index.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ async function main () {
1616
const changelogTypes = core.getInput('changelog-types')
1717
const command = core.getInput('command') ? core.getInput('command') : undefined
1818
const versionFile = core.getInput('version-file') ? core.getInput('version-file') : undefined
19+
const defaultBranch = core.getInput('default-branch') ? core.getInput('default-branch') : undefined
1920

2021
// Parse the changelogTypes if there are any
2122
let changelogSections
@@ -60,7 +61,8 @@ async function main () {
6061
label: RELEASE_LABEL,
6162
bumpMinorPreMajor,
6263
changelogSections,
63-
versionFile
64+
versionFile,
65+
defaultBranch
6466
})
6567
const pr = await release.run()
6668
if (pr) {

test/release-please.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,61 @@ describe('release-please-action', () => {
4646
})
4747
})
4848

49+
it('both opens PR to a different default branch and tags GitHub releases by default', async () => {
50+
const output = {}
51+
core.setOutput = (name, value) => {
52+
output[name] = value
53+
}
54+
const input = {
55+
'release-type': 'node',
56+
'default-branch': 'dev'
57+
}
58+
core.getInput = (name) => {
59+
return input[name]
60+
}
61+
const createRelease = sinon.stub().returns({
62+
upload_url: 'http://example.com',
63+
tag_name: 'v1.0.0'
64+
})
65+
action.getGitHubRelease = () => {
66+
class Release {}
67+
Release.prototype.createRelease = createRelease
68+
return Release
69+
}
70+
const releasePR = sinon.stub().returns(25)
71+
const buildStatic = sinon.stub().returns({
72+
run: releasePR
73+
})
74+
action.getReleasePRFactory = () => {
75+
return {
76+
buildStatic
77+
}
78+
}
79+
await action.main()
80+
sinon.assert.calledOnce(createRelease)
81+
sinon.assert.calledOnce(releasePR)
82+
sinon.assert.calledWith(buildStatic, 'node', {
83+
apiUrl: 'https://api.github.com',
84+
bumpMinorPreMajor: false,
85+
changelogSections: undefined,
86+
defaultBranch: 'dev',
87+
fork: undefined,
88+
label: 'autorelease: pending',
89+
monorepoTags: false,
90+
packageName: undefined,
91+
path: undefined,
92+
repoUrl: undefined,
93+
token: undefined,
94+
versionFile: undefined
95+
})
96+
assert.deepStrictEqual(output, {
97+
release_created: true,
98+
upload_url: 'http://example.com',
99+
tag_name: 'v1.0.0',
100+
pr: 25
101+
})
102+
})
103+
49104
it('only opens PR, if command set to release-pr', async () => {
50105
const output = {}
51106
core.setOutput = (name, value) => {

0 commit comments

Comments
 (0)