mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
Use split publishing workflow (#679)
* fix release line timing * Use split publishing workflow * remove release check, handle through publish plan * remove unused script * remove unused publish plan output * fmt * update a thing * fmt * simplify * update pre * update changesets cli
This commit is contained in:
+11
-31
@@ -1,6 +1,6 @@
|
||||
import { Buffer } from "node:buffer";
|
||||
import path from "node:path";
|
||||
import { exec, getExecOutput } from "@actions/exec";
|
||||
import { exec } from "@actions/exec";
|
||||
import pkgJson from "../package.json" with { type: "json" };
|
||||
|
||||
const tag = `v${pkgJson.version}`;
|
||||
@@ -20,37 +20,17 @@ const gitEnv = {
|
||||
|
||||
process.chdir(path.join(import.meta.dirname, ".."));
|
||||
|
||||
(async () => {
|
||||
const { exitCode, stderr } = await getExecOutput(
|
||||
`git`,
|
||||
["ls-remote", "--exit-code", "origin", "--tags", `refs/tags/${tag}`],
|
||||
{
|
||||
ignoreReturnCode: true,
|
||||
},
|
||||
);
|
||||
if (exitCode === 0) {
|
||||
console.log(
|
||||
`Action is not being published because version ${tag} is already published`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (exitCode !== 2) {
|
||||
throw new Error(`git ls-remote exited with ${exitCode}:\n${stderr}`);
|
||||
}
|
||||
await exec("git", ["checkout", "--detach"]);
|
||||
await exec("git", ["add", "--force", "dist"]);
|
||||
await exec("git", ["commit", "-m", tag]);
|
||||
|
||||
await exec("git", ["checkout", "--detach"]);
|
||||
await exec("git", ["add", "--force", "dist"]);
|
||||
await exec("git", ["commit", "-m", tag]);
|
||||
|
||||
await exec("changeset", ["git-tag"]);
|
||||
|
||||
if (isPrerelease) {
|
||||
await exec("git", ["push", "origin", `refs/tags/${tag}`], {
|
||||
env: gitEnv,
|
||||
});
|
||||
return;
|
||||
}
|
||||
await exec("changeset", ["git-tag"]);
|
||||
|
||||
if (isPrerelease) {
|
||||
await exec("git", ["push", "origin", `refs/tags/${tag}`], {
|
||||
env: gitEnv,
|
||||
});
|
||||
} else {
|
||||
await exec(
|
||||
"git",
|
||||
[
|
||||
@@ -64,4 +44,4 @@ process.chdir(path.join(import.meta.dirname, ".."));
|
||||
env: gitEnv,
|
||||
},
|
||||
);
|
||||
})();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user