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
17 changes: 17 additions & 0 deletions .changeset/eighty-parks-tickle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
"@changesets/action": major
---

Rename the root action inputs and outputs to better match the sub-actions' conventions.

Inputs:

- `version` -> `version-script`
- `publish` -> `publish-script`
- `commit` -> `commit-message`
- `title` -> `pr-title`
- `branch` -> `pr-base-branch`

Outputs:

- `pull-request-number` -> `pr-number`
6 changes: 3 additions & 3 deletions README.md

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.

Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ jobs:
uses: changesets/action@v2
with:
# This expects you to have a script called release which does a build for your packages and calls changeset publish
publish: pnpm release
publish-script: pnpm release
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

Expand Down Expand Up @@ -217,7 +217,7 @@ jobs:
uses: changesets/action@v2
with:
# this expects you to have a npm script called version that runs some logic and then calls `changeset version`.
version: pnpm version
version-script: pnpm version
```

#### With Yarn 2 / Plug'n'Play
Expand All @@ -227,6 +227,6 @@ If you are using [Yarn Plug'n'Play](https://yarnpkg.com/features/pnp), you shoul
```yaml
- uses: changesets/action@v2
with:
version: yarn changeset version
version-script: yarn changeset version
# ...
```
35 changes: 18 additions & 17 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,28 @@ inputs:
description: "The GitHub token to use for authentication. Defaults to the GitHub-provided token."
required: false
default: ${{ github.token }}
publish:
publish-script:
description: "The command to use to build and publish packages"
required: false
version:
version-script:
description: "The command to update version, edit CHANGELOG, read and delete changesets. Default to `changeset version` if not provided"
required: false
commit:
description: |
The commit message. Default to `Version Packages`
commit-message:
description: "The commit message. Default to `Version Packages`"
required: false
title:
description: The pull request title. Default to `Version Packages`
default: "Version Packages"
pr-title:
description: "The pull request title. Default to `Version Packages`"
required: false
setup-git-user:
description: Sets up the git user for commits as `"github-actions[bot]"`. Default to `true`
default: "Version Packages"
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."
required: false
pr-base-branch:
description: "Sets the base branch of the PR. Defaults to `github.ref_name`."
required: false
default: true
create-github-releases:
description: "A boolean value to indicate whether to create Github releases after `publish` or not"
description: "Whether to create Github releases after publish"
required: false
default: true
commit-mode:
Expand All @@ -37,12 +40,10 @@ inputs:
or app who owns the GITHUB_TOKEN.
required: false
default: "git-cli"
branch:
description: Sets the branch in which the action will run. Default to `github.ref_name` if not provided
required: false
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.'
setup-git-user:
description: Sets up the git user for commits as `"github-actions[bot]"`. Default to `true`
required: false
default: true
outputs:
published:
description: A boolean value to indicate whether a publishing is happened or not
Expand All @@ -51,7 +52,7 @@ outputs:
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"}]`
has-changesets:
description: A boolean about whether there were changesets. Useful if you want to create your own publishing functionality.
pull-request-number:
pr-number:
description: The pull request number that was created or updated
branding:
icon: "package"
Expand Down
21 changes: 13 additions & 8 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@ import {

(async () => {
throwOnRenamedInputs({
commitMode: "commit-mode",
createGithubReleases: "create-github-releases",
publish: "publish-script",
version: "version-script",
commit: "commit-mesage",
title: "pr-title",
branch: "pr-base-branch",
prDraft: "pr-draft",
createGithubReleases: "create-github-releases",
commitMode: "commit-mode",
setupGitUser: "setup-git-user",
});

Expand Down Expand Up @@ -55,7 +60,7 @@ import {

let { changesets } = await readChangesetState(cwd);

let publishScript = core.getInput("publish");
let publishScript = core.getInput("publish-script");
let hasChangesets = changesets.length !== 0;
const hasNonEmptyChangesets = changesets.some(
(changeset) => changeset.releases.length > 0,
Expand Down Expand Up @@ -156,17 +161,17 @@ import {
return;
case hasChangesets: {
const { pullRequestNumber } = await runVersion({
script: getOptionalInput("version"),
script: getOptionalInput("version-script"),
github,
cwd,
prTitle: getOptionalInput("title"),
commitMessage: getOptionalInput("commit"),
prTitle: getOptionalInput("pr-title"),
commitMessage: getOptionalInput("commit-message"),
hasPublishScript,
prDraft,
branch: getOptionalInput("branch"),
branch: getOptionalInput("pr-base-branch"),
});

core.setOutput("pull-request-number", String(pullRequestNumber));
core.setOutput("pr-number", String(pullRequestNumber));

return;
}
Expand Down
15 changes: 12 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,22 @@ export function getRequiredInput(name: string) {
}

export function throwOnRenamedInputs(renames: Record<string, string>) {
const references: 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.`,
);
references[oldInput] = newInput;
}
}

if (Object.keys(references).length > 0) {
const list = Object.entries(references)
.map(([oldInput, newInput]) => `- "${oldInput}" -> "${newInput}"`)
.join("\n");
throw new Error(
`The following inputs have been renamed:\n${list}\nPlease update your workflow file.`,
);
}
}

function resolveChangesetsCli(cwd: string) {
Expand Down
4 changes: 3 additions & 1 deletion version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,9 @@ inputs:
description: Sets up the git user for commits as `"github-actions[bot]"`. Default to `true`
required: false
default: true
outputs: {}
outputs:
pr-number:
description: The pull request number that was created or updated
branding:
icon: package
color: blue