From 97d28e9bdaa91ccca45c736ea8f3e331ffc3779b Mon Sep 17 00:00:00 2001 From: bluwy Date: Fri, 4 Sep 2026 16:24:09 +0800 Subject: [PATCH 1/2] Handle error when pushing git tags with the git CLI --- .changeset/cool-rules-shine.md | 5 +++++ src/github.ts | 29 +++++++++++++++-------------- 2 files changed, 20 insertions(+), 14 deletions(-) create mode 100644 .changeset/cool-rules-shine.md diff --git a/.changeset/cool-rules-shine.md b/.changeset/cool-rules-shine.md new file mode 100644 index 00000000..9267c5cf --- /dev/null +++ b/.changeset/cool-rules-shine.md @@ -0,0 +1,5 @@ +--- +"@changesets/action": patch +--- + +Handle error when pushing git tags with the git CLI diff --git a/src/github.ts b/src/github.ts index d44480c4..2576f0cd 100644 --- a/src/github.ts +++ b/src/github.ts @@ -213,25 +213,26 @@ 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 tag ${tag}: ${err.message}`); }); + } else { + await exec("git", ["push", "origin", tag], { + cwd: this.cwd, + env: { + ...process.env, + ...(await this.#getCliAuthEnv()), + } as Record, + }); + } + } catch (err) { + // Assuming tag was manually pushed in custom publish script + core.warning(`Failed to create tag ${tag}: ${(err as Error).message}`); } - await exec("git", ["push", "origin", tag], { - cwd: this.cwd, - env: { - ...process.env, - ...(await this.#getCliAuthEnv()), - } as Record, - }); } async prepareBranch(branch: string) { From 077c356eeccee2dc06a8474aecc7cf692a1a4eab Mon Sep 17 00:00:00 2001 From: bluwy Date: Sat, 5 Sep 2026 02:13:00 +0800 Subject: [PATCH 2/2] Update message --- src/github.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/github.ts b/src/github.ts index 65c6a37f..48886a8d 100644 --- a/src/github.ts +++ b/src/github.ts @@ -230,9 +230,8 @@ export class GitHub { }); } } catch (err) { - // Assuming tag was manually pushed in custom publish script core.warning( - `Failed to create git tag "${tag}": ${(err as Error).message}`, + `Failed to create git tag "${tag}". Assuming it was manually pushed by the publish script: ${(err as Error).message}`, ); } }