diff --git a/.changeset/cold-dryers-march.md b/.changeset/cold-dryers-march.md new file mode 100644 index 00000000..2b7eef3f --- /dev/null +++ b/.changeset/cold-dryers-march.md @@ -0,0 +1,5 @@ +--- +"@changesets/action": patch +--- + +Fix custom publish scripts that don't create tags locally diff --git a/.changeset/three-women-brush.md b/.changeset/three-women-brush.md new file mode 100644 index 00000000..9cd98f5b --- /dev/null +++ b/.changeset/three-women-brush.md @@ -0,0 +1,5 @@ +--- +"@changesets/action": patch +--- + +Fix tags not pushing when `createGithubReleases` is false diff --git a/src/git.ts b/src/git.ts index 3e32a2c4..fa05ed10 100644 --- a/src/git.ts +++ b/src/git.ts @@ -88,7 +88,10 @@ export class Git { core.warning(`Failed to create tag ${tag}: ${err.message}`); }); } - await exec("git", ["push", "origin", tag], { cwd: this.cwd }); + await exec("git", ["push", "origin", tag], { + cwd: this.cwd, + ignoreReturnCode: true, + }); } async prepareBranch(branch: string) { diff --git a/src/run.ts b/src/run.ts index 18ec1da4..42736d08 100644 --- a/src/run.ts +++ b/src/run.ts @@ -115,15 +115,15 @@ export async function runPublish({ releasedPackages.push(pkg); } - if (createGithubReleases) { - await Promise.all( - releasedPackages.map(async (pkg) => { - const tagName = `${pkg.packageJson.name}@${pkg.packageJson.version}`; - await git.pushTag(tagName); + await Promise.all( + releasedPackages.map(async (pkg) => { + const tagName = `${pkg.packageJson.name}@${pkg.packageJson.version}`; + await git.pushTag(tagName); + if (createGithubReleases) { await createRelease(octokit, { pkg, tagName }); - }) - ); - } + } + }) + ); } else { if (packages.length === 0) { throw new Error( @@ -139,9 +139,9 @@ export async function runPublish({ if (match) { releasedPackages.push(pkg); + const tagName = `v${pkg.packageJson.version}`; + await git.pushTag(tagName); if (createGithubReleases) { - const tagName = `v${pkg.packageJson.version}`; - await git.pushTag(tagName); await createRelease(octokit, { pkg, tagName }); } break; @@ -330,7 +330,7 @@ export async function runVersion({ /** * Fetch any existing pull requests that are open against the branch, * before we push any changes that may inadvertently close the existing PRs. - * + * * (`@changesets/ghcommit` has to reset the branch to the same commit as the base, * which GitHub will then react to by closing the PRs) */ @@ -340,7 +340,13 @@ export async function runVersion({ head: `${github.context.repo.owner}:${versionBranch}`, base: branch, }); - core.info(`Existing pull requests: ${JSON.stringify(existingPullRequests.data, null, 2)}`); + core.info( + `Existing pull requests: ${JSON.stringify( + existingPullRequests.data, + null, + 2 + )}` + ); await git.pushChanges({ branch: versionBranch, message: finalCommitMessage });