Handle error when pushing git tags with the git CLI (#735)

* Handle error when pushing git tags with the git CLI

* Update message
This commit is contained in:
Bjorn Lu
2026-09-07 11:45:47 +00:00
committed by GitHub
parent e08fde7435
commit 88338839e3
2 changed files with 21 additions and 14 deletions
+5
View File
@@ -0,0 +1,5 @@
---
"@changesets/action": patch
---
Handle error when pushing git tags with the git CLI
+16 -14
View File
@@ -213,25 +213,27 @@ export class GitHub {
}
async pushTag(tag: string) {
if (!this.pushWithGitCli) {
return this.octokit.rest.git
.createRef({
try {
if (!this.pushWithGitCli) {
await this.octokit.rest.git.createRef({
...context.repo,
ref: `refs/tags/${tag}`,
sha: context.sha,
})
.catch((err) => {
// Assuming tag was manually pushed in custom publish script
core.warning(`Failed to create git tag "${tag}": ${err.message}`);
});
} else {
await exec("git", ["push", "origin", tag], {
cwd: this.cwd,
env: {
...process.env,
...(await this.#getCliAuthEnv()),
} as Record<string, string>,
});
}
} catch (err) {
core.warning(
`Failed to create git tag "${tag}". Assuming it was manually pushed by the publish script: ${(err as Error).message}`,
);
}
await exec("git", ["push", "origin", tag], {
cwd: this.cwd,
env: {
...process.env,
...(await this.#getCliAuthEnv()),
} as Record<string, string>,
});
}
async prepareBranch(branch: string) {