Skip to content

Commit

Permalink
Merge pull request #3 from s0/github-api-tag-push
Browse files Browse the repository at this point in the history
Allow tag publish to fail, assume it was manually published
  • Loading branch information
s0 authored Aug 25, 2024
2 parents c1fe2d5 + 1d9e84e commit d106fcc
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
5 changes: 5 additions & 0 deletions .changeset/thick-jars-chew.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@changesets/action": minor
---

Handle custom publish commands more gracefully
30 changes: 20 additions & 10 deletions src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,16 @@ export async function runPublish({
const tagName = `${pkg.packageJson.name}@${pkg.packageJson.version}`;
// Tag will only be created locally,
// Create it using the GitHub API so it's signed.
await octokit.rest.git.createRef({
...github.context.repo,
ref: `refs/tags/${tagName}`,
sha: github.context.sha,
});
await octokit.rest.git
.createRef({
...github.context.repo,
ref: `refs/tags/${tagName}`,
sha: github.context.sha,
})
.catch((err) => {
// Assuming tag was manually pushed in custom publish script
core.warning(`Failed to create tag ${tagName}: ${err.message}`);
});
if (createGithubReleases) {
await createRelease(octokit, { pkg, tagName });
}
Expand All @@ -189,11 +194,16 @@ export async function runPublish({
const tagName = `v${pkg.packageJson.version}`;
// Tag will only be created locally,
// Create it using the GitHub API so it's signed.
await octokit.rest.git.createRef({
...github.context.repo,
ref: `refs/tags/${tagName}`,
sha: github.context.sha,
});
await octokit.rest.git
.createRef({
...github.context.repo,
ref: `refs/tags/${tagName}`,
sha: github.context.sha,
})
.catch((err) => {
// Assuming tag was manually pushed in custom publish script
core.warning(`Failed to create tag ${tagName}: ${err.message}`);
});
if (createGithubReleases) {
await createRelease(octokit, { pkg, tagName });
}
Expand Down

0 comments on commit d106fcc

Please sign in to comment.