import { r as ux } from "./cli-B86kvKcR.mjs";
import { n as runReleaseCheckCommand } from "./check-NyDIOUkU.mjs";
import { a as readActiveReleaseSummary, o as releaseSummaryIncludesPackages, t as finalizeRelease } from "./release-C3xNWdlR.mjs";
import process from "node:process";
import { defineCommand } from "citty";
import { execa } from "execa";
//#region src/commands/release/publish.ts
async function runReleasePublishCommand() {
	try {
		const cwd = process.cwd();
		const activeSummary = await readActiveReleaseSummary(cwd);
		if (!activeSummary) throw new Error("No active release summary found. Run `anvil release prepare` first.");
		await runReleaseCheckCommand({ quiet: true });
		if (process.exitCode) return;
		if (releaseSummaryIncludesPackages(activeSummary)) await ux.running("Publishing packages", async () => {
			await execa("pnpm", [
				"changeset",
				"publish",
				"--no-git-tag"
			], {
				cwd,
				stdio: "inherit"
			});
		});
		else ux.log.info("Skipping package publish because this release has no package version changes.");
		const marker = await ux.running("Finalizing repo release", async () => finalizeRelease(cwd));
		ux.log.success(`Published and finalized ${marker.releaseTag}.`);
	} catch (error) {
		ux.handleError(error);
	}
}
var publish_default = defineCommand({
	meta: {
		name: "publish",
		description: "Publish packages and finalize the repo release"
	},
	async run() {
		await runReleasePublishCommand();
		if (!process.exitCode) process.exit(0);
	}
});
//#endregion
export { publish_default as default };

//# sourceMappingURL=publish-D-t4j0Z8.mjs.map