Rename root action inputs and outputs (#681)

This commit is contained in:
Bjorn Lu
2026-07-01 12:08:50 +00:00
committed by GitHub
parent f71ae043ed
commit 73591071e6
6 changed files with 66 additions and 32 deletions
+17
View File
@@ -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`
+3 -3
View File
@@ -106,7 +106,7 @@ jobs:
uses: changesets/action@v2 uses: changesets/action@v2
with: with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish # 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: env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
@@ -217,7 +217,7 @@ jobs:
uses: changesets/action@v2 uses: changesets/action@v2
with: with:
# this expects you to have a npm script called version that runs some logic and then calls `changeset version`. # 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 #### 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 ```yaml
- uses: changesets/action@v2 - uses: changesets/action@v2
with: with:
version: yarn changeset version version-script: yarn changeset version
# ... # ...
``` ```
+18 -17
View File
@@ -8,25 +8,28 @@ inputs:
description: "The GitHub token to use for authentication. Defaults to the GitHub-provided token." description: "The GitHub token to use for authentication. Defaults to the GitHub-provided token."
required: false required: false
default: ${{ github.token }} default: ${{ github.token }}
publish: publish-script:
description: "The command to use to build and publish packages" description: "The command to use to build and publish packages"
required: false required: false
version: version-script:
description: "The command to update version, edit CHANGELOG, read and delete changesets. Default to `changeset version` if not provided" description: "The command to update version, edit CHANGELOG, read and delete changesets. Default to `changeset version` if not provided"
required: false required: false
commit: commit-message:
description: | description: "The commit message. Default to `Version Packages`"
The commit message. Default to `Version Packages`
required: false required: false
title: default: "Version Packages"
description: The pull request title. Default to `Version Packages` pr-title:
description: "The pull request title. Default to `Version Packages`"
required: false required: false
setup-git-user: default: "Version Packages"
description: Sets up the git user for commits as `"github-actions[bot]"`. Default to `true` 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 required: false
default: true
create-github-releases: 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 required: false
default: true default: true
push-git-tags: push-git-tags:
@@ -43,12 +46,10 @@ inputs:
or app who owns the GITHUB_TOKEN. or app who owns the GITHUB_TOKEN.
required: false required: false
default: "git-cli" default: "git-cli"
branch: setup-git-user:
description: Sets the branch in which the action will run. Default to `github.ref_name` if not provided description: Sets up the git user for commits as `"github-actions[bot]"`. Default to `true`
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.'
required: false required: false
default: true
outputs: outputs:
published: published:
description: A boolean value to indicate whether a publishing is happened or not description: A boolean value to indicate whether a publishing is happened or not
@@ -57,7 +58,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"}]` 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: has-changesets:
description: A boolean about whether there were changesets. Useful if you want to create your own publishing functionality. 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 description: The pull request number that was created or updated
branding: branding:
icon: "package" icon: "package"
+13 -8
View File
@@ -12,9 +12,14 @@ import {
(async () => { (async () => {
throwOnRenamedInputs({ throwOnRenamedInputs({
commitMode: "commit-mode", publish: "publish-script",
createGithubReleases: "create-github-releases", version: "version-script",
commit: "commit-mesage",
title: "pr-title",
branch: "pr-base-branch",
prDraft: "pr-draft", prDraft: "pr-draft",
createGithubReleases: "create-github-releases",
commitMode: "commit-mode",
setupGitUser: "setup-git-user", setupGitUser: "setup-git-user",
}); });
@@ -55,7 +60,7 @@ import {
let { changesets } = await readChangesetState(cwd); let { changesets } = await readChangesetState(cwd);
let publishScript = core.getInput("publish"); let publishScript = core.getInput("publish-script");
let hasChangesets = changesets.length !== 0; let hasChangesets = changesets.length !== 0;
const hasNonEmptyChangesets = changesets.some( const hasNonEmptyChangesets = changesets.some(
(changeset) => changeset.releases.length > 0, (changeset) => changeset.releases.length > 0,
@@ -168,17 +173,17 @@ import {
return; return;
case hasChangesets: { case hasChangesets: {
const { pullRequestNumber } = await runVersion({ const { pullRequestNumber } = await runVersion({
script: getOptionalInput("version"), script: getOptionalInput("version-script"),
github, github,
cwd, cwd,
prTitle: getOptionalInput("title"), prTitle: getOptionalInput("pr-title"),
commitMessage: getOptionalInput("commit"), commitMessage: getOptionalInput("commit-message"),
hasPublishScript, hasPublishScript,
prDraft, prDraft,
branch: getOptionalInput("branch"), branch: getOptionalInput("pr-base-branch"),
}); });
core.setOutput("pull-request-number", String(pullRequestNumber)); core.setOutput("pr-number", String(pullRequestNumber));
return; return;
} }
+12 -3
View File
@@ -136,13 +136,22 @@ export function getRequiredInput(name: string) {
} }
export function throwOnRenamedInputs(renames: Record<string, string>) { export function throwOnRenamedInputs(renames: Record<string, string>) {
const references: Record<string, string> = {};
for (const [oldInput, newInput] of Object.entries(renames)) { for (const [oldInput, newInput] of Object.entries(renames)) {
if (core.getInput(oldInput)) { if (core.getInput(oldInput)) {
throw new Error( references[oldInput] = newInput;
`The input "${oldInput}" has been renamed to "${newInput}". Please update your workflow file.`,
);
} }
} }
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) { function resolveChangesetsCli(cwd: string) {
+3 -1
View File
@@ -37,7 +37,9 @@ inputs:
description: Sets up the git user for commits as `"github-actions[bot]"`. Default to `true` description: Sets up the git user for commits as `"github-actions[bot]"`. Default to `true`
required: false required: false
default: true default: true
outputs: {} outputs:
pr-number:
description: The pull request number that was created or updated
branding: branding:
icon: package icon: package
color: blue color: blue