Skip to content

Commit 3b7c71c

Browse files
authored
Add back cwd input (#718)
1 parent 6f58ba3 commit 3b7c71c

16 files changed

Lines changed: 41 additions & 15 deletions

File tree

.changeset/silent-schools-bathe.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@changesets/action": minor
3+
---
4+
5+
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.

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ If using [trusted publishing](https://docs.npmjs.com/trusted-publishers), it's r
6262
| `create-github-releases` | Whether to create Github releases after publish |
6363
| `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`. |
6464
| `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`. |
65+
| `cwd` | The working directory to execute Changesets in. Defaults to the root of the repository. |
6566
6667
| Outputs | Description |
6768
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |

action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ inputs:
4747
GitHub's GPG key and attributed to the user or app that owns the `github-token`.
4848
required: false
4949
default: false
50+
cwd:
51+
description: "The working directory to execute Changesets in. Defaults to the root of the repository."
52+
required: false
5053
outputs:
5154
published:
5255
description: A "true" or "false" string value to indicate whether a publishing is happened or not

pack/README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ This action packs publishable packages into tarballs, complements [changesets/ac
1717

1818
<!-- api-start -->
1919

20-
| Inputs | Description |
21-
| -------------------------- | --------------------------------------------------------------------- |
22-
| `publish-plan-artifact-id` | Artifact id for a publish plan generated by the select-mode subaction |
20+
| Inputs | Description |
21+
| -------------------------- | --------------------------------------------------------------------------------------- |
22+
| `publish-plan-artifact-id` | Artifact id for a publish plan generated by the select-mode subaction |
23+
| `cwd` | The working directory to execute Changesets in. Defaults to the root of the repository. |
2324

2425
| Outputs | Description |
2526
| ---------------------- | ------------------------------------------- |

pack/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ inputs:
77
publish-plan-artifact-id:
88
description: "Artifact id for a publish plan generated by the select-mode subaction"
99
required: false
10+
cwd:
11+
description: "The working directory to execute Changesets in. Defaults to the root of the repository."
12+
required: false
1013
outputs:
1114
pack-dir-artifact-id:
1215
description: "Artifact id for the packed output directory"

publish/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ This action publishes packages to npm.
2525
| `pack-dir-artifact-id` | Artifact id for packed publish output generated by the pack subaction |
2626
| `create-github-releases` | Whether to create Github releases after publish |
2727
| `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`. |
28+
| `cwd` | The working directory to execute Changesets in. Defaults to the root of the repository. |
2829

2930
| Outputs | Description |
3031
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |

publish/action.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ inputs:
2626
this option will also always be `true`.
2727
required: false
2828
default: true
29+
cwd:
30+
description: "The working directory to execute Changesets in. Defaults to the root of the repository."
31+
required: false
2932
outputs:
3033
published:
3134
description: A "true" or "false" string value to indicate whether a publishing has happened or not

select-mode/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ This action selects the mode to run a Changesets workflow:
2020

2121
<!-- api-start -->
2222

23-
Inputs: _none_
23+
| Inputs | Description |
24+
| ------ | --------------------------------------------------------------------------------------- |
25+
| `cwd` | The working directory to execute Changesets in. Defaults to the root of the repository. |
2426

2527
| Outputs | Description |
2628
| -------------------------- | ---------------------------------------------------------------------------- |

select-mode/action.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ description: Whether to version or publish in the current repo state
33
runs:
44
using: node24
55
main: ../dist/select-mode.js
6-
inputs: {}
6+
inputs:
7+
cwd:
8+
description: "The working directory to execute Changesets in. Defaults to the root of the repository."
9+
required: false
710
outputs:
811
mode:
912
description: "The mode to use for the current repo state: 'version', 'publish', or 'none'."

src/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ import {
1111
} from "./utils.ts";
1212

1313
(async () => {
14-
// If the user needs to change the cwd, set `working-directory` in the step instead
15-
const cwd = process.cwd();
14+
const cwd = getOptionalInput("cwd") || process.cwd();
1615
await validateChangesetsCliVersion(cwd);
1716

1817
throwOnRenamedInputs({

0 commit comments

Comments
 (0)