Skip to content

Commit da809a5

Browse files
committed
use tag-based workflow for merging
1 parent 614716b commit da809a5

File tree

3 files changed

+46
-28
lines changed

3 files changed

+46
-28
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: Merge mongosh Release PR
2+
3+
on:
4+
push:
5+
tags:
6+
- 'v*'
7+
8+
jobs:
9+
prepare-release:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: mongodb-js/devtools-shared/actions/setup-bot-token@main
13+
id: app-token
14+
with:
15+
app-id: ${{ vars.DEVTOOLS_BOT_APP_ID }}
16+
private-key: ${{ secrets.DEVTOOLS_BOT_PRIVATE_KEY }}
17+
18+
- uses: actions/checkout@v4
19+
with:
20+
# don't checkout a detatched HEAD
21+
ref: ${{ github.head_ref }}
22+
23+
# this is important so git log can pick up on
24+
# the whole history to generate the list of AUTHORS
25+
fetch-depth: "0"
26+
token: ${{ steps.app-token.outputs.token }}
27+
28+
29+
- name: Merge Pull Request
30+
shell: bash
31+
env:
32+
MONGOSH_RELEASE_VERSION: ${{ env.NEXT_VERSION }}
33+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
34+
run: |
35+
gh pr merge release/${{ github.ref_name }} --squash

.github/workflows/prepare-release-mongosh.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ jobs:
104104
with:
105105
token: ${{ steps.app-token.outputs.token }}
106106
commit-message: "chore(release): prepare for mongosh v${NEXT_VERSION} ${{ github.event.inputs.jiraTicket }}"
107-
branch: release/${NEXT_VERSION}
107+
branch: release/${RELEASE_TAG}
108108
title: "chore(release): prepare for mongosh v${NEXT_VERSION} ${{ github.event.inputs.jiraTicket }}"
109109
body: |
110110
- [${{ github.event.inputs.jiraTicket }}](https://jira.mongodb.org/browse/${{ github.event.inputs.jiraTicket }})

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

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,12 @@ export function publishToNpm(
2424
spawnSync: typeof spawnSyncFn = spawnSyncFn
2525
): Promise<void> {
2626
const publisher = process.env.MONGOSH_RELEASE_PUBLISHER;
27-
if (!publisher && !useAuxiliaryPackagesOnly) {
28-
throw new Error(
29-
'MONGOSH_RELEASE_PUBLISHER not specified for publishing mongosh release'
30-
);
27+
if (!useAuxiliaryPackagesOnly) {
28+
if (!publisher) {
29+
throw new Error(
30+
'MONGOSH_RELEASE_PUBLISHER is required for publishing mongosh'
31+
);
32+
}
3133
}
3234

3335
const commandOptions: SpawnSyncOptionsWithStringEncoding = {
@@ -49,7 +51,9 @@ export function publishToNpm(
4951
(packageConfig) => !MONGOSH_RELEASE_PACKAGES.includes(packageConfig.name)
5052
);
5153
}
52-
await setReleasePublisher(publisher, packages);
54+
if (publisher) {
55+
await setReleasePublisher(publisher, packages);
56+
}
5357
// Lerna requires a clean repository for a publish from-package
5458
// we use git update-index --assume-unchanged on files we know have been bumped
5559
markBumpedFilesAsAssumeUnchangedFn(packages, true);
@@ -82,32 +86,11 @@ export function publishToNpm(
8286

8387
spawnSync(
8488
'git',
85-
['tag', '-a', mongoshVersion, '-m', mongoshVersion],
89+
['tag', '-a', `v${mongoshVersion}`, '-m', `v${mongoshVersion}`],
8690
commandOptions
8791
);
8892

8993
spawnSync('git', ['push', '--follow-tags'], commandOptions);
90-
91-
// Merge the release branch into main
92-
spawnSync('git', ['checkout', 'origin/main'], commandOptions);
93-
spawnSync(
94-
'git',
95-
['merge', '--squash', `origin/release/${mongoshVersion}`],
96-
commandOptions
97-
);
98-
spawnSync(
99-
'git',
100-
['commit', '-m', `chore(release): release mongosh v${mongoshVersion}`],
101-
commandOptions
102-
);
103-
spawnSync('git', ['push', 'origin', 'main'], commandOptions);
104-
105-
// Delete the release branch after merging
106-
spawnSync(
107-
'git',
108-
['branch', '-D', `release/${mongoshVersion}`],
109-
commandOptions
110-
);
11194
}
11295
}
11396

0 commit comments

Comments
 (0)