From f93f86f40164accd74f74963483de0fef6982c11 Mon Sep 17 00:00:00 2001 From: Herman Jensen Date: Wed, 21 May 2025 12:34:03 +0200 Subject: [PATCH 1/3] fix: push tags when createGithubReleases is false --- src/run.ts | 30 ++++++++++++++++++------------ 1 file changed, 18 insertions(+), 12 deletions(-) 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 }); From 02445c8341f0397e6a0aefa635935913f4d07dab Mon Sep 17 00:00:00 2001 From: Herman Jensen Date: Wed, 21 May 2025 12:47:44 +0200 Subject: [PATCH 2/3] fix: ignore return code --- src/git.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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) { From cecbdcd67b5f037207150121a6b513343818fe48 Mon Sep 17 00:00:00 2001 From: Herman Jensen Date: Wed, 21 May 2025 13:31:17 +0200 Subject: [PATCH 3/3] docs: add changesets --- .changeset/cold-dryers-march.md | 5 +++++ .changeset/three-women-brush.md | 5 +++++ 2 files changed, 10 insertions(+) create mode 100644 .changeset/cold-dryers-march.md create mode 100644 .changeset/three-women-brush.md 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