diff --git a/package.json b/package.json index b83dc9e94332..856d825c5399 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,7 @@ "scripts": { "setup": "ts-node scripts/setup.ts", "build": "ts-node scripts/setup.ts --build", - "dry": "ts-node scripts/ci/publish.ts --dry-run", + "publish-all-dryrun": "ts-node scripts/ci/publish.ts --publish --dry-run", "publish-all": "ts-node scripts/ci/publish.ts --publish", "bump-engines": "ts-node scripts/bump-engines.ts", "test": "ts-node scripts/ci/publish.ts --test", diff --git a/scripts/ci/publish.ts b/scripts/ci/publish.ts index e0ed16fb98c3..68bf4121f796 100644 --- a/scripts/ci/publish.ts +++ b/scripts/ci/publish.ts @@ -306,7 +306,7 @@ function zeroOutPatch(version: string): string { /** * Takes the max dev version + 1 - * For now supporting 2.Y.Z-dev.# + * For now supporting X.Y.Z-dev.# * @param packages Local package definitions */ async function getNewDevVersion(packages: Packages): Promise { @@ -329,7 +329,7 @@ async function getNewDevVersion(packages: Packages): Promise { /** * Takes the max dev version + 1 - * For now supporting 2.Y.Z-dev.# + * For now supporting X.Y.Z-dev.# * @param packages Local package definitions */ async function getNewIntegrationVersion( @@ -407,10 +407,10 @@ async function getNewPatchDevVersion( packages: Packages, patchBranch: string, ): Promise { - const minor = getMinorFromPatchBranch(patchBranch)! + const { minor, major } = getSemverFromPatchBranch(patchBranch)! const currentPatch = await getCurrentPatchForMinor(minor) const newPatch = currentPatch + 1 - const newVersion = `2.${minor}.${newPatch}` + const newVersion = `${major}.${minor}.${newPatch}` const versions = [...(await getAllVersions(packages, 'dev', newVersion))] const maxIncrement = getMaxPatchVersionIncrement(versions) @@ -514,13 +514,17 @@ async function getNextMinorStable() { return increaseMinor(remoteVersion) } -// TODO: Adjust this for stable release -function getMinorFromPatchBranch(version: string): number | null { - const regex = /2\.(\d+)\.x/ +function getSemverFromPatchBranch( + version: string, +): { major: number; minor: number } | null { + const regex = /(\d+)\.(\d+)\.x/ const match = regex.exec(version) if (match) { - return Number(match[1]) + return { + major: Number(match[0]), + minor: Number(match[1]), + } } return null @@ -531,7 +535,7 @@ async function publish() { '--publish': Boolean, '--repo': String, '--dry-run': Boolean, - '--release': String, + '--release': String, // TODO What does that do? '--test': Boolean, }) @@ -583,16 +587,13 @@ async function publish() { )} is not a valid semver version.`, ) } - const releaseRegex = /2\.\d{1,2}\.\d{1,2}/ - if ( - !args['--release'].startsWith('2.') || - !releaseRegex.test(args['--release']) - ) { + const releaseRegex = /\d{1,2}\.\d{1,2}\.\d{1,2}/ + if (!releaseRegex.test(args['--release'])) { throw new Error( `New release version ${chalk.bold.underline( args['--release'], )} does not follow the stable naming scheme: ${chalk.bold.underline( - '2.x.y', + 'x.y.z', )}`, ) } @@ -632,10 +633,14 @@ async function publish() { let tagForE2ECheck: undefined | string const patchBranch = getPatchBranch() const branch = await getPrismaBranch() + + // For branches that are named "integration/" we publish to the integration npm tag if (branch && branch.startsWith('integration/')) { prisma2Version = await getNewIntegrationVersion(packages, branch) tag = 'integration' - } else if (patchBranch) { + } + // Is it a patch branch? (Like 2.20.x) + else if (patchBranch) { prisma2Version = await getNewPatchDevVersion(packages, patchBranch) tag = 'patch-dev' if (args['--release']) { @@ -717,7 +722,6 @@ Check them out at https://github.com/prisma/e2e-tests/actions?query=workflow%3At prisma2Version, tag, args['--release'], - patchBranch, ) console.log(`Waiting 5 sec so you can check it out first...`) await new Promise((r) => setTimeout(r, 5000)) @@ -731,7 +735,6 @@ Check them out at https://github.com/prisma/e2e-tests/actions?query=workflow%3At prisma2Version, tag, args['--release'], - patchBranch, ) const enginesCommit = await getEnginesCommit() @@ -994,7 +997,6 @@ async function publishPackages( prisma2Version: string, tag: string, releaseVersion?: string, - patchBranch?: string, ): Promise { // we need to release a new `prisma` CLI in all cases. // if there is a change in prisma-client-js, it will also use this new version @@ -1079,13 +1081,7 @@ async function publishPackages( const pkgDir = path.dirname(pkg.path) - let newVersion = prisma2Version - if ( - pkgName === '@prisma/engine-core' && - process.env.BUILDKITE_TAG === '2.0.1' - ) { - newVersion = '2.0.1-1' - } + const newVersion = prisma2Version console.log( `\nPublishing ${chalk.magentaBright( @@ -1124,14 +1120,8 @@ async function publishPackages( if (process.env.BUILDKITE) { await run(pkgDir, `pnpm run build`, dryRun) } - const skipPackages = - process.env.BUILDKITE_TAG === '2.0.1' - ? [ - '@prisma/debug', - '@prisma/generator-helper', - '@prisma/ink-components', - ] - : [] + + const skipPackages: string[] = [] if (!skipPackages.includes(pkgName)) { await run(pkgDir, `pnpm publish --no-git-checks --tag ${tag}`, dryRun) } @@ -1295,19 +1285,19 @@ async function areEndToEndTestsPassing(tag: string): Promise { return res.includes('passing') } -function getPatchBranch(): string | undefined { +function getPatchBranch() { if (process.env.PATCH_BRANCH) { return process.env.PATCH_BRANCH } if (process.env.BUILDKITE_BRANCH) { - const minor = getMinorFromPatchBranch(process.env.BUILDKITE_BRANCH) - if (minor !== null) { + const versions = getSemverFromPatchBranch(process.env.BUILDKITE_BRANCH) + if (versions?.minor !== null) { return process.env.BUILDKITE_BRANCH } } - return undefined + return null } type CommitInfo = {