diff --git a/CLUSTERFLUX_PUBLIC_TREE.json b/CLUSTERFLUX_PUBLIC_TREE.json index db6f6e2..c41cefc 100644 --- a/CLUSTERFLUX_PUBLIC_TREE.json +++ b/CLUSTERFLUX_PUBLIC_TREE.json @@ -1,7 +1,7 @@ { "kind": "clusterflux-filtered-public-tree", - "source_commit": "45bbc215f681e4dd414c4919263626ecee018abe", - "release_name": "release-45bbc215f681", + "source_commit": "33ad736f0817e8e0ae4043a4c91f198115364d9f", + "release_name": "release-33ad736f0817", "filtered_out": [ "private/**", "internal/**", diff --git a/scripts/prepare-public-release.js b/scripts/prepare-public-release.js index 3252b61..8efd0d1 100755 --- a/scripts/prepare-public-release.js +++ b/scripts/prepare-public-release.js @@ -947,7 +947,6 @@ function publishPublicTree(releaseName, sourceCommit, publicTreeIdentity) { } run("git", ["init"], { cwd: publicTree }); - run("git", ["checkout", "-B", publicRepoBranch], { cwd: publicTree }); run("git", ["config", "user.name", "Clusterflux release"], { cwd: publicTree, }); @@ -955,10 +954,29 @@ function publishPublicTree(releaseName, sourceCommit, publicTreeIdentity) { cwd: publicTree, }); run("git", ["add", "."], { cwd: publicTree }); + const tree = commandOutput("git", ["write-tree"], { cwd: publicTree }); + run("git", ["remote", "add", "public", remote], { cwd: publicTree }); run( "git", [ - "commit", + "fetch", + "public", + `refs/heads/${publicRepoBranch}:refs/remotes/public/${publicRepoBranch}`, + ], + { cwd: publicTree } + ); + const parent = commandOutput( + "git", + ["rev-parse", `refs/remotes/public/${publicRepoBranch}`], + { cwd: publicTree } + ); + result.commit = commandOutput( + "git", + [ + "commit-tree", + tree, + "-p", + parent, "-m", `Public release ${releaseName}`, "-m", @@ -968,22 +986,12 @@ function publishPublicTree(releaseName, sourceCommit, publicTreeIdentity) { ], { cwd: publicTree } ); - result.commit = commandOutput("git", ["rev-parse", "HEAD"], { cwd: publicTree }); - run("git", ["remote", "add", "public", remote], { cwd: publicTree }); - const pushArgs = ["push", "public", `HEAD:${publicRepoBranch}`]; - if (boolEnv("CLUSTERFLUX_PUBLIC_REPO_PUSH_FORCE_WITH_LEASE")) { - run( - "git", - [ - "fetch", - "public", - `refs/heads/${publicRepoBranch}:refs/remotes/public/${publicRepoBranch}`, - ], - { cwd: publicTree } - ); - pushArgs.splice(1, 0, "--force-with-lease"); - } - run("git", pushArgs, { cwd: publicTree }); + run("git", ["update-ref", `refs/heads/${publicRepoBranch}`, result.commit], { + cwd: publicTree, + }); + run("git", ["push", "public", `${result.commit}:${publicRepoBranch}`], { + cwd: publicTree, + }); result.pushed = true; return result; }