From d57c63b7c673e25cec08086e5fccdf451d0ceef9 Mon Sep 17 00:00:00 2001 From: bluwy Date: Wed, 12 Aug 2026 18:32:26 +0800 Subject: [PATCH] Add back cwd input --- .changeset/silent-schools-bathe.md | 5 +++++ README.md | 1 + action.yml | 3 +++ pack/README.md | 7 ++++--- pack/action.yml | 3 +++ publish/README.md | 1 + publish/action.yml | 3 +++ select-mode/README.md | 4 +++- select-mode/action.yml | 5 ++++- src/index.ts | 3 +-- src/pack/index.ts | 3 +-- src/publish/index.ts | 3 +-- src/select-mode/index.ts | 8 ++++++-- src/version/index.ts | 3 +-- version/README.md | 1 + version/action.yml | 3 +++ 16 files changed, 41 insertions(+), 15 deletions(-) create mode 100644 .changeset/silent-schools-bathe.md diff --git a/.changeset/silent-schools-bathe.md b/.changeset/silent-schools-bathe.md new file mode 100644 index 00000000..d6525be9 --- /dev/null +++ b/.changeset/silent-schools-bathe.md @@ -0,0 +1,5 @@ +--- +"@changesets/action": minor +--- + +Add a `cwd` input to the root action, `/select-mode`, `/version`, `/pack`, and `/publish` sub-actions to set the current working directory to execute Changesets in. This input existed in v1 but was incorrectly removed. diff --git a/README.md b/README.md index 4b724e7b..18784fbc 100644 --- a/README.md +++ b/README.md @@ -62,6 +62,7 @@ If using [trusted publishing](https://docs.npmjs.com/trusted-publishers), it's r | `create-github-releases` | Whether to create Github releases after publish | | `push-git-tags` | Whether to create git tags after publish. If `create-github-releases` is set to `true`, this option will also always be `true`. | | `push-with-git-cli` | Whether to use the Git CLI instead of the GitHub API to push release commits and tags. Defaults to `false`. When using the GitHub API, commits and tags are signed using GitHub's GPG key and attributed to the user or app that owns the `github-token`. | +| `cwd` | The working directory to execute Changesets in. Defaults to the root of the repository. | | Outputs | Description | | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | diff --git a/action.yml b/action.yml index e19c373c..e358500d 100644 --- a/action.yml +++ b/action.yml @@ -47,6 +47,9 @@ inputs: GitHub's GPG key and attributed to the user or app that owns the `github-token`. required: false default: false + cwd: + description: "The working directory to execute Changesets in. Defaults to the root of the repository." + required: false outputs: published: description: A "true" or "false" string value to indicate whether a publishing is happened or not diff --git a/pack/README.md b/pack/README.md index ee7709d7..178ac36d 100644 --- a/pack/README.md +++ b/pack/README.md @@ -17,9 +17,10 @@ This action packs publishable packages into tarballs, complements [changesets/ac -| Inputs | Description | -| -------------------------- | --------------------------------------------------------------------- | -| `publish-plan-artifact-id` | Artifact id for a publish plan generated by the select-mode subaction | +| Inputs | Description | +| -------------------------- | --------------------------------------------------------------------------------------- | +| `publish-plan-artifact-id` | Artifact id for a publish plan generated by the select-mode subaction | +| `cwd` | The working directory to execute Changesets in. Defaults to the root of the repository. | | Outputs | Description | | ---------------------- | ------------------------------------------- | diff --git a/pack/action.yml b/pack/action.yml index eceb353b..ad5b7332 100644 --- a/pack/action.yml +++ b/pack/action.yml @@ -7,6 +7,9 @@ inputs: publish-plan-artifact-id: description: "Artifact id for a publish plan generated by the select-mode subaction" required: false + cwd: + description: "The working directory to execute Changesets in. Defaults to the root of the repository." + required: false outputs: pack-dir-artifact-id: description: "Artifact id for the packed output directory" diff --git a/publish/README.md b/publish/README.md index a8148f2f..e0cacc36 100644 --- a/publish/README.md +++ b/publish/README.md @@ -25,6 +25,7 @@ This action publishes packages to npm. | `pack-dir-artifact-id` | Artifact id for packed publish output generated by the pack subaction | | `create-github-releases` | Whether to create Github releases after publish | | `push-git-tags` | Whether to create git tags after publish. If `create-github-releases` is set to `true`, this option will also always be `true`. | +| `cwd` | The working directory to execute Changesets in. Defaults to the root of the repository. | | Outputs | Description | | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | diff --git a/publish/action.yml b/publish/action.yml index 511fb7aa..580d9dd2 100644 --- a/publish/action.yml +++ b/publish/action.yml @@ -26,6 +26,9 @@ inputs: this option will also always be `true`. required: false default: true + cwd: + description: "The working directory to execute Changesets in. Defaults to the root of the repository." + required: false outputs: published: description: A "true" or "false" string value to indicate whether a publishing has happened or not diff --git a/select-mode/README.md b/select-mode/README.md index 3b7abc42..668b33c0 100644 --- a/select-mode/README.md +++ b/select-mode/README.md @@ -20,7 +20,9 @@ This action selects the mode to run a Changesets workflow: -Inputs: _none_ +| Inputs | Description | +| ------ | --------------------------------------------------------------------------------------- | +| `cwd` | The working directory to execute Changesets in. Defaults to the root of the repository. | | Outputs | Description | | -------------------------- | ---------------------------------------------------------------------------- | diff --git a/select-mode/action.yml b/select-mode/action.yml index c03d8a2c..7dccb5bd 100644 --- a/select-mode/action.yml +++ b/select-mode/action.yml @@ -3,7 +3,10 @@ description: Whether to version or publish in the current repo state runs: using: node24 main: ../dist/select-mode.js -inputs: {} +inputs: + cwd: + description: "The working directory to execute Changesets in. Defaults to the root of the repository." + required: false outputs: mode: description: "The mode to use for the current repo state: 'version', 'publish', or 'none'." diff --git a/src/index.ts b/src/index.ts index 14420bf9..556506a6 100644 --- a/src/index.ts +++ b/src/index.ts @@ -11,8 +11,7 @@ import { } from "./utils.ts"; (async () => { - // If the user needs to change the cwd, set `working-directory` in the step instead - const cwd = process.cwd(); + const cwd = getOptionalInput("cwd") || process.cwd(); await validateChangesetsCliVersion(cwd); throwOnRenamedInputs({ diff --git a/src/pack/index.ts b/src/pack/index.ts index ae4ed1be..5ab50d82 100644 --- a/src/pack/index.ts +++ b/src/pack/index.ts @@ -17,8 +17,7 @@ try { } async function main() { - // If the user needs to change the cwd, set `working-directory` in the step instead - const cwd = process.cwd(); + const cwd = getOptionalInput("cwd") || process.cwd(); await validateChangesetsCliVersion(cwd); const publishPlanArtifactId = getOptionalInput("publish-plan-artifact-id"); diff --git a/src/publish/index.ts b/src/publish/index.ts index 308c93c8..5fc60c36 100644 --- a/src/publish/index.ts +++ b/src/publish/index.ts @@ -17,8 +17,7 @@ try { } async function main() { - // If the user needs to change the cwd, set `working-directory` in the step instead - const cwd = process.cwd(); + const cwd = getOptionalInput("cwd") || process.cwd(); await validateChangesetsCliVersion(cwd); const githubToken = getRequiredInput("github-token"); diff --git a/src/select-mode/index.ts b/src/select-mode/index.ts index 396aa2ea..61514fc1 100644 --- a/src/select-mode/index.ts +++ b/src/select-mode/index.ts @@ -4,7 +4,11 @@ import path from "node:path"; import artifact from "@actions/artifact"; import * as core from "@actions/core"; import readChangesetState from "../readChangesetState.ts"; -import { execChangesetsCli, validateChangesetsCliVersion } from "../utils.ts"; +import { + execChangesetsCli, + getOptionalInput, + validateChangesetsCliVersion, +} from "../utils.ts"; type ModeResult = | { @@ -27,7 +31,7 @@ try { } async function main() { - const cwd = process.cwd(); + const cwd = getOptionalInput("cwd") || process.cwd(); await validateChangesetsCliVersion(cwd); const result = await getMode(cwd); diff --git a/src/version/index.ts b/src/version/index.ts index bf7d3b7a..699f390a 100644 --- a/src/version/index.ts +++ b/src/version/index.ts @@ -15,8 +15,7 @@ try { } async function main() { - // If the user needs to change the cwd, set `working-directory` in the step instead - const cwd = process.cwd(); + const cwd = getOptionalInput("cwd") || process.cwd(); await validateChangesetsCliVersion(cwd); throwOnRemovedCommitModeInput(); diff --git a/version/README.md b/version/README.md index 16ea99e4..ff2f0a20 100644 --- a/version/README.md +++ b/version/README.md @@ -31,6 +31,7 @@ This action versions packages and creates or updates a pull request with the cha | `pr-draft` | 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. | | `pr-base-branch` | Sets the base branch of the PR. Defaults to `github.ref_name`. | | `push-with-git-cli` | Whether to use the Git CLI instead of the GitHub API to push release commits. Defaults to `false`. When using the GitHub API, commits are signed using GitHub's GPG key and attributed to the user or app that owns the `github-token`. | +| `cwd` | The working directory to execute Changesets in. Defaults to the root of the repository. | | Outputs | Description | | ----------- | --------------------------------------------------- | diff --git a/version/action.yml b/version/action.yml index e3dda8af..c98e070d 100644 --- a/version/action.yml +++ b/version/action.yml @@ -34,6 +34,9 @@ inputs: GPG key and attributed to the user or app that owns the `github-token`. required: false default: false + cwd: + description: "The working directory to execute Changesets in. Defaults to the root of the repository." + required: false outputs: pr-number: description: The pull request number that was created or updated