Skip to content

Commit 0a87def

Browse files
pelikhanCopilot
andauthored
fix: avoid persisting release checkout credentials (#71802)
Keep checkout authentication for tag pushes while disabling unnecessary credential retention in the separate release job. Cover both source and compiled jobs with a credential regression test. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
1 parent d3a9841 commit 0a87def

3 files changed

Lines changed: 21 additions & 5 deletions

File tree

‎.github/workflows/release.lock.yml‎

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎.github/workflows/release.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -615,7 +615,7 @@ jobs:
615615
uses: actions/checkout@v7.0.1
616616
with:
617617
fetch-depth: 0
618-
persist-credentials: true
618+
persist-credentials: false
619619

620620
- name: Download release binaries
621621
uses: actions/download-artifact@v8.0.2

‎scripts/release-workflows.test.cjs‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ const promote = script(promotion, "Validate and promote release");
2525
const compare = script(alignment, "Compare latest releases");
2626
const stable = { tag_name: "v1.2.3", draft: false, prerelease: false };
2727

28+
test("release checkout is credential-free while tag publishing retains git authentication", () => {
29+
const lock = fs.readFileSync(path.join(root, ".github/workflows/release.lock.yml"), "utf8");
30+
for (const source of [release, lock]) {
31+
const releaseJob = source.split("\n release:\n")[1]?.split(/\n \w+:\n/)[0];
32+
assert.ok(releaseJob, "Missing release job");
33+
assert.match(releaseJob, /fetch-depth: 0\n +persist-credentials: false/);
34+
assert.match(releaseJob, /GH_TOKEN: \$\{\{ secrets.GITHUB_TOKEN \}\}/);
35+
assert.doesNotMatch(releaseJob, /\bgit (?:fetch|pull|push|clone|ls-remote)\b/);
36+
37+
const pushTagJob = source.split("\n push_tag:\n")[1]?.split(/\n \w+:\n/)[0];
38+
assert.ok(pushTagJob, "Missing push_tag job");
39+
assert.match(pushTagJob, /persist-credentials: true/);
40+
assert.match(pushTagJob, /git push origin "\$RELEASE_TAG"/);
41+
}
42+
});
43+
2844
test("release safe-output example preserves apostrophes, newlines, and Unicode through Bash and JSON", () => {
2945
const outputFormat = release.split("## Output Format\n")[1];
3046
assert.ok(outputFormat, "Missing release output instructions");

0 commit comments

Comments
 (0)