Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/silent-schools-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@changesets/action": minor

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One could argue it should be a patch - im fine with either

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I'm also fine with either but I'll merge as minor for now, action versions are usually more lenient

---

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 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
Expand Down
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions pack/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,10 @@ This action packs publishable packages into tarballs, complements [changesets/ac

<!-- api-start -->

| 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 |
| ---------------------- | ------------------------------------------- |
Expand Down
3 changes: 3 additions & 0 deletions pack/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically, it probably defaults to the current workspace dir or smth - but it's probably fine to assume the root of the repository here

required: false
outputs:
pack-dir-artifact-id:
description: "Artifact id for the packed output directory"
Expand Down
1 change: 1 addition & 0 deletions publish/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
| -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
Expand Down
3 changes: 3 additions & 0 deletions publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion select-mode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ This action selects the mode to run a Changesets workflow:

<!-- api-start -->

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

| Outputs | Description |
| -------------------------- | ---------------------------------------------------------------------------- |
Expand Down
5 changes: 4 additions & 1 deletion select-mode/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'."
Expand Down
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
3 changes: 1 addition & 2 deletions src/pack/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
3 changes: 1 addition & 2 deletions src/publish/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
8 changes: 6 additions & 2 deletions src/select-mode/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
| {
Expand All @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions src/version/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
1 change: 1 addition & 0 deletions version/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
| ----------- | --------------------------------------------------- |
Expand Down
3 changes: 3 additions & 0 deletions version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading