From 7e1c6c1354ed0a3ad177de4502867654080fb0bd Mon Sep 17 00:00:00 2001 From: bluwy Date: Wed, 24 Jun 2026 11:10:27 +0800 Subject: [PATCH 1/2] Rename to kebab-case for root action inputs and outputs --- .changeset/yellow-roses-fix.md | 5 +++++ action.yml | 14 +++++++------- src/index.ts | 18 +++++++++--------- 3 files changed, 21 insertions(+), 16 deletions(-) create mode 100644 .changeset/yellow-roses-fix.md diff --git a/.changeset/yellow-roses-fix.md b/.changeset/yellow-roses-fix.md new file mode 100644 index 00000000..21c93839 --- /dev/null +++ b/.changeset/yellow-roses-fix.md @@ -0,0 +1,5 @@ +--- +"@changesets/action": major +--- + +Rename the input and output names to kebab-case instead of camelCase to match the official GitHub actions pattern diff --git a/action.yml b/action.yml index 8f2ccb18..c38f8386 100644 --- a/action.yml +++ b/action.yml @@ -21,15 +21,15 @@ inputs: title: description: The pull request title. Default to `Version Packages` required: false - setupGitUser: + setup-git-user: description: Sets up the git user for commits as `"github-actions[bot]"`. Default to `true` required: false default: true - createGithubReleases: + create-github-releases: description: "A boolean value to indicate whether to create Github releases after `publish` or not" required: false default: true - commitMode: + commit-mode: description: > An enum to specify the commit mode. Use "git-cli" to push changes using the Git CLI, or "github-api" to push changes via the GitHub API. When using "github-api", @@ -40,18 +40,18 @@ inputs: branch: description: Sets the branch in which the action will run. Default to `github.ref_name` if not provided required: false - prDraft: + 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 outputs: published: description: A boolean value to indicate whether a publishing is happened or not - publishedPackages: + published-packages: description: > 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"}]` - hasChangesets: + has-changesets: description: A boolean about whether there were changesets. Useful if you want to create your own publishing functionality. - pullRequestNumber: + pull-request-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 99e5e49e..823fbdcf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -20,14 +20,14 @@ import { fileExists, getOptionalInput } from "./utils.ts"; const cwd = process.cwd(); const octokit = setupOctokit(githubToken); - const commitMode = getOptionalInput("commitMode") ?? "git-cli"; - const prDraft = getOptionalInput("prDraft"); + const commitMode = getOptionalInput("commit-mode") ?? "git-cli"; + const prDraft = getOptionalInput("pr-draft"); if (commitMode !== "git-cli" && commitMode !== "github-api") { core.setFailed(`Invalid commit mode: ${commitMode}`); return; } if (prDraft !== undefined && prDraft !== "always" && prDraft !== "create") { - core.setFailed(`Invalid prDraft: ${prDraft}`); + core.setFailed(`Invalid pr-draft: ${prDraft}`); return; } const git = new Git({ @@ -35,7 +35,7 @@ import { fileExists, getOptionalInput } from "./utils.ts"; cwd, }); - let setupGitUser = core.getBooleanInput("setupGitUser"); + let setupGitUser = core.getBooleanInput("setup-git-user"); if (setupGitUser) { core.info("setting git user"); @@ -58,8 +58,8 @@ import { fileExists, getOptionalInput } from "./utils.ts"; let hasPublishScript = !!publishScript; core.setOutput("published", "false"); - core.setOutput("publishedPackages", "[]"); - core.setOutput("hasChangesets", String(hasChangesets)); + core.setOutput("published-packages", "[]"); + core.setOutput("has-changesets", String(hasChangesets)); switch (true) { case !hasChangesets && !hasPublishScript: @@ -122,14 +122,14 @@ import { fileExists, getOptionalInput } from "./utils.ts"; githubToken, git, octokit, - createGithubReleases: core.getBooleanInput("createGithubReleases"), + createGithubReleases: core.getBooleanInput("create-github-releases"), cwd, }); if (result.published) { core.setOutput("published", "true"); core.setOutput( - "publishedPackages", + "published-packages", JSON.stringify(result.publishedPackages), ); } @@ -166,7 +166,7 @@ import { fileExists, getOptionalInput } from "./utils.ts"; branch: getOptionalInput("branch"), }); - core.setOutput("pullRequestNumber", String(pullRequestNumber)); + core.setOutput("pull-request-number", String(pullRequestNumber)); return; } From 56a64366136d5b6f619d124165002a1941073bb5 Mon Sep 17 00:00:00 2001 From: bluwy Date: Thu, 25 Jun 2026 09:48:53 +0800 Subject: [PATCH 2/2] Throw on renamed inputs --- src/index.ts | 9 ++++++++- src/utils.ts | 10 ++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index fccb12cf..f1462bc6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,9 +3,16 @@ import * as core from "@actions/core"; import { GitHub } from "./github.ts"; import readChangesetState from "./readChangesetState.ts"; import { runPublish, runVersion } from "./run.ts"; -import { fileExists, getOptionalInput } from "./utils.ts"; +import { fileExists, getOptionalInput, throwOnRenamedInputs } from "./utils.ts"; (async () => { + throwOnRenamedInputs({ + commitMode: "commit-mode", + createGithubReleases: "create-github-releases", + prDraft: "pr-draft", + setupGitUser: "setup-git-user", + }); + // to maintain compatibility with workflows created before github-token input was introduced // it's important to prefer the explicitly set GITHUB_TOKEN over the default token coming from github.token let githubToken = process.env.GITHUB_TOKEN || core.getInput("github-token"); diff --git a/src/utils.ts b/src/utils.ts index 205eb5cf..6a626e3f 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -135,6 +135,16 @@ export function getRequiredInput(name: string) { return core.getInput(name, { required: true }); } +export function throwOnRenamedInputs(renames: 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.`, + ); + } + } +} + function resolveChangesetsCli(cwd: string) { return require.resolve("@changesets/cli/bin.js", { paths: [cwd],