From 37d14fc142519c9a524e14ac5ca6102e0c19389c Mon Sep 17 00:00:00 2001 From: anguyen-yext2 Date: Thu, 9 Oct 2025 18:32:53 -0400 Subject: [PATCH 1/4] hotfix: fix release tag in trusted publishing workflow --- scripts/release.ts | 2 +- scripts/verifyPublish.ts | 13 ++----------- 2 files changed, 3 insertions(+), 12 deletions(-) diff --git a/scripts/release.ts b/scripts/release.ts index e1b09e9c..0a3ea427 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -52,7 +52,7 @@ import { process.exit(1); } - const tag = `${packageName}@${targetVersion}`; + const tag = `v${targetVersion}`; if (targetVersion.includes('beta') && !args.tag) { args.tag = 'beta'; diff --git a/scripts/verifyPublish.ts b/scripts/verifyPublish.ts index b3dc0e05..ea442707 100644 --- a/scripts/verifyPublish.ts +++ b/scripts/verifyPublish.ts @@ -8,18 +8,9 @@ import { args, getPackageInfo } from './releaseUtils.js'; process.exit(1); } - const versionIndex = tag.lastIndexOf('@'); - const pkgName = tag.slice(0, versionIndex); - const version = tag.slice(versionIndex + 1); + const [, version] = tag.split('v'); - const { pkg, currentVersion } = await getPackageInfo(); - const packageName = pkg.name; - if (pkgName !== packageName) { - console.error( - `Package name from tag '${pkgName}' mismatches with package '${packageName}'` - ); - process.exit(1); - } + const { currentVersion } = await getPackageInfo(); if (currentVersion !== version) { console.error( `Package version from tag '${version}' mismatches with current version '${currentVersion}'` From a19f2caa3ff908aca42f48652b33e424cf9a2302 Mon Sep 17 00:00:00 2001 From: anguyen-yext2 Date: Thu, 9 Oct 2025 18:39:16 -0400 Subject: [PATCH 2/4] remove pkgName from release script --- scripts/release.ts | 8 +++----- scripts/releaseUtils.ts | 19 ++++++++----------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/scripts/release.ts b/scripts/release.ts index 0a3ea427..6ff78b78 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -20,11 +20,9 @@ import { (async () => { let targetVersion: string | undefined; - const { currentVersion, pkg, pkgPath, pkgDir } = await getPackageInfo(); + const { currentVersion, pkgPath, pkgDir } = await getPackageInfo(); - const packageName = pkg.name; - - await logRecentCommits(packageName); + await logRecentCommits(); if (!targetVersion) { const { release }: { release: string } = await prompts({ @@ -75,7 +73,7 @@ import { updateVersion(pkgDir, pkgPath, targetVersion); step('\nGenerating changelog...'); - const latestTag = await getLatestTag(packageName); + const latestTag = await getLatestTag(); if (!latestTag) { step('\nNo previous tag, skipping changelog generation.'); } else { diff --git a/scripts/releaseUtils.ts b/scripts/releaseUtils.ts index 43a2d419..a30bcf09 100644 --- a/scripts/releaseUtils.ts +++ b/scripts/releaseUtils.ts @@ -163,28 +163,25 @@ export function updateVersion(pkgDir: string, pkgPath: string, version: string): execSync('npm install', { cwd: pkgDir, stdio: 'inherit' }); } -export async function getLatestTag(pkgName: string): Promise { - const tags = (await run('git', ['tag'], { stdio: 'pipe' })).stdout +export async function getLatestTag(): Promise { + return (await run('git', ['tag'], { stdio: 'pipe' })).stdout .split(/\n/) - .filter(Boolean); - const prefix = `${pkgName}@`; - return tags - .filter((tag) => tag.startsWith(prefix)) + .filter(Boolean) .sort() .reverse()[0]; } -export async function logRecentCommits(pkgName: string): Promise { - const tag = await getLatestTag(pkgName); +export async function logRecentCommits(): Promise { + const tag = await getLatestTag(); if (!tag) return; const sha = await run('git', ['rev-list', '-n', '1', tag], { stdio: 'pipe', }).then((res) => res.stdout.trim()); console.log( colors.bold( - `\n${colors.blue('i')} Commits of ${colors.green( - pkgName - )} since ${colors.green(tag)} ${colors.gray(`(${sha.slice(0, 5)})`)}` + `\n${colors.blue('i')} Commits of since ${colors.green( + tag, + )} ${colors.gray(`(${sha.slice(0, 5)})`)}` ) ); await run( From e56cc4b4aa6f21983c1d11e17bc8530fe181ab0e Mon Sep 17 00:00:00 2001 From: anguyen-yext2 Date: Mon, 13 Oct 2025 14:52:21 -0400 Subject: [PATCH 3/4] refactor --- scripts/release.ts | 65 ++++++++++++++--------------------------- scripts/releaseUtils.ts | 11 +++---- 2 files changed, 28 insertions(+), 48 deletions(-) diff --git a/scripts/release.ts b/scripts/release.ts index 6ff78b78..43dae282 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -8,6 +8,7 @@ import { args, getLatestTag, getPackageInfo, + getTagSha, getVersionChoices, isDryRun, logRecentCommits, @@ -18,31 +19,31 @@ import { } from './releaseUtils.js'; (async () => { - let targetVersion: string | undefined; const { currentVersion, pkgPath, pkgDir } = await getPackageInfo(); - await logRecentCommits(); + const latestTag = await getLatestTag(); + if (latestTag) { + const sha = await getTagSha(latestTag); + await logRecentCommits(latestTag, sha); + } - if (!targetVersion) { - const { release }: { release: string } = await prompts({ - type: 'select', - name: 'release', - message: 'Select release type', - choices: getVersionChoices(currentVersion), - }); + const { release }: { release: string } = await prompts({ + type: 'select', + name: 'release', + message: 'Select release type', + choices: getVersionChoices(currentVersion), + }); - if (release === 'custom') { - const res: { version: string } = await prompts({ - type: 'text', - name: 'version', - message: 'Input custom version', - initial: currentVersion, - }); - targetVersion = res.version; - } else { - targetVersion = release; - } + let targetVersion = release; + if (release === 'custom') { + const { version }: { version: string } = await prompts({ + type: 'text', + name: 'version', + message: 'Input custom version', + initial: currentVersion, + }); + targetVersion = version; } if (!semver.valid(targetVersion)) { @@ -52,13 +53,6 @@ import { const tag = `v${targetVersion}`; - if (targetVersion.includes('beta') && !args.tag) { - args.tag = 'beta'; - } - if (targetVersion.includes('alpha') && !args.tag) { - args.tag = 'alpha'; - } - const { yes }: { yes: boolean } = await prompts({ type: 'confirm', name: 'yes', @@ -72,21 +66,6 @@ import { step('\nUpdating package version...'); updateVersion(pkgDir, pkgPath, targetVersion); - step('\nGenerating changelog...'); - const latestTag = await getLatestTag(); - if (!latestTag) { - step('\nNo previous tag, skipping changelog generation.'); - } else { - const sha = ( - await run('git', ['rev-list', '-n', '1', latestTag], { - stdio: 'pipe', - }) - ).stdout.trim(); - - const changelogArgs = ['generate-changelog', `${sha}..HEAD`]; - await run('npx', changelogArgs, { cwd: pkgDir }); - } - const { stdout } = await run('git', ['diff'], { stdio: 'pipe' }); if (stdout) { step('\nCommitting changes...'); @@ -99,8 +78,8 @@ import { } step('\nPushing to GitHub...'); - await runIfNotDry('git', ['push', 'origin', `refs/tags/${tag}`]); await runIfNotDry('git', ['push']); + await runIfNotDry('git', ['push', 'origin', `refs/tags/${tag}`]); if (isDryRun) { console.log('\nDry run finished - run git diff to see package changes.'); diff --git a/scripts/releaseUtils.ts b/scripts/releaseUtils.ts index a30bcf09..d611f094 100644 --- a/scripts/releaseUtils.ts +++ b/scripts/releaseUtils.ts @@ -171,15 +171,16 @@ export async function getLatestTag(): Promise { .reverse()[0]; } -export async function logRecentCommits(): Promise { - const tag = await getLatestTag(); - if (!tag) return; - const sha = await run('git', ['rev-list', '-n', '1', tag], { +export async function getTagSha(tag: string): Promise { + return await run('git', ['rev-list', '-n', '1', tag], { stdio: 'pipe', }).then((res) => res.stdout.trim()); +} + +export async function logRecentCommits(tag: string, sha: string): Promise { console.log( colors.bold( - `\n${colors.blue('i')} Commits of since ${colors.green( + `\n${colors.blue('i')} Commits since ${colors.green( tag, )} ${colors.gray(`(${sha.slice(0, 5)})`)}` ) From 723fcdddebab5728694fd0e36cc8070d64e27da2 Mon Sep 17 00:00:00 2001 From: anguyen-yext2 Date: Mon, 13 Oct 2025 14:53:50 -0400 Subject: [PATCH 4/4] rm unused import --- scripts/release.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/release.ts b/scripts/release.ts index 43dae282..3b05ad6a 100644 --- a/scripts/release.ts +++ b/scripts/release.ts @@ -5,7 +5,6 @@ import prompts from 'prompts'; import semver from 'semver'; import colors from 'picocolors'; import { - args, getLatestTag, getPackageInfo, getTagSha,