diff --git a/.changeset/eighty-parks-tickle.md b/.changeset/eighty-parks-tickle.md new file mode 100644 index 00000000..af67650b --- /dev/null +++ b/.changeset/eighty-parks-tickle.md @@ -0,0 +1,17 @@ +--- +"@changesets/action": major +--- + +Rename the root action inputs and outputs to better match the sub-actions' conventions. + +Inputs: + +- `version` -> `version-script` +- `publish` -> `publish-script` +- `commit` -> `commit-message` +- `title` -> `pr-title` +- `branch` -> `pr-base-branch` + +Outputs: + +- `pull-request-number` -> `pr-number` diff --git a/README.md b/README.md index 24e37bab..62e7dd38 100644 --- a/README.md +++ b/README.md @@ -106,7 +106,7 @@ jobs: uses: changesets/action@v2 with: # This expects you to have a script called release which does a build for your packages and calls changeset publish - publish: pnpm release + publish-script: pnpm release env: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} @@ -217,7 +217,7 @@ jobs: uses: changesets/action@v2 with: # this expects you to have a npm script called version that runs some logic and then calls `changeset version`. - version: pnpm version + version-script: pnpm version ``` #### With Yarn 2 / Plug'n'Play @@ -227,6 +227,6 @@ If you are using [Yarn Plug'n'Play](https://yarnpkg.com/features/pnp), you shoul ```yaml - uses: changesets/action@v2 with: - version: yarn changeset version + version-script: yarn changeset version # ... ``` diff --git a/action.yml b/action.yml index c38f8386..c09e6140 100644 --- a/action.yml +++ b/action.yml @@ -8,25 +8,28 @@ inputs: description: "The GitHub token to use for authentication. Defaults to the GitHub-provided token." required: false default: ${{ github.token }} - publish: + publish-script: description: "The command to use to build and publish packages" required: false - version: + version-script: description: "The command to update version, edit CHANGELOG, read and delete changesets. Default to `changeset version` if not provided" required: false - commit: - description: | - The commit message. Default to `Version Packages` + commit-message: + description: "The commit message. Default to `Version Packages`" required: false - title: - description: The pull request title. Default to `Version Packages` + default: "Version Packages" + pr-title: + description: "The pull request title. Default to `Version Packages`" required: false - setup-git-user: - description: Sets up the git user for commits as `"github-actions[bot]"`. Default to `true` + default: "Version Packages" + pr-draft: + description: "Controls draft PR behavior. Use 'create' to create new version PRs as draft, or 'always' to also convert existing version PRs back to draft when updating them." + required: false + pr-base-branch: + description: "Sets the base branch of the PR. Defaults to `github.ref_name`." required: false - default: true create-github-releases: - description: "A boolean value to indicate whether to create Github releases after `publish` or not" + description: "Whether to create Github releases after publish" required: false default: true commit-mode: @@ -37,12 +40,10 @@ inputs: or app who owns the GITHUB_TOKEN. required: false default: "git-cli" - branch: - description: Sets the branch in which the action will run. Default to `github.ref_name` if not provided - required: false - pr-draft: - description: 'Controls draft PR behavior. Use "create" to create new version PRs as draft, or "always" to also convert existing version PRs back to draft when updating them.' + setup-git-user: + description: Sets up the git user for commits as `"github-actions[bot]"`. Default to `true` required: false + default: true outputs: published: description: A boolean value to indicate whether a publishing is happened or not @@ -51,7 +52,7 @@ outputs: A JSON array to present the published packages. The format is `[{"name": "@xx/xx", "version": "1.2.0"}, {"name": "@xx/xy", "version": "0.8.9"}]` has-changesets: description: A boolean about whether there were changesets. Useful if you want to create your own publishing functionality. - pull-request-number: + pr-number: description: The pull request number that was created or updated branding: icon: "package" diff --git a/src/index.ts b/src/index.ts index 1ce7cafa..7f487e30 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,9 +12,14 @@ import { (async () => { throwOnRenamedInputs({ - commitMode: "commit-mode", - createGithubReleases: "create-github-releases", + publish: "publish-script", + version: "version-script", + commit: "commit-mesage", + title: "pr-title", + branch: "pr-base-branch", prDraft: "pr-draft", + createGithubReleases: "create-github-releases", + commitMode: "commit-mode", setupGitUser: "setup-git-user", }); @@ -55,7 +60,7 @@ import { let { changesets } = await readChangesetState(cwd); - let publishScript = core.getInput("publish"); + let publishScript = core.getInput("publish-script"); let hasChangesets = changesets.length !== 0; const hasNonEmptyChangesets = changesets.some( (changeset) => changeset.releases.length > 0, @@ -156,17 +161,17 @@ import { return; case hasChangesets: { const { pullRequestNumber } = await runVersion({ - script: getOptionalInput("version"), + script: getOptionalInput("version-script"), github, cwd, - prTitle: getOptionalInput("title"), - commitMessage: getOptionalInput("commit"), + prTitle: getOptionalInput("pr-title"), + commitMessage: getOptionalInput("commit-message"), hasPublishScript, prDraft, - branch: getOptionalInput("branch"), + branch: getOptionalInput("pr-base-branch"), }); - core.setOutput("pull-request-number", String(pullRequestNumber)); + core.setOutput("pr-number", String(pullRequestNumber)); return; } diff --git a/src/utils.ts b/src/utils.ts index 6a626e3f..4ad5268c 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -136,13 +136,22 @@ export function getRequiredInput(name: string) { } export function throwOnRenamedInputs(renames: Record) { + const references: Record = {}; + for (const [oldInput, newInput] of Object.entries(renames)) { if (core.getInput(oldInput)) { - throw new Error( - `The input "${oldInput}" has been renamed to "${newInput}". Please update your workflow file.`, - ); + references[oldInput] = newInput; } } + + if (Object.keys(references).length > 0) { + const list = Object.entries(references) + .map(([oldInput, newInput]) => `- "${oldInput}" -> "${newInput}"`) + .join("\n"); + throw new Error( + `The following inputs have been renamed:\n${list}\nPlease update your workflow file.`, + ); + } } function resolveChangesetsCli(cwd: string) { diff --git a/version/action.yml b/version/action.yml index 752f04a0..d8ab725e 100644 --- a/version/action.yml +++ b/version/action.yml @@ -37,7 +37,9 @@ inputs: description: Sets up the git user for commits as `"github-actions[bot]"`. Default to `true` required: false default: true -outputs: {} +outputs: + pr-number: + description: The pull request number that was created or updated branding: icon: package color: blue