Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions packages/build/src/npm-packages/bump.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,14 @@ describe('npm-packages bump', function () {
});

describe('bumpMongoshReleasePackages', function () {
it('throws if MONGOSH_RELEASE_VERSION is not set', async function () {
process.env.MONGOSH_RELEASE_VERSION = '';

it('throws if version is not set', async function () {
try {
await bumpMongoshReleasePackages();
await bumpMongoshReleasePackages('');
expect.fail('did not error');
} catch (error) {
expect(error).instanceOf(Error);
expect((error as Error).message).equals(
'MONGOSH_RELEASE_VERSION version not specified during mongosh bump'
'version not specified during mongosh bump'
);
}
});
Expand Down
12 changes: 6 additions & 6 deletions packages/build/src/npm-packages/bump.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ import path from 'path';
import { getPackagesInTopologicalOrder } from '@mongodb-js/monorepo-tools';

/** Bumps only the main mongosh release packages to the set version. */
export async function bumpMongoshReleasePackages(): Promise<void> {
const version = process.env.MONGOSH_RELEASE_VERSION;
export async function bumpMongoshReleasePackages(
version: string
): Promise<void> {
if (!version) {
throw new Error(
'MONGOSH_RELEASE_VERSION version not specified during mongosh bump'
);
throw new Error('version not specified during mongosh bump');
}
console.info(`mongosh: Bumping package versions to ${version}`);

console.info(`mongosh: Bumping mongosh release packages to ${version}`);
const monorepoRootPath = path.resolve(__dirname, '..', '..', '..', '..');
const packages = await getPackagesInTopologicalOrder(monorepoRootPath);

Expand Down
7 changes: 7 additions & 0 deletions packages/build/src/publish-mongosh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ import type { pushTags as pushTagsType } from './npm-packages';
import { type publishToNpm as publishToNpmType } from './npm-packages';
import type { PackageInformationProvider } from './packaging';
import { getPackageFile } from './packaging';
import {
bumpAuxiliaryPackages,
bumpMongoshReleasePackages,
} from './npm-packages/bump';

export async function publishMongosh(
config: Config,
Expand Down Expand Up @@ -59,6 +63,9 @@ export async function publishMongosh(
latestDraftTag.name
);

bumpAuxiliaryPackages();
await bumpMongoshReleasePackages(releaseVersion);

await publishArtifactsToBarque(
barque,
config.project as string,
Expand Down
2 changes: 1 addition & 1 deletion packages/build/src/release.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function release(
if (command === 'bump') {
bumpAuxiliaryPackages();
if (!config.useAuxiliaryPackagesOnly) {
await bumpMongoshReleasePackages();
await bumpMongoshReleasePackages(config.version);
}
return;
}
Expand Down
10 changes: 9 additions & 1 deletion packages/build/src/run-draft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import { downloadArtifactFromEvergreen as downloadArtifactFromEvergreenFn } from
import { generateChangelog as generateChangelogFn } from './git';
import type { GithubRepo } from '@mongodb-js/devtools-github-repo';
import { getPackageFile } from './packaging';
import {
bumpAuxiliaryPackages,
bumpMongoshReleasePackages,
} from './npm-packages/bump';

export async function runDraft(
config: Config,
Expand All @@ -16,7 +20,8 @@ export async function runDraft(
ensureGithubReleaseExistsAndUpdateChangelog: typeof ensureGithubReleaseExistsAndUpdateChangelogFn = ensureGithubReleaseExistsAndUpdateChangelogFn
): Promise<void> {
const { triggeringGitTag } = config;
if (!triggeringGitTag || !getReleaseVersionFromTag(triggeringGitTag)) {
const draftReleaseVersion = getReleaseVersionFromTag(triggeringGitTag);
if (!triggeringGitTag || !draftReleaseVersion) {
console.error(
'mongosh: skipping draft as not triggered by a git tag that matches a draft/release tag'
);
Expand Down Expand Up @@ -44,6 +49,9 @@ export async function runDraft(
);
await fs.mkdir(tmpDir, { recursive: true });

bumpAuxiliaryPackages();
await bumpMongoshReleasePackages(draftReleaseVersion);

for await (const variant of ALL_PACKAGE_VARIANTS) {
const tarballFile = getPackageFile(variant, config.packageInformation);
console.info(
Expand Down