Avoid changing HEAD when executing publish (#81)

This commit is contained in:
Mateusz Burzyński
2021-03-23 11:04:41 +01:00
committed by GitHub
parent b5c0c12a1d
commit aacbc22392
3 changed files with 11 additions and 13 deletions
+8 -8
View File
@@ -22,20 +22,20 @@ export const pullBranch = async (branch: string) => {
export const push = async (
branch: string,
{ force, includeTags }: { force?: boolean; includeTags?: boolean } = {}
{ force }: { force?: boolean } = {}
) => {
await exec(
"git",
[
"push",
"origin",
`HEAD:${branch}`,
includeTags && "--tags",
force && "--force",
].filter<string>(Boolean as any)
["push", "origin", `HEAD:${branch}`, force && "--force"].filter<string>(
Boolean as any
)
);
};
export const pushTags = async () => {
await exec("git", ["push", "origin", "--tags"]);
};
export const switchToMaybeExistingBranch = async (branch: string) => {
let { stderr } = await execWithOutput("git", ["checkout", branch], {
ignoreReturnCode: true,
+1 -3
View File
@@ -69,7 +69,6 @@ export async function runPublish({
githubToken,
cwd = process.cwd(),
}: PublishOptions): Promise<PublishResult> {
let branch = github.context.ref.replace("refs/heads/", "");
let octokit = github.getOctokit(githubToken);
let [publishCommand, ...publishArgs] = script.split(/\s+/);
@@ -79,8 +78,7 @@ export async function runPublish({
{ cwd }
);
await gitUtils.pullBranch(branch);
await gitUtils.push(branch, { includeTags: true });
await gitUtils.pushTags();
let { packages, tool } = await getPackages(cwd);
let releasedPackages: Package[] = [];