Rename to kebab-case for root action inputs and outputs (#668)

* Rename to kebab-case for root action inputs and outputs

* Throw on renamed inputs
This commit is contained in:
Bjorn Lu
2026-06-30 08:24:21 +00:00
committed by GitHub
parent 164652bdd6
commit 0eae789230
4 changed files with 44 additions and 17 deletions
+5
View File
@@ -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
+7 -7
View File
@@ -21,15 +21,15 @@ inputs:
title: title:
description: The pull request title. Default to `Version Packages` description: The pull request title. Default to `Version Packages`
required: false required: false
setupGitUser: setup-git-user:
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
createGithubReleases: create-github-releases:
description: "A boolean value to indicate whether to create Github releases after `publish` or not" description: "A boolean value to indicate whether to create Github releases after `publish` or not"
required: false required: false
default: true default: true
commitMode: commit-mode:
description: > description: >
An enum to specify the commit mode. Use "git-cli" to push changes using the Git CLI, 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", or "github-api" to push changes via the GitHub API. When using "github-api",
@@ -40,18 +40,18 @@ inputs:
branch: branch:
description: Sets the branch in which the action will run. Default to `github.ref_name` if not provided description: Sets the branch in which the action will run. Default to `github.ref_name` if not provided
required: false 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.' 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
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
publishedPackages: published-packages:
description: > 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"}]` 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. 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 description: The pull request number that was created or updated
branding: branding:
icon: "package" icon: "package"
+22 -10
View File
@@ -3,9 +3,21 @@ import * as core from "@actions/core";
import { GitHub } from "./github.ts"; import { GitHub } from "./github.ts";
import readChangesetState from "./readChangesetState.ts"; import readChangesetState from "./readChangesetState.ts";
import { runPublish, runVersion } from "./run.ts"; import { runPublish, runVersion } from "./run.ts";
import { fileExists, getOptionalInput, getRequiredInput } from "./utils.ts"; import {
fileExists,
getOptionalInput,
getRequiredInput,
throwOnRenamedInputs,
} from "./utils.ts";
(async () => { (async () => {
throwOnRenamedInputs({
commitMode: "commit-mode",
createGithubReleases: "create-github-releases",
prDraft: "pr-draft",
setupGitUser: "setup-git-user",
});
const githubToken = getRequiredInput("github-token"); const githubToken = getRequiredInput("github-token");
if (process.env.GITHUB_TOKEN && process.env.GITHUB_TOKEN !== githubToken) { if (process.env.GITHUB_TOKEN && process.env.GITHUB_TOKEN !== githubToken) {
throw new Error( throw new Error(
@@ -18,14 +30,14 @@ import { fileExists, getOptionalInput, getRequiredInput } from "./utils.ts";
// If the user needs to change the cwd, set `working-directory` in the step instead // If the user needs to change the cwd, set `working-directory` in the step instead
const cwd = process.cwd(); const cwd = process.cwd();
const commitMode = getOptionalInput("commitMode") ?? "git-cli"; const commitMode = getOptionalInput("commit-mode") ?? "git-cli";
const prDraft = getOptionalInput("prDraft"); const prDraft = getOptionalInput("pr-draft");
if (commitMode !== "git-cli" && commitMode !== "github-api") { if (commitMode !== "git-cli" && commitMode !== "github-api") {
core.setFailed(`Invalid commit mode: ${commitMode}`); core.setFailed(`Invalid commit mode: ${commitMode}`);
return; return;
} }
if (prDraft !== undefined && prDraft !== "always" && prDraft !== "create") { if (prDraft !== undefined && prDraft !== "always" && prDraft !== "create") {
core.setFailed(`Invalid prDraft: ${prDraft}`); core.setFailed(`Invalid pr-draft: ${prDraft}`);
return; return;
} }
const github = new GitHub({ const github = new GitHub({
@@ -34,7 +46,7 @@ import { fileExists, getOptionalInput, getRequiredInput } from "./utils.ts";
commitMode, commitMode,
}); });
let setupGitUser = core.getBooleanInput("setupGitUser"); let setupGitUser = core.getBooleanInput("setup-git-user");
if (setupGitUser) { if (setupGitUser) {
core.info("setting git user"); core.info("setting git user");
@@ -51,8 +63,8 @@ import { fileExists, getOptionalInput, getRequiredInput } from "./utils.ts";
let hasPublishScript = !!publishScript; let hasPublishScript = !!publishScript;
core.setOutput("published", "false"); core.setOutput("published", "false");
core.setOutput("publishedPackages", "[]"); core.setOutput("published-packages", "[]");
core.setOutput("hasChangesets", String(hasChangesets)); core.setOutput("has-changesets", String(hasChangesets));
switch (true) { switch (true) {
case !hasChangesets && !hasPublishScript: case !hasChangesets && !hasPublishScript:
@@ -113,14 +125,14 @@ import { fileExists, getOptionalInput, getRequiredInput } from "./utils.ts";
const result = await runPublish({ const result = await runPublish({
script: publishScript, script: publishScript,
github, github,
createGithubReleases: core.getBooleanInput("createGithubReleases"), createGithubReleases: core.getBooleanInput("create-github-releases"),
cwd, cwd,
}); });
if (result.published) { if (result.published) {
core.setOutput("published", "true"); core.setOutput("published", "true");
core.setOutput( core.setOutput(
"publishedPackages", "published-packages",
JSON.stringify(result.publishedPackages), JSON.stringify(result.publishedPackages),
); );
} }
@@ -154,7 +166,7 @@ import { fileExists, getOptionalInput, getRequiredInput } from "./utils.ts";
branch: getOptionalInput("branch"), branch: getOptionalInput("branch"),
}); });
core.setOutput("pullRequestNumber", String(pullRequestNumber)); core.setOutput("pull-request-number", String(pullRequestNumber));
return; return;
} }
+10
View File
@@ -135,6 +135,16 @@ export function getRequiredInput(name: string) {
return core.getInput(name, { required: true }); return core.getInput(name, { required: true });
} }
export function throwOnRenamedInputs(renames: Record<string, string>) {
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) { function resolveChangesetsCli(cwd: string) {
return require.resolve("@changesets/cli/bin.js", { return require.resolve("@changesets/cli/bin.js", {
paths: [cwd], paths: [cwd],