mirror of
https://github.com/joaquinjsb/gitea-release-please-action
synced 2026-05-13 13:31:36 +02:00
feat(release-please): add default branch input option (#202)
This commit is contained in:
@@ -46,6 +46,7 @@ Automate releases with Conventional Commit Messages.
|
|||||||
| `version-file` | provide a path to a version file to increment (used by ruby releaser) |
|
| `version-file` | provide a path to a version file to increment (used by ruby releaser) |
|
||||||
| `fork` | Should the PR be created from a fork (does not work with `secrets.GITHUB_TOKEN`) |
|
| `fork` | Should the PR be created from a fork (does not work with `secrets.GITHUB_TOKEN`) |
|
||||||
| `command` | release-please command to run, either `github-release`, or `release-pr` (_defaults to running both_) |
|
| `command` | release-please command to run, either `github-release`, or `release-pr` (_defaults to running both_) |
|
||||||
|
| `default-branch` | branch to open pull release PR against (detected by default) |
|
||||||
|
|
||||||
| output | description |
|
| output | description |
|
||||||
|:---:|---|
|
|:---:|---|
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ inputs:
|
|||||||
version-file:
|
version-file:
|
||||||
description: 'provide a path to a version file to increment (used by ruby releaser)'
|
description: 'provide a path to a version file to increment (used by ruby releaser)'
|
||||||
required: false
|
required: false
|
||||||
|
default-branch:
|
||||||
|
description: 'branch to open pull release PR against (detected by default)'
|
||||||
|
required: false
|
||||||
runs:
|
runs:
|
||||||
using: 'node12'
|
using: 'node12'
|
||||||
main: 'dist/index.js'
|
main: 'dist/index.js'
|
||||||
|
|||||||
4
index.js
4
index.js
@@ -16,6 +16,7 @@ async function main () {
|
|||||||
const changelogTypes = core.getInput('changelog-types')
|
const changelogTypes = core.getInput('changelog-types')
|
||||||
const command = core.getInput('command') ? core.getInput('command') : undefined
|
const command = core.getInput('command') ? core.getInput('command') : undefined
|
||||||
const versionFile = core.getInput('version-file') ? core.getInput('version-file') : 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
|
// Parse the changelogTypes if there are any
|
||||||
let changelogSections
|
let changelogSections
|
||||||
@@ -60,7 +61,8 @@ async function main () {
|
|||||||
label: RELEASE_LABEL,
|
label: RELEASE_LABEL,
|
||||||
bumpMinorPreMajor,
|
bumpMinorPreMajor,
|
||||||
changelogSections,
|
changelogSections,
|
||||||
versionFile
|
versionFile,
|
||||||
|
defaultBranch
|
||||||
})
|
})
|
||||||
const pr = await release.run()
|
const pr = await release.run()
|
||||||
if (pr) {
|
if (pr) {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const core = require('@actions/core')
|
|||||||
const sinon = require('sinon')
|
const sinon = require('sinon')
|
||||||
|
|
||||||
describe('release-please-action', () => {
|
describe('release-please-action', () => {
|
||||||
it('both opens PR and tags GitHub releases by default', async () => {
|
it('both opens PR to the default branch and tags GitHub releases by default', async () => {
|
||||||
const output = {}
|
const output = {}
|
||||||
core.setOutput = (name, value) => {
|
core.setOutput = (name, value) => {
|
||||||
output[name] = value
|
output[name] = value
|
||||||
@@ -26,17 +26,59 @@ describe('release-please-action', () => {
|
|||||||
return Release
|
return Release
|
||||||
}
|
}
|
||||||
const releasePR = sinon.stub().returns(25)
|
const releasePR = sinon.stub().returns(25)
|
||||||
|
const buildStatic = sinon.stub().returns({
|
||||||
|
run: releasePR
|
||||||
|
})
|
||||||
action.getReleasePRFactory = () => {
|
action.getReleasePRFactory = () => {
|
||||||
return {
|
return {
|
||||||
buildStatic: () => {
|
buildStatic
|
||||||
return {
|
|
||||||
run: releasePR
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await action.main()
|
await action.main()
|
||||||
sinon.assert.calledOnce(createRelease)
|
sinon.assert.calledOnce(createRelease)
|
||||||
|
sinon.assert.calledWith(buildStatic, 'node', sinon.match.hasOwn('defaultBranch', undefined))
|
||||||
|
sinon.assert.calledOnce(releasePR)
|
||||||
|
assert.deepStrictEqual(output, {
|
||||||
|
release_created: true,
|
||||||
|
upload_url: 'http://example.com',
|
||||||
|
tag_name: 'v1.0.0',
|
||||||
|
pr: 25
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
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.calledWith(buildStatic, 'node', sinon.match.hasOwn('defaultBranch', 'dev'))
|
||||||
sinon.assert.calledOnce(releasePR)
|
sinon.assert.calledOnce(releasePR)
|
||||||
assert.deepStrictEqual(output, {
|
assert.deepStrictEqual(output, {
|
||||||
release_created: true,
|
release_created: true,
|
||||||
|
|||||||
Reference in New Issue
Block a user