Skip to content

Commit

Permalink
feat(manifest): add manifest-pr command (#280)
Browse files Browse the repository at this point in the history
  • Loading branch information
bcoe committed Mar 25, 2021
1 parent 10ca9ee commit f48a175
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -55,7 +55,7 @@ Automate releases with Conventional Commit Messages.
| `changelog-types` | A JSON formatted String containing to override the outputted changelog sections |
| `version-file` | provide a path to a version file to increment (used by ruby releaser) |
| `fork` | Should the PR be created from a fork. Default `false`|
| `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`, `manifest`, `manifest-pr` (_defaults to running both_) |
| `default-branch` | branch to open pull release PR against (detected by default) |
| `pull-request-title-pattern` | title pattern used to make release PR, defaults to using `chore${scope}: release${component} ${version}`. |

Expand Down
9 changes: 5 additions & 4 deletions index.js
Expand Up @@ -3,7 +3,7 @@ const { factory } = require('release-please/build/src')

const CONFIG_FILE = 'release-please-config.json'
const MANIFEST_FILE = '.release-please-manifest.json'
const MANIFEST_COMMAND = 'manifest'
const MANIFEST_COMMANDS = ['manifest', 'manifest-pr']
const RELEASE_LABEL = 'autorelease: pending'
const GITHUB_RELEASE_COMMAND = 'github-release'
const GITHUB_RELEASE_PR_COMMAND = 'release-pr'
Expand Down Expand Up @@ -34,13 +34,14 @@ function getManifestInput () {
}
}

async function runManifest () {
async function runManifest (command) {
const githubOpts = getGitHubInput()
const manifestOpts = { ...githubOpts, ...getManifestInput() }
const pr = await factory.runCommand('manifest-pr', manifestOpts)
if (pr) {
core.setOutput('pr', pr)
}
if (command === 'manifest-pr') return

const releasesCreated = await factory.runCommand('manifest-release', manifestOpts)
if (releasesCreated) {
Expand All @@ -58,8 +59,8 @@ async function runManifest () {

async function main () {
const command = core.getInput('command') || undefined
if (command === MANIFEST_COMMAND) {
return await runManifest()
if (MANIFEST_COMMANDS.includes(command)) {
return await runManifest(command)
}

const { token, fork, defaultBranch, apiUrl, repoUrl } = getGitHubInput()
Expand Down
14 changes: 14 additions & 0 deletions test/release-please.js
Expand Up @@ -361,4 +361,18 @@ describe('release-please-action', () => {
pr: 25
})
})

it('opens PR only for manifest-pr', async () => {
input = { command: 'manifest-pr' }

const runCommandStub = sandbox.stub(factory, 'runCommand')
const manifestReleasePRStub = runCommandStub.withArgs('manifest-pr').returns(25)

await action.main()

sinon.assert.calledOnce(manifestReleasePRStub)
assert.deepStrictEqual(output, {
pr: 25
})
})
})

0 comments on commit f48a175

Please sign in to comment.