Skip to content
Open
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ There are also sub-actions hosted in this repository. Check out their respective
### Outputs

- published - A boolean value to indicate whether a publishing has happened or not
- publishedPackages - 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"}]`
- publish-output - The path to the Changesets publish output file in NDJSON format

### Example workflow

Expand Down
7 changes: 3 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,9 @@ inputs:
default: true
outputs:
published:
description: A boolean value to indicate whether a publishing is happened or not
published-packages:
description: >
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"}]`
description: A boolean value to indicate whether any release was published
publish-output:
description: The path to the changesets publish output file in NDJSON format
has-changesets:
description: A boolean about whether there were changesets. Useful if you want to create your own publishing functionality.
pr-number:
Expand Down
7 changes: 3 additions & 4 deletions publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,9 @@ inputs:
default: true
outputs:
published:
description: "A boolean value to indicate whether a publishing has happened or not"
published-packages:
description: >
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"}]`
description: A boolean value to indicate whether any release was published
output:
description: The path to the Changesets publish output file in NDJSON format

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.

Suggested change
description: The path to the Changesets publish output file in NDJSON format
description: The path to the publish output NDJSON file

branding:
icon: package
color: blue
17 changes: 7 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ import {
let hasPublishScript = !!publishScript;

core.setOutput("published", "false");
core.setOutput("published-packages", "[]");
core.setOutput("has-changesets", String(hasChangesets));

switch (true) {
Expand Down Expand Up @@ -146,19 +145,17 @@ import {
cwd,
});

if (result.published) {
core.setOutput("published", "true");
core.setOutput(
"published-packages",
JSON.stringify(result.publishedPackages),
);
}
core.setOutput(
"published",
result.releases.length > 0 ? "true" : "false",
);
core.setOutput("publish-output", result.output);

if (result.exitCode !== 0) {
core.error(
`Publish command exited with code ${result.exitCode}${
result.published
? `, but some packages were published: ${result.publishedPackages
result.releases.length
? `, but some packages were published: ${result.releases
.map((p) => `${p.name}@${p.version}`)
.join(", ")}`
: ""
Expand Down
15 changes: 4 additions & 11 deletions src/publish/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,14 @@ async function main() {
fromPackDir,
});

if (result.published) {
core.setOutput("published", "true");
core.setOutput(

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.

Why I'd like to propose changing this? Currently, we interpret "git-tag" events as "releases". But with --no-git-tag and other customizations that's not exactly particularly accurate.

We should be emitting some other events for npm-only releases and allow the action to interpret them as releases. That's something to fix on the CLI side of things.

But even once we do it... the user wouldn't be able to tell exactly what and how got released. We'd have to "interpret" a mix of tag/npm releases into this array of published-packages. So my thinking is that by allowing the user to interpret the NDJSON output we can just satisfy more use cases without hardcoding some decisions into the action's core.

@beeequeue beeequeue Jul 2, 2026

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.

i think we should have both.

having to parse and handle the CLI output requires quite a lot more than just checking if the published value is true, especially in CI flows.

since we also have the output file now, we can change the meaning of published:

published: was any package published

we could also add tagged
tagged: was any package tagged

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.

I quite like having published and tagged separated. Then we could let them decide how to handle it. Maybe also if publish passes but tag failed (or vice versa) it would be clearer which packages is affected

"published-packages",
JSON.stringify(result.publishedPackages),
);
} else {
core.setOutput("published", "false");
}
core.setOutput("published", result.releases.length > 0 ? "true" : "false");
core.setOutput("output", result.output);

if (result.exitCode !== 0) {
throw new Error(
`Publish command exited with code ${result.exitCode}${
result.published
? `, but some packages were published: ${result.publishedPackages
result.releases.length
? `, but some packages were published: ${result.releases
.map((p) => `${p.name}@${p.version}`)
.join(", ")}`
: ""
Expand Down
38 changes: 15 additions & 23 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,19 @@ type PublishOptions = {
cwd: string;
};

type PublishedPackage = { name: string; version: string };
type PackageRelease = { name: string; version: string };

type ChangesetsOutputEvent = {
type: "git-tag";
tag: string;
packageName: string;
};

type PublishResult =
| {
published: true;
publishedPackages: PublishedPackage[];
exitCode: number;
}
| {
published: false;
exitCode: number;
};
type PublishResult = {
releases: PackageRelease[];
output: string;
exitCode: number;
};

function isObject(value: unknown) {
return typeof value === "object" && value !== null;
Expand Down Expand Up @@ -227,18 +223,14 @@ export async function runPublish({
);
}

if (releases.length) {
return {
published: true,
publishedPackages: releases.map(({ pkg }) => ({
name: pkg.packageJson.name,
version: pkg.packageJson.version,
})),
exitCode: changesetPublishOutput.exitCode,
};
}

return { published: false, exitCode: changesetPublishOutput.exitCode };
return {
releases: releases.map(({ pkg }) => ({
name: pkg.packageJson.name,
version: pkg.packageJson.version,
})),
output: outputFile,
exitCode: changesetPublishOutput.exitCode,
};
}

type GetMessageOptions = {
Expand Down