Skip to content

Commit 285eda6

Browse files
committed
align with future release move changes
1 parent c9fd356 commit 285eda6

13 files changed

+85
-44
lines changed

.github/workflows/bump-packages.yml renamed to .github/workflows/bump-auxiliary-packages.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Bump packages
1+
name: Bump auxiliary package versions
22
on:
33
workflow_dispatch:
44
push:
@@ -38,19 +38,19 @@ jobs:
3838
3939
- name: Bump packages
4040
env:
41-
LAST_BUMP_COMMIT_MESSAGE: "chore(release): bump package versions"
41+
LAST_BUMP_COMMIT_MESSAGE: "chore(release): bump auxiliary package versions"
4242
run: |
43-
npm run bump-packages
43+
npm run bump-auxiliary
4444
git add .
4545
git commit --no-allow-empty -m "$LAST_BUMP_COMMIT_MESSAGE" || true
4646
4747
- name: Create Pull Request
4848
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # 7.0.5
4949
with:
5050
token: ${{ steps.app-token.outputs.token }}
51-
commit-message: "chore(release): bump package versions"
52-
branch: ci/bump-packages
53-
title: "chore(release): bump package versions"
51+
commit-message: "chore(release): bump auxiliary package versions"
52+
branch: ci/bump-auxiliary-packages
53+
title: "chore(release): bump auxiliary package versions"
5454
labels: no-title-validation
5555
body: |
5656
- Bump package versions

.github/workflows/release-packages.yml renamed to .github/workflows/release-auxiliary-packages.yml

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Publish
1+
name: Publish Auxiliary Packages
22
on:
33
# NOTE: avoid using the manual execution unless is the only way to fix some issue,
44
# rather retry failed jobs in case of flakes. The manual execution can potentially
@@ -53,9 +53,3 @@ jobs:
5353
git update-index --assume-unchanged .npmrc
5454
npm run publish-packages
5555
56-
- name: "Publish tags"
57-
run: |
58-
npx lerna list -a --json | \
59-
jq -r '.[] | .name + "@" + .version' | \
60-
xargs -i sh -c "git tag -a {} -m {} || true"
61-
git push --follow-tags

package-lock.json

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@
7171
"prepare": "husky",
7272
"precommit": "precommit",
7373
"preinstall": "node scripts/sort-workspaces.js",
74-
"bump-packages": "npm run bump-packages --workspace @mongosh/build",
75-
"publish-packages": "lerna publish from-package --no-verify-access --no-push --no-git-tag-version --yes"
74+
"bump-auxiliary": "npm run bump-auxiliary --workspace @mongosh/build",
75+
"publish-auxiliary": "npm run publish-auxiliary --workspace @mongosh/build"
7676
},
7777
"config": {
7878
"unsafe-perm": true
@@ -100,6 +100,7 @@
100100
"@babel/compat-data": "^7.9.0",
101101
"@mongodb-js/monorepo-tools": "^1.1.10",
102102
"@mongodb-js/sbom-tools": "^0.7.0",
103+
"@pkgjs/nv": "^0.2.2",
103104
"@types/chai": "^4.2.5",
104105
"@types/mocha": "^5.2.7",
105106
"@types/node": "^14.14.6",
@@ -109,6 +110,7 @@
109110
"@types/which": "^1.3.2",
110111
"chai": "^4.2.0",
111112
"cross-env": "^6.0.3",
113+
"depcheck": "^1.4.7",
112114
"duplexpair": "^1.0.2",
113115
"find-up": "^5.0.0",
114116
"glob": "^10.3.12",
@@ -120,7 +122,7 @@
120122
"nyc": "^15.1.0",
121123
"pkg-up": "^3.1.0",
122124
"rimraf": "^3.0.2",
123-
"semver": "^7.5.4",
125+
"semver": "^7.6.3",
124126
"sinon": "^7.5.0",
125127
"sinon-chai": "^3.5.0",
126128
"terser-webpack-plugin": "^4.2.3",
@@ -132,9 +134,7 @@
132134
"webpack-bundle-analyzer": "^4.7.0",
133135
"webpack-cli": "^4.3.1",
134136
"which": "^2.0.2",
135-
"yaml": "^1.10.0",
136-
"depcheck": "^1.4.7",
137-
"@pkgjs/nv": "^0.2.2"
137+
"yaml": "^1.10.0"
138138
},
139139
"optionalDependencies": {
140140
"lerna": "^8.1.8"

packages/build/package.json

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@
2626
"evergreen-release": "ts-node -r ../../scripts/import-expansions.js src/index.ts",
2727
"release": "ts-node src/index.ts trigger-release",
2828
"prettier": "prettier",
29+
"bump": "ts-node src/index.ts bump",
30+
"publish": "ts-node src/index.ts publish",
31+
"bump-auxiliary": "ts-node src/index.ts bump --auxiliary",
32+
"publish-auxiliary": "ts-node src/index.ts publish --auxiliary",
2933
"reformat": "npm run prettier -- --write . && npm run eslint --fix"
3034
},
3135
"license": "Apache-2.0",

packages/build/src/config/config.ts

+1
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,5 @@ export interface Config {
4646
artifactUrlExtraTag?: string;
4747
manpage?: ManPageConfig;
4848
isDryRun?: boolean;
49+
isAuxiliaryOnly?: boolean;
4950
}

packages/build/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ if (require.main === module) {
5959
}
6060

6161
config.isDryRun ||= process.argv.includes('--dry-run');
62+
config.isAuxiliaryOnly ||= process.argv.includes('--auxiliary');
6263

6364
await release(command, config);
6465
}

packages/build/src/npm-packages/bump.ts

+9-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { spawnSync } from '../helpers';
22
import {
3-
IGNORE_BUMP_PACKAGES,
3+
MONGOSH_RELEASE_ONLY_PACKAGES,
44
MONGOSH_RELEASE_PACKAGES,
55
PROJECT_ROOT,
66
} from './constants';
@@ -10,9 +10,13 @@ import path from 'path';
1010
import { getPackagesInTopologicalOrder } from '@mongodb-js/monorepo-tools';
1111

1212
/** Bumps only the main mongosh release packages to the set version. */
13-
export async function bumpMongoshReleasePackages(
14-
version: string
15-
): Promise<void> {
13+
export async function bumpMongoshReleasePackages(): Promise<void> {
14+
const version = process.env.MONGOSH_RELEASE_VERSION;
15+
if (!version) {
16+
throw new Error(
17+
'MONGOSH_RELEASE_VERSION version not specified during mongosh bump'
18+
);
19+
}
1620
console.info(`mongosh: Bumping package versions to ${version}`);
1721
const monorepoRootPath = path.resolve(__dirname, '..', '..', '..', '..');
1822
const packages = await getPackagesInTopologicalOrder(monorepoRootPath);
@@ -62,7 +66,7 @@ export function bumpIndependentPackages() {
6266
env: {
6367
...process.env,
6468
SKIP_BUMP_PACKAGES: [
65-
...IGNORE_BUMP_PACKAGES,
69+
...MONGOSH_RELEASE_ONLY_PACKAGES,
6670
...MONGOSH_RELEASE_PACKAGES,
6771
].join(','),
6872
},

packages/build/src/npm-packages/constants.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ export const LERNA_BIN = path.resolve(
1111
/** Packages which get bumped only as part of the mongosh release. */
1212
export const MONGOSH_RELEASE_PACKAGES = ['mongosh', '@mongosh/cli-repl'];
1313

14-
/** Packages which always get ignored when doing a release or bump */
15-
export const IGNORE_BUMP_PACKAGES = [
14+
/** Packages which always get excluded when doing a release or bump */
15+
export const EXCLUDE_RELEASE_PACKAGES = [
1616
'@mongodb-js/eslint-config-mongosh',
1717
'@mongodb-js/tsconfig-mongosh',
1818
];

packages/build/src/npm-packages/publish.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ describe('npm-packages publishNpmPackages', function () {
3030
listNpmPackages.returns(packages);
3131

3232
publishNpmPackages(
33+
false,
3334
false,
3435
listNpmPackages,
3536
markBumpedFilesAsAssumeUnchanged,
@@ -69,6 +70,7 @@ describe('npm-packages publishNpmPackages', function () {
6970

7071
try {
7172
publishNpmPackages(
73+
false,
7274
false,
7375
listNpmPackages,
7476
markBumpedFilesAsAssumeUnchanged,

packages/build/src/npm-packages/publish.ts

+47-14
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,40 @@
11
import path from 'path';
2-
import { LERNA_BIN, PROJECT_ROOT } from './constants';
2+
import {
3+
EXCLUDE_RELEASE_PACKAGES,
4+
LERNA_BIN,
5+
MONGOSH_RELEASE_PACKAGES,
6+
PROJECT_ROOT,
7+
} from './constants';
38
import type { LernaPackageDescription } from './list';
49
import { listNpmPackages as listNpmPackagesFn } from './list';
510
import { spawnSync } from '../helpers/spawn-sync';
11+
import type { SpawnSyncOptionsWithStringEncoding } from 'child_process';
612

713
export function publishNpmPackages(
8-
isDryRun: boolean,
14+
isDryRun = false,
15+
isAuxiliaryOnly = false,
916
listNpmPackages: typeof listNpmPackagesFn = listNpmPackagesFn,
1017
markBumpedFilesAsAssumeUnchangedFn: typeof markBumpedFilesAsAssumeUnchanged = markBumpedFilesAsAssumeUnchanged,
1118
spawnSyncFn: typeof spawnSync = spawnSync
1219
): void {
13-
const packages = listNpmPackages();
20+
const commandOptions: SpawnSyncOptionsWithStringEncoding = {
21+
stdio: 'inherit',
22+
cwd: PROJECT_ROOT,
23+
encoding: 'utf8',
24+
env: {
25+
...process.env,
26+
...(isDryRun ? { npm_config_dry_run: 'true' } : {}),
27+
},
28+
};
29+
let packages = listNpmPackages().filter(
30+
(packageConfig) => !EXCLUDE_RELEASE_PACKAGES.includes(packageConfig.name)
31+
);
1432

33+
if (isAuxiliaryOnly) {
34+
packages = packages.filter(
35+
(packageConfig) => !MONGOSH_RELEASE_PACKAGES.includes(packageConfig.name)
36+
);
37+
}
1538
// Lerna requires a clean repository for a publish from-package (--force-publish does not have any effect here)
1639
// we use git update-index --assume-unchanged on files we know have been bumped
1740
markBumpedFilesAsAssumeUnchangedFn(packages, true);
@@ -23,26 +46,36 @@ export function publishNpmPackages(
2346
'from-package',
2447
'--no-private',
2548
'--no-changelog',
26-
'--no-push',
2749
'--exact',
28-
'--no-git-tag-version',
50+
// During mongosh releases we handle the tags manually
51+
...(!isAuxiliaryOnly ? ['--no-git-tag-version', '--no-push'] : []),
2952
'--force-publish',
3053
'--yes',
3154
'--no-verify-access',
3255
],
33-
{
34-
stdio: 'inherit',
35-
cwd: PROJECT_ROOT,
36-
encoding: 'utf8',
37-
env: {
38-
...process.env,
39-
...(isDryRun ? { npm_config_dry_run: 'true' } : {}),
40-
},
41-
}
56+
commandOptions
4257
);
4358
} finally {
4459
markBumpedFilesAsAssumeUnchangedFn(packages, false);
4560
}
61+
62+
if (!isAuxiliaryOnly) {
63+
const mongoshVersion = packages.find(
64+
(packageConfig) => packageConfig.name === 'mongosh'
65+
)?.version;
66+
67+
if (!mongoshVersion) {
68+
throw new Error('Mongosh package not found');
69+
}
70+
71+
spawnSync(
72+
'git',
73+
['tag', '-a', mongoshVersion, '-m', mongoshVersion],
74+
commandOptions
75+
);
76+
77+
spawnSync('git', ['push', '--follow-tags'], commandOptions);
78+
}
4679
}
4780

4881
export function markBumpedFilesAsAssumeUnchanged(

packages/build/src/release.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,9 @@ export async function release(
5757

5858
if (command === 'bump') {
5959
bumpIndependentPackages();
60-
await bumpMongoshReleasePackages(config.version);
60+
if (!config.isAuxiliaryOnly) {
61+
await bumpMongoshReleasePackages();
62+
}
6163
return;
6264
}
6365

packages/build/src/run-publish.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export async function runPublish(
8181
// ensures the segment api key to be present in the published packages
8282
await writeBuildInfo(config, 'packaged');
8383

84-
publishNpmPackages(!!config.isDryRun);
84+
publishNpmPackages(config.isDryRun, config.isAuxiliaryOnly);
8585

8686
await publishToHomebrew(
8787
homebrewCoreGithubRepo,

0 commit comments

Comments
 (0)