mirror of
https://github.com/changesets/action
synced 2026-10-26 16:39:56 +08:00
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:
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@changesets/action": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Handle error when pushing git tags with the git CLI
|
||||||
+9
-7
@@ -213,18 +213,14 @@ export class GitHub {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async pushTag(tag: string) {
|
async pushTag(tag: string) {
|
||||||
|
try {
|
||||||
if (!this.pushWithGitCli) {
|
if (!this.pushWithGitCli) {
|
||||||
return this.octokit.rest.git
|
await this.octokit.rest.git.createRef({
|
||||||
.createRef({
|
|
||||||
...context.repo,
|
...context.repo,
|
||||||
ref: `refs/tags/${tag}`,
|
ref: `refs/tags/${tag}`,
|
||||||
sha: context.sha,
|
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], {
|
await exec("git", ["push", "origin", tag], {
|
||||||
cwd: this.cwd,
|
cwd: this.cwd,
|
||||||
env: {
|
env: {
|
||||||
@@ -233,6 +229,12 @@ export class GitHub {
|
|||||||
} as Record<string, string>,
|
} 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}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async prepareBranch(branch: string) {
|
async prepareBranch(branch: string) {
|
||||||
await switchToMaybeExistingBranch(branch, { cwd: this.cwd });
|
await switchToMaybeExistingBranch(branch, { cwd: this.cwd });
|
||||||
|
|||||||
Reference in New Issue
Block a user