mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
* Migrate to ESM * just use `require.resolve` * reuse setup action * checkout PR head for a sec * ls things * try a thing * the dirname had a trailing whitespace, lol
19 lines
588 B
TypeScript
19 lines
588 B
TypeScript
import { exec } from "@actions/exec";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
import pkgJson from "../package.json" with { type: "json" };
|
|
|
|
process.chdir(path.join(import.meta.dirname, ".."));
|
|
|
|
await exec("changeset", ["version"]);
|
|
|
|
const releaseLine = `v${pkgJson.version.split(".")[0]}`;
|
|
|
|
const readmePath = path.join(import.meta.dirname, "..", "README.md");
|
|
const content = fs.readFileSync(readmePath, "utf8");
|
|
const updatedContent = content.replace(
|
|
/changesets\/action@[^\s]+/g,
|
|
`changesets/action@${releaseLine}`
|
|
);
|
|
fs.writeFileSync(readmePath, updatedContent);
|