Add back cwd input (#718)

This commit is contained in:
Bjorn Lu
2026-08-12 13:10:39 +00:00
committed by GitHub
parent 6f58ba3580
commit 3b7c71c440
16 changed files with 41 additions and 15 deletions
+5
View File
@@ -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.
+1
View File
@@ -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 | | `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-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`. | | `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 | | Outputs | Description |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
+3
View File
@@ -47,6 +47,9 @@ inputs:
GitHub's GPG key and attributed to the user or app that owns the `github-token`. GitHub's GPG key and attributed to the user or app that owns the `github-token`.
required: false required: false
default: false default: false
cwd:
description: "The working directory to execute Changesets in. Defaults to the root of the repository."
required: false
outputs: outputs:
published: published:
description: A "true" or "false" string value to indicate whether a publishing is happened or not description: A "true" or "false" string value to indicate whether a publishing is happened or not
+4 -3
View File
@@ -17,9 +17,10 @@ This action packs publishable packages into tarballs, complements [changesets/ac
<!-- api-start --> <!-- api-start -->
| Inputs | Description | | Inputs | Description |
| -------------------------- | --------------------------------------------------------------------- | | -------------------------- | --------------------------------------------------------------------------------------- |
| `publish-plan-artifact-id` | Artifact id for a publish plan generated by the select-mode subaction | | `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 | | Outputs | Description |
| ---------------------- | ------------------------------------------- | | ---------------------- | ------------------------------------------- |
+3
View File
@@ -7,6 +7,9 @@ inputs:
publish-plan-artifact-id: publish-plan-artifact-id:
description: "Artifact id for a publish plan generated by the select-mode subaction" description: "Artifact id for a publish plan generated by the select-mode subaction"
required: false required: false
cwd:
description: "The working directory to execute Changesets in. Defaults to the root of the repository."
required: false
outputs: outputs:
pack-dir-artifact-id: pack-dir-artifact-id:
description: "Artifact id for the packed output directory" description: "Artifact id for the packed output directory"
+1
View File
@@ -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 | | `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 | | `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-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 | | Outputs | Description |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ | | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
+3
View File
@@ -26,6 +26,9 @@ inputs:
this option will also always be `true`. this option will also always be `true`.
required: false required: false
default: true default: true
cwd:
description: "The working directory to execute Changesets in. Defaults to the root of the repository."
required: false
outputs: outputs:
published: published:
description: A "true" or "false" string value to indicate whether a publishing has happened or not description: A "true" or "false" string value to indicate whether a publishing has happened or not
+3 -1
View File
@@ -20,7 +20,9 @@ This action selects the mode to run a Changesets workflow:
<!-- api-start --> <!-- api-start -->
Inputs: _none_ | Inputs | Description |
| ------ | --------------------------------------------------------------------------------------- |
| `cwd` | The working directory to execute Changesets in. Defaults to the root of the repository. |
| Outputs | Description | | Outputs | Description |
| -------------------------- | ---------------------------------------------------------------------------- | | -------------------------- | ---------------------------------------------------------------------------- |
+4 -1
View File
@@ -3,7 +3,10 @@ description: Whether to version or publish in the current repo state
runs: runs:
using: node24 using: node24
main: ../dist/select-mode.js 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: outputs:
mode: mode:
description: "The mode to use for the current repo state: 'version', 'publish', or 'none'." description: "The mode to use for the current repo state: 'version', 'publish', or 'none'."
+1 -2
View File
@@ -11,8 +11,7 @@ import {
} from "./utils.ts"; } from "./utils.ts";
(async () => { (async () => {
// If the user needs to change the cwd, set `working-directory` in the step instead const cwd = getOptionalInput("cwd") || process.cwd();
const cwd = process.cwd();
await validateChangesetsCliVersion(cwd); await validateChangesetsCliVersion(cwd);
throwOnRenamedInputs({ throwOnRenamedInputs({
+1 -2
View File
@@ -17,8 +17,7 @@ try {
} }
async function main() { async function main() {
// If the user needs to change the cwd, set `working-directory` in the step instead const cwd = getOptionalInput("cwd") || process.cwd();
const cwd = process.cwd();
await validateChangesetsCliVersion(cwd); await validateChangesetsCliVersion(cwd);
const publishPlanArtifactId = getOptionalInput("publish-plan-artifact-id"); const publishPlanArtifactId = getOptionalInput("publish-plan-artifact-id");
+1 -2
View File
@@ -17,8 +17,7 @@ try {
} }
async function main() { async function main() {
// If the user needs to change the cwd, set `working-directory` in the step instead const cwd = getOptionalInput("cwd") || process.cwd();
const cwd = process.cwd();
await validateChangesetsCliVersion(cwd); await validateChangesetsCliVersion(cwd);
const githubToken = getRequiredInput("github-token"); const githubToken = getRequiredInput("github-token");
+6 -2
View File
@@ -4,7 +4,11 @@ import path from "node:path";
import artifact from "@actions/artifact"; import artifact from "@actions/artifact";
import * as core from "@actions/core"; import * as core from "@actions/core";
import readChangesetState from "../readChangesetState.ts"; import readChangesetState from "../readChangesetState.ts";
import { execChangesetsCli, validateChangesetsCliVersion } from "../utils.ts"; import {
execChangesetsCli,
getOptionalInput,
validateChangesetsCliVersion,
} from "../utils.ts";
type ModeResult = type ModeResult =
| { | {
@@ -27,7 +31,7 @@ try {
} }
async function main() { async function main() {
const cwd = process.cwd(); const cwd = getOptionalInput("cwd") || process.cwd();
await validateChangesetsCliVersion(cwd); await validateChangesetsCliVersion(cwd);
const result = await getMode(cwd); const result = await getMode(cwd);
+1 -2
View File
@@ -15,8 +15,7 @@ try {
} }
async function main() { async function main() {
// If the user needs to change the cwd, set `working-directory` in the step instead const cwd = getOptionalInput("cwd") || process.cwd();
const cwd = process.cwd();
await validateChangesetsCliVersion(cwd); await validateChangesetsCliVersion(cwd);
throwOnRemovedCommitModeInput(); throwOnRemovedCommitModeInput();
+1
View File
@@ -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-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`. | | `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`. | | `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 | | Outputs | Description |
| ----------- | --------------------------------------------------- | | ----------- | --------------------------------------------------- |
+3
View File
@@ -34,6 +34,9 @@ inputs:
GPG key and attributed to the user or app that owns the `github-token`. GPG key and attributed to the user or app that owns the `github-token`.
required: false required: false
default: false default: false
cwd:
description: "The working directory to execute Changesets in. Defaults to the root of the repository."
required: false
outputs: outputs:
pr-number: pr-number:
description: The pull request number that was created or updated description: The pull request number that was created or updated