Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/cool-rules-shine.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@changesets/action": patch
---

Handle error when pushing git tags with the git CLI
30 changes: 16 additions & 14 deletions src/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down