Skip to content

Commit

Permalink
feat(release-please): add default branch input option
Browse files Browse the repository at this point in the history
  • Loading branch information
pragmaticivan committed Jan 29, 2021
1 parent a9e0f67 commit 18a5426
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ inputs:
version-file:
description: 'provide a path to a version file to increment (used by ruby releaser)'
required: false
default-branch:
description: 'branch to open pull release PR against (detected by default)'
required: false
runs:
using: 'node12'
main: 'dist/index.js'
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ async function main () {
const changelogTypes = core.getInput('changelog-types')
const command = core.getInput('command') ? core.getInput('command') : undefined
const versionFile = core.getInput('version-file') ? core.getInput('version-file') : undefined
const defaultBranch = core.getInput('default-branch') ? core.getInput('default-branch') : undefined

// Parse the changelogTypes if there are any
let changelogSections
Expand Down Expand Up @@ -60,7 +61,8 @@ async function main () {
label: RELEASE_LABEL,
bumpMinorPreMajor,
changelogSections,
versionFile
versionFile,
defaultBranch
})
const pr = await release.run()
if (pr) {
Expand Down
55 changes: 55 additions & 0 deletions test/release-please.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,61 @@ describe('release-please-action', () => {
})
})

it('both opens PR to a different default branch and tags GitHub releases by default', async () => {
const output = {}
core.setOutput = (name, value) => {
output[name] = value
}
const input = {
'release-type': 'node',
'default-branch': 'dev'
}
core.getInput = (name) => {
return input[name]
}
const createRelease = sinon.stub().returns({
upload_url: 'http://example.com',
tag_name: 'v1.0.0'
})
action.getGitHubRelease = () => {
class Release {}
Release.prototype.createRelease = createRelease
return Release
}
const releasePR = sinon.stub().returns(25)
const buildStatic = sinon.stub().returns({
run: releasePR
})
action.getReleasePRFactory = () => {
return {
buildStatic
}
}
await action.main()
sinon.assert.calledOnce(createRelease)
sinon.assert.calledOnce(releasePR)
sinon.assert.calledWith(buildStatic, 'node', {
apiUrl: 'https://api.github.com',
bumpMinorPreMajor: false,
changelogSections: undefined,
defaultBranch: 'dev',
fork: undefined,
label: 'autorelease: pending',
monorepoTags: false,
packageName: undefined,
path: undefined,
repoUrl: undefined,
token: undefined,
versionFile: undefined
})
assert.deepStrictEqual(output, {
release_created: true,
upload_url: 'http://example.com',
tag_name: 'v1.0.0',
pr: 25
})
})

it('only opens PR, if command set to release-pr', async () => {
const output = {}
core.setOutput = (name, value) => {
Expand Down

0 comments on commit 18a5426

Please sign in to comment.