From 44827541d2a562fef8aedc1379c814c04f0ad482 Mon Sep 17 00:00:00 2001 From: Andrew Sweet Date: Wed, 10 Aug 2022 19:08:25 +0100 Subject: [PATCH] feat: provide inputs for releaser and manifest options in release-please 13.15 (#474) * Synchronised action inputs with ReleaserConfig and ManifestOptions from release-please 13.15.0 * fix conflict from merge * fix merge issue * fix merge issue Co-authored-by: Benjamin E. Coe Co-authored-by: Jeff Ching --- README.md | 65 ++++++++++++++++++++---------- action.yml | 70 ++++++++++++++++++++++++++++++++ index.js | 50 ++++++++++++++++++++++- test/release-please.js | 91 +++++++++++++++++++++++++++++++++++++----- 4 files changed, 243 insertions(+), 33 deletions(-) diff --git a/README.md b/README.md index 6e9edfc..26a304c 100644 --- a/README.md +++ b/README.md @@ -44,27 +44,50 @@ Automate releases with Conventional Commit Messages. ## Configuration -| input | description | -|:---:|---| -| `token` | A GitHub secret token, the action defaults to using the special `secrets.GITHUB_TOKEN` | -| `release-type` | What type of project is this a release for? Reference [Release types supported](#release-types-supported); new types of releases can be [added here](https://github.com/googleapis/release-please/tree/main/src/strategies) | -| `package-name` | A name for the artifact releases are being created for (this might be the `name` field in a `setup.py` or `package.json`) | -| `bump-minor-pre-major` | Should breaking changes before 1.0.0 produce minor bumps? Default `false` | -| `bump-patch-for-minor-pre-major` | Should feat changes before 1.0.0 produce patch bumps instead of minor bumps? Default `false` | -| `path` | create a release from a path other than the repository's root | -| `monorepo-tags` | add prefix to tags and branches, allowing multiple libraries to be released from the same repository. | -| `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) | -| `extra-files` | add extra-files to bump using the [generic updater](https://github.com/googleapis/release-please/blob/main/docs/customizing.md#updating-arbitrary-files) | -| `fork` | Should the PR be created from a fork. Default `false`| -| `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}`. | -| `changelog-path` | configure alternate path for `CHANGELOG.md`. Default `CHANGELOG.md` | -| `github-api-url` | configure github API URL. Default `https://api.github.com` | -| `--signoff` | Add [`Signed-off-by`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---signoff) line at the end of the commit log message using the user and email provided. (format "Name \") | -| `repo-url` | configure github repository URL. Default `process.env.GITHUB_REPOSITORY` | -| `github-graphql-url` | configure github GraphQL URL. Default `https://api.github.com` | +| input | description | +|:----------------------------------:|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| +| `token` | A GitHub secret token, the action defaults to using the special `secrets.GITHUB_TOKEN` | +| `release-type` | What type of project is this a release for? Reference [Release types supported](#release-types-supported); new types of releases can be [added here](https://github.com/googleapis/release-please/tree/main/src/strategies) | +| `package-name` | A name for the artifact releases are being created for (this might be the `name` field in a `setup.py` or `package.json`) | +| `bump-minor-pre-major` | Should breaking changes before 1.0.0 produce minor bumps? Default `false` | +| `bump-patch-for-minor-pre-major` | Should feat changes before 1.0.0 produce patch bumps instead of minor bumps? Default `false` | +| `path` | create a release from a path other than the repository's root | +| `monorepo-tags` | add prefix to tags and branches, allowing multiple libraries to be released from the same repository. | +| `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) | +| `extra-files` | add extra-files to bump using the [generic updater](https://github.com/googleapis/release-please/blob/main/docs/customizing.md#updating-arbitrary-files) | +| `fork` | Should the PR be created from a fork. Default `false` | +| `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}`. | +| `changelog-path` | configure alternate path for `CHANGELOG.md`. Default `CHANGELOG.md` | +| `github-api-url` | configure github API URL. Default `https://api.github.com` | +| `signoff` | Add [`Signed-off-by`](https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---signoff) line at the end of the commit log message using the user and email provided. (format "Name \") | +| `repo-url` | configure github repository URL. Default `process.env.GITHUB_REPOSITORY` | +| `github-graphql-url` | configure github GraphQL URL. Default `https://api.github.com` | +| `changelog-notes-type` | Strategy for building the [changelog contents](https://github.com/googleapis/release-please/blob/main/docs/customizing.md#changelog-types). Default `default`. Called `changelog-type` in release-please documentation. | + | `changelog-host` | Host for commit hyperlinks in the changelog. Default `https://github.com` | +| `versioning-strategy` | Override [method of determining SemVer version bumps based on commits](https://github.com/googleapis/release-please/blob/main/docs/customizing.md#versioning-strategies). Default `default` | + | `release-as` | manually set version to this value, ignoring conventional commits. Absence defaults to conventional commits derived next version. Once the release PR is merged you should either remove this or update it to a higher version. Otherwise subsequent `manifest-pr` runs will continue to use this version even though it was already set in the last release. | + | `skip-github-release` | Skip creating GitHub Releases. Default `false` | +| `prerelease` | If set, create releases that are pre-major or pre-release version marked as pre-release on Github. Defaults `false` | + | `component` | Name of the component used for branch naming and release tagging. Defaults to a normalized version based on the package name | + | `include-v-in-tag` | include "v" in tag versions. Default `true` | + | `tag-separator` | configures separator character used in release tag | + | `snapshot-labels` | sets java snapshot pull request labels other than `autorelease: snapshot` | + | `bootstrap-sha` | if this is the first time running `manifest-pr` on a repo this key will limit how far back (exclusive) to pull commits for conventional commit parsing, see (the manifest releaser docs)[https://github.com/googleapis/release-please/blob/main/docs/manifest-releaser.md] | + | `last-release-sha` | overrides the commit sha release-please will use from which to gather commits for the current release, see (the manifest releaser docs)[https://github.com/googleapis/release-please/blob/main/docs/manifest-releaser.md] | + | `always-link-local` | when using the `node-workspace` plugin, setting to false will only bump your local dependencies within the SemVer range, see (the manifest releaser docs)[https://github.com/googleapis/release-please/blob/main/docs/manifest-releaser.md] . Default `true`. | + | `separate-pull-requests` | create separate pull requests for each package instead of a single manifest release pull request, see (the manifest releaser docs)[https://github.com/googleapis/release-please/blob/main/docs/manifest-releaser.md]. Default `false`. | + | `plugins` | see https://github.com/googleapis/release-please/blob/main/docs/manifest-releaser.md#plugins | + | `labels` | list of labels to apply to the release pull requests, defaults to `autorelease: pending` | +| `release-labels` | set a pull request label other than `autorelease: tagged` | + | `skip-labeling` | if set, labels will not be applied to pull requests. Default `false`. | + | `sequential-calls` | issue GitHub API requests sequentially rather than concurrently, see (the manifest releaser docs)[https://github.com/googleapis/release-please/blob/main/docs/manifest-releaser.md]. Default `false` | + | `group-pull-request-title-pattern` | sets the manifest pull request title for when releasing multiple packages grouped together in the one pull request | + | `release-search-depth` | when searching for the latest release SHAs, only consider the last N releases | + | `commit-search-depth` | when fetching the list of commits to consider, only consider the last N commits | + ### The `command` option Some additional info regarding the `command` property. diff --git a/action.yml b/action.yml index 94a285e..2536c19 100644 --- a/action.yml +++ b/action.yml @@ -100,6 +100,76 @@ inputs: description: 'mark pull request as a draft' required: false default: false + changelog-notes-type: + description: "Strategy for building the changelog contents(see https://github.com/googleapis/release-please/blob/main/docs/customizing.md#changelog-types). Default `default`. Called `changelog-type` in release-please documentation." + required: false + versioning-strategy: + description: 'Override method of determining SemVer version bumps based on commits (drr https://github.com/googleapis/release-please/blob/main/docs/customizing.md#versioning-strategies). Default `default`' + required: false + release-as: + description: 'manually set version to this value, ignoring conventional commits. Absence defaults to conventional commits derived next version. Once the release PR is merged you should either remove this or update it to a higher version. Otherwise subsequent `manifest-pr` runs will continue to use this version even though it was already set in the last release.' + required: false + skip-github-release: + description: 'Skip creating GitHub Releases. Default `false`' + required: false + default: false + prerelease: + description: 'If set, create releases that are pre-major or pre-release version marked as pre-release on Github. Defaults `false`' + required: false + default: false + component: + description: 'name of the component used for branch naming and release tagging, defaults to a normalized version based on the package name' + required: false + include-v-in-tag: + description: 'include "v" in tag versions. Default `true`' + required: false + default: true + tag-separator: + description: 'configures separator character used in release tag' + required: false + snapshot-labels: + description: 'sets java snapshot pull request labels other than `autorelease: snapshot` ' + required: false + bootstrap-sha: + description: 'if this is the first time running `manifest-pr` on a repo this key will limit how far back (exclusive) to pull commits for conventional commit parsing (see the manifest releaser docs https://github.com/googleapis/release-please/blob/main/docs/manifest-releaser.md)' + required: false + last-release-sha: + description: 'overrides the commit sha release-please will use from which to gather commits for the current release (see the manifest releaser docs https://github.com/googleapis/release-please/blob/main/docs/manifest-releaser.md)' + required: false + always-link-local: + description: 'when using the `node-workspace` plugin, setting to false will only bump your local dependencies within the SemVer range (see the manifest releaser docs)[https://github.com/googleapis/release-please/blob/main/docs/manifest-releaser.md) . Default `true`.' + required: false + default: true + separate-pull-requests: + description: 'create separate pull requests for each package instead of a single manifest release pull request (see the manifest releaser docs https://github.com/googleapis/release-please/blob/main/docs/manifest-releaser.md). Default `false`.' + required: false + default: false + plugins: + description: 'see https://github.com/googleapis/release-please/blob/main/docs/manifest-releaser.md#plugins' + required: false + labels: + description: 'list of labels to apply to the release pull requests, defaults to `autorelease: pending`' + required: false + release-labels: + description: 'set a pull request label other than `autorelease: tagged`' + required: false + skip-labeling: + description: 'if set, labels will not be applied to pull requests. Default `false`.' + required: false + default: false + sequential-calls: + description: 'issue GitHub API requests sequentially rather than concurrently (see the manifest releaser docs https://github.com/googleapis/release-please/blob/main/docs/manifest-releaser.md). Default `false`' + required: false + default: false + group-pull-request-title-pattern: + description: 'sets the manifest pull request title for when releasing multiple packages grouped together in the one pull request' + required: false + release-search-depth: + description: 'when searching for the latest release SHAs, only consider the last N releases' + required: false + commit-search-depth: + description: 'when fetching the list of commits to consider, only consider the last N commits' + required: false runs: using: 'node12' diff --git a/index.js b/index.js index 56e1e0c..bc50326 100644 --- a/index.js +++ b/index.js @@ -121,6 +121,27 @@ async function manifestInstance (github) { const pullRequestTitlePattern = core.getInput('pull-request-title-pattern') || undefined const draft = core.getBooleanInput('draft') const draftPullRequest = core.getBooleanInput('draft-pull-request') + const changelogType = core.getInput('changelog-notes-type') || undefined + const versioning = core.getInput('versioning-strategy') || undefined + const releaseAs = core.getInput('release-as') || undefined + const skipGithubRelease = core.getBooleanInput('skip-github-release') + const prerelease = core.getBooleanInput('prerelease') + const component = core.getInput('component') || undefined + const includeVInTag = core.getBooleanInput('include-v-in-tag') + const tagSeparator = core.getInput('tag-separator') || undefined + const snapshotLabels = core.getMultilineInput('snapshot-labels') || undefined + const bootstrapSha = core.getInput('bootstrap-sha') || undefined + const lastReleaseSha = core.getInput('last-release-sha') || undefined + const alwaysLinkLocal = core.getBooleanInput('always-link-local') + const separatePullRequests = core.getBooleanInput('separate-pull-requests') + const plugins = core.getMultilineInput('plugins') || undefined + const labels = core.getMultilineInput('labels') || undefined + const releaseLabels = core.getMultilineInput('release-labels') || undefined + const skipLabeling = core.getBooleanInput('skip-labeling') + const sequentialCalls = core.getBooleanInput('sequential-calls') + const groupPullRequestTitlePattern = core.getInput('group-pull-request-title-pattern') || undefined + const releaseSearchDepth = core.getInput('release-search-depth') || undefined + const commitSearchDepth = core.getInput('commit-search-depth') || undefined return await Manifest.fromConfig( github, github.repository.defaultBranch, @@ -136,12 +157,37 @@ async function manifestInstance (github) { extraFiles, includeComponentInTag: monorepoTags, pullRequestTitlePattern, - draftPullRequest + draftPullRequest, + versioning, + releaseAs, + skipGithubRelease, + draft, + prerelease, + component, + includeVInTag, + tagSeparator, + changelogType, + snapshotLabels }, { draft, signoff, - fork + fork, + draftPullRequest, + bootstrapSha, + lastReleaseSha, + alwaysLinkLocal, + separatePullRequests, + plugins, + labels, + releaseLabels, + snapshotLabels, + skipLabeling, + sequentialCalls, + prerelease, + groupPullRequestTitlePattern, + releaseSearchDepth, + commitSearchDepth }, path ) diff --git a/test/release-please.js b/test/release-please.js index 688237c..c565e47 100644 --- a/test/release-please.js +++ b/test/release-please.js @@ -94,7 +94,14 @@ describe('release-please-action', () => { command: 'release-pr', 'release-type': 'node', 'changelog-types': - '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false}]' + '[{"type":"feat","section":"Features","hidden":false},{"type":"fix","section":"Bug Fixes","hidden":false},{"type":"chore","section":"Miscellaneous","hidden":false}]', + 'skip-github-release': 'false', + prerelease: 'false', + 'include-v-in-tag': 'true', + 'always-link-local': 'true', + 'separate-pull-requests': 'false', + 'skip-labeling': 'false', + 'sequential-calls': 'false' } const createPullRequestsFake = sandbox.fake.returns([fixturePrs[0]]) @@ -122,7 +129,14 @@ describe('release-please-action', () => { input = { command: 'release-pr', 'release-type': 'node', - 'pull-request-title-pattern': 'beep boop' + 'pull-request-title-pattern': 'beep boop', + 'skip-github-release': 'false', + prerelease: 'false', + 'include-v-in-tag': 'true', + 'always-link-local': 'true', + 'separate-pull-requests': 'false', + 'skip-labeling': 'false', + 'sequential-calls': 'false' } const createPullRequestsFake = sandbox.fake.returns([fixturePrs[0]]) @@ -145,7 +159,15 @@ describe('release-please-action', () => { }) it('both opens PR to the default branch and tags GitHub releases by default', async () => { - input = {} + input = { + 'skip-github-release': 'false', + prerelease: 'false', + 'include-v-in-tag': 'true', + 'always-link-local': 'true', + 'separate-pull-requests': 'false', + 'skip-labeling': 'false', + 'sequential-calls': 'false' + } const createReleasesFake = sandbox.fake.returns([ { @@ -177,7 +199,14 @@ describe('release-please-action', () => { it('both opens PR to a different default branch and tags GitHub releases by default', async () => { input = { - 'default-branch': 'dev' + 'default-branch': 'dev', + 'skip-github-release': 'false', + prerelease: 'false', + 'include-v-in-tag': 'true', + 'always-link-local': 'true', + 'separate-pull-requests': 'false', + 'skip-labeling': 'false', + 'sequential-calls': 'false' } const createReleasesFake = sandbox.fake.returns([ @@ -216,7 +245,14 @@ describe('release-please-action', () => { it('only opens PR, if command set to release-pr', async () => { input = { - command: 'release-pr' + command: 'release-pr', + 'skip-github-release': 'false', + prerelease: 'false', + 'include-v-in-tag': 'true', + 'always-link-local': 'true', + 'separate-pull-requests': 'false', + 'skip-labeling': 'false', + 'sequential-calls': 'false' } const createReleasesFake = sandbox.fake.returns([ @@ -244,7 +280,14 @@ describe('release-please-action', () => { it('only creates GitHub release, if command set to github-release', async () => { input = { - command: 'github-release' + command: 'github-release', + 'skip-github-release': 'false', + prerelease: 'false', + 'include-v-in-tag': 'true', + 'always-link-local': 'true', + 'separate-pull-requests': 'false', + 'skip-labeling': 'false', + 'sequential-calls': 'false' } const createReleasesFake = sandbox.fake.returns([ @@ -289,7 +332,14 @@ describe('release-please-action', () => { } input = { 'release-type': 'node', - command: 'github-release' + command: 'github-release', + 'skip-github-release': 'false', + prerelease: 'false', + 'include-v-in-tag': 'true', + 'always-link-local': 'true', + 'separate-pull-requests': 'false', + 'skip-labeling': 'false', + 'sequential-calls': 'false' } const createReleasesFake = sandbox.fake.returns([release]) sandbox.stub(Manifest, 'fromConfig').returns({ @@ -312,7 +362,14 @@ describe('release-please-action', () => { it('sets appropriate outputs when release PR opened', async () => { input = { 'release-type': 'node', - command: 'release-pr' + command: 'release-pr', + 'skip-github-release': 'false', + prerelease: 'false', + 'include-v-in-tag': 'true', + 'always-link-local': 'true', + 'separate-pull-requests': 'false', + 'skip-labeling': 'false', + 'sequential-calls': 'false' } const createPullRequestsFake = sandbox.fake.returns([fixturePrs[0]]) const createManifestCommand = sandbox.stub(Manifest, 'fromConfig').returns({ @@ -332,7 +389,14 @@ describe('release-please-action', () => { it('does not set PR output, when no release PR is returned', async () => { input = { 'release-type': 'node', - command: 'release-pr' + command: 'release-pr', + 'skip-github-release': 'false', + prerelease: 'false', + 'include-v-in-tag': 'true', + 'always-link-local': 'true', + 'separate-pull-requests': 'false', + 'skip-labeling': 'false', + 'sequential-calls': 'false' } const createPullRequestsFake = sandbox.fake.returns([undefined]) const createManifestCommand = sandbox.stub(Manifest, 'fromConfig').returns({ @@ -347,7 +411,14 @@ describe('release-please-action', () => { it('does not set release output, when no release is returned', async () => { input = { 'release-type': 'node', - command: 'github-release' + command: 'github-release', + 'skip-github-release': 'false', + prerelease: 'false', + 'include-v-in-tag': 'true', + 'always-link-local': 'true', + 'separate-pull-requests': 'false', + 'skip-labeling': 'false', + 'sequential-calls': 'false' } const createReleasesFake = sandbox.fake.returns([undefined]) sandbox.stub(Manifest, 'fromConfig').returns({