Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
49 changes: 49 additions & 0 deletions .github/workflows/temp-push-auxiliary-tags.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Temporary workflow just to fix currently not pushed tags for our release, will be removed.
name: Push Tags for Auxiliary Packages
on:
workflow_dispatch:

permissions:
contents: none # We use the github app to checkout and push tags

jobs:
publish:
runs-on: ubuntu-latest
environment: Production

steps:
- uses: mongodb-js/devtools-shared/actions/setup-bot-token@main
id: app-token
with:
app-id: ${{ vars.DEVTOOLS_BOT_APP_ID }}
private-key: ${{ secrets.DEVTOOLS_BOT_PRIVATE_KEY }}

- uses: actions/checkout@v4
with:
# don't checkout a detatched HEAD
ref: ${{ github.head_ref }}

# this is important so git log can pick up on
# the whole history to generate the list of AUTHORS
fetch-depth: "0"
token: ${{ steps.app-token.outputs.token }}

- name: "Use Node.js 20"
uses: actions/setup-node@v4
with:
node-version: 20.16.0

- name: Install npm@10.2.4
run: npm install -g npm@10.2.4

- name: Install Dependencies
run: |
npm ci

- name: "Pushing tags..."
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> ~/.npmrc
npm config list
npm run tags-auxiliary
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@
"precommit": "precommit",
"preinstall": "node scripts/sort-workspaces.js",
"bump-auxiliary": "npm run bump-auxiliary --workspace @mongosh/build",
"publish-auxiliary": "npm run publish-auxiliary --workspace @mongosh/build"
"publish-auxiliary": "npm run publish-auxiliary --workspace @mongosh/build",
"tags-auxiliary": "npm run tags-auxiliary --workspace @mongosh/build"
},
"config": {
"unsafe-perm": true
Expand Down
1 change: 1 addition & 0 deletions packages/build/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"publish": "ts-node src/index.ts publish",
"bump-auxiliary": "ts-node src/index.ts bump --auxiliary",
"publish-auxiliary": "ts-node src/index.ts publish --auxiliary",
"tags-auxiliary": "ts-node src/index.ts temp-push-auxiliary-tags --auxiliary",
"reformat": "npm run prettier -- --write . && npm run eslint --fix"
},
"license": "Apache-2.0",
Expand Down
1 change: 1 addition & 0 deletions packages/build/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const validCommands: (ReleaseCommand | 'trigger-release')[] = [
'download-crypt-shared-library',
'download-and-list-artifacts',
'trigger-release',
'temp-push-auxiliary-tags',
] as const;

const isValidCommand = (
Expand Down
1 change: 1 addition & 0 deletions packages/build/src/npm-packages/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export { bumpAuxiliaryPackages } from './bump';
export { publishToNpm } from './publish';
export { pushTags } from './push-tags';
56 changes: 0 additions & 56 deletions packages/build/src/npm-packages/publish.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,62 +25,6 @@ describe('npm-packages publishToNpm', function () {
spawnSync = sinon.stub();
});

it('throws if mongosh is not existent when publishing all', function () {
const packages = [{ name: 'packageA', version: '0.7.0' }];
listNpmPackages.returns(packages);

expect(() =>
publishToNpm(
{ isDryRun: false, useAuxiliaryPackagesOnly: false },
listNpmPackages,
markBumpedFilesAsAssumeUnchanged,
spawnSync
)
).throws('mongosh package not found');
});

it('takes mongosh version and pushes tags', function () {
const packages = [
{ name: 'packageA', version: '0.7.0' },
{ name: 'mongosh', version: '1.2.0' },
];
listNpmPackages.returns(packages);

publishToNpm(
{ isDryRun: false, useAuxiliaryPackagesOnly: false },
listNpmPackages,
markBumpedFilesAsAssumeUnchanged,
spawnSync
);

expect(spawnSync).calledWith('git', ['tag', '-a', '1.2.0', '-m', '1.2.0']);
expect(spawnSync).calledWith('git', ['push', '--follow-tags']);
});

it('does not manually push tags with auxiliary packages', function () {
const packages = [
{ name: 'packageA', version: '0.7.0' },
{ name: 'mongosh', version: '1.2.0' },
];
listNpmPackages.returns(packages);

publishToNpm(
{ isDryRun: false, useAuxiliaryPackagesOnly: true },
listNpmPackages,
markBumpedFilesAsAssumeUnchanged,
spawnSync
);

expect(spawnSync).not.calledWith('git', [
'tag',
'-a',
'1.2.0',
'-m',
'1.2.0',
]);
expect(spawnSync).not.calledWith('git', ['push', '--follow-tags']);
});

it('calls lerna to publish packages for a real version', function () {
const packages = [
{ name: 'packageA', version: '0.7.0' },
Expand Down
32 changes: 8 additions & 24 deletions packages/build/src/npm-packages/publish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,17 @@ export function publishToNpm(
...(isDryRun ? { npm_config_dry_run: 'true' } : {}),
},
};
let packages = listNpmPackages().filter(
const allReleasablePackages = listNpmPackages().filter(
(packageConfig) => !EXCLUDE_RELEASE_PACKAGES.includes(packageConfig.name)
);

if (useAuxiliaryPackagesOnly) {
packages = packages.filter(
(packageConfig) => !MONGOSH_RELEASE_PACKAGES.includes(packageConfig.name)
);
}
const packages: LernaPackageDescription[] = useAuxiliaryPackagesOnly
? allReleasablePackages.filter(
(packageConfig) =>
!MONGOSH_RELEASE_PACKAGES.includes(packageConfig.name)
)
: allReleasablePackages;

// Lerna requires a clean repository for a publish from-package
// we use git update-index --assume-unchanged on files we know have been bumped
markBumpedFilesAsAssumeUnchangedFn(packages, true);
Expand All @@ -54,24 +56,6 @@ export function publishToNpm(
} finally {
markBumpedFilesAsAssumeUnchangedFn(packages, false);
}

if (!useAuxiliaryPackagesOnly) {
const mongoshVersion = packages.find(
(packageConfig) => packageConfig.name === 'mongosh'
)?.version;

if (!mongoshVersion) {
throw new Error('mongosh package not found');
}

spawnSync(
'git',
['tag', '-a', mongoshVersion, '-m', mongoshVersion],
commandOptions
);

spawnSync('git', ['push', '--follow-tags'], commandOptions);
}
}

export function markBumpedFilesAsAssumeUnchanged(
Expand Down
Loading
Loading