mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
Avoid changing HEAD when executing publish (#81)
This commit is contained in:
Vendored
+2
-2
File diff suppressed because one or more lines are too long
+8
-8
@@ -22,20 +22,20 @@ export const pullBranch = async (branch: string) => {
|
|||||||
|
|
||||||
export const push = async (
|
export const push = async (
|
||||||
branch: string,
|
branch: string,
|
||||||
{ force, includeTags }: { force?: boolean; includeTags?: boolean } = {}
|
{ force }: { force?: boolean } = {}
|
||||||
) => {
|
) => {
|
||||||
await exec(
|
await exec(
|
||||||
"git",
|
"git",
|
||||||
[
|
["push", "origin", `HEAD:${branch}`, force && "--force"].filter<string>(
|
||||||
"push",
|
Boolean as any
|
||||||
"origin",
|
)
|
||||||
`HEAD:${branch}`,
|
|
||||||
includeTags && "--tags",
|
|
||||||
force && "--force",
|
|
||||||
].filter<string>(Boolean as any)
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const pushTags = async () => {
|
||||||
|
await exec("git", ["push", "origin", "--tags"]);
|
||||||
|
};
|
||||||
|
|
||||||
export const switchToMaybeExistingBranch = async (branch: string) => {
|
export const switchToMaybeExistingBranch = async (branch: string) => {
|
||||||
let { stderr } = await execWithOutput("git", ["checkout", branch], {
|
let { stderr } = await execWithOutput("git", ["checkout", branch], {
|
||||||
ignoreReturnCode: true,
|
ignoreReturnCode: true,
|
||||||
|
|||||||
+1
-3
@@ -69,7 +69,6 @@ export async function runPublish({
|
|||||||
githubToken,
|
githubToken,
|
||||||
cwd = process.cwd(),
|
cwd = process.cwd(),
|
||||||
}: PublishOptions): Promise<PublishResult> {
|
}: PublishOptions): Promise<PublishResult> {
|
||||||
let branch = github.context.ref.replace("refs/heads/", "");
|
|
||||||
let octokit = github.getOctokit(githubToken);
|
let octokit = github.getOctokit(githubToken);
|
||||||
let [publishCommand, ...publishArgs] = script.split(/\s+/);
|
let [publishCommand, ...publishArgs] = script.split(/\s+/);
|
||||||
|
|
||||||
@@ -79,8 +78,7 @@ export async function runPublish({
|
|||||||
{ cwd }
|
{ cwd }
|
||||||
);
|
);
|
||||||
|
|
||||||
await gitUtils.pullBranch(branch);
|
await gitUtils.pushTags();
|
||||||
await gitUtils.push(branch, { includeTags: true });
|
|
||||||
|
|
||||||
let { packages, tool } = await getPackages(cwd);
|
let { packages, tool } = await getPackages(cwd);
|
||||||
let releasedPackages: Package[] = [];
|
let releasedPackages: Package[] = [];
|
||||||
|
|||||||
Reference in New Issue
Block a user