Skip to content

Commit 6a2ad8b

Browse files
committed
chore(ci): add automatic merging of the release tag
The new system requires us to manually merge into main. This automates it through a workflow
1 parent d19a7ed commit 6a2ad8b

File tree

2 files changed

+55
-1
lines changed

2 files changed

+55
-1
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Merge Release Tag
2+
3+
on:
4+
push:
5+
tags:
6+
- 'mongosh@[0-9]+.[0-9]+.[0-9]+'
7+
workflow_dispatch:
8+
9+
jobs:
10+
merge-release-tag:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: mongodb-js/devtools-shared/actions/setup-bot-token@main
15+
id: app-token
16+
with:
17+
app-id: ${{ vars.DEVTOOLS_BOT_APP_ID }}
18+
private-key: ${{ secrets.DEVTOOLS_BOT_PRIVATE_KEY }}
19+
20+
- uses: actions/checkout@v4
21+
with:
22+
ref: ${{ github.ref }}
23+
fetch-depth: "0"
24+
token: ${{ steps.app-token.outputs.token }}
25+
26+
- name: Extract version from tag
27+
id: version
28+
run: echo "RELEASE_VERSION=$(echo ${GITHUB_REF} | sed -n 's/refs\/tags\/mongosh@\([0-9]\+\.[0-9]\+\.[0-9]\+\)/\1/p')" >> $GITHUB_ENV
29+
30+
- name: Validate release version
31+
shell: bash
32+
run: |
33+
if [ -z "${RELEASE_VERSION}" ]; then
34+
echo "RELEASE_TAG is not set or is empty"
35+
exit 1
36+
fi
37+
38+
if git rev-parse "release/v$RELEASE_VERSION" >/dev/null 2>&1; then
39+
echo "Error: Branch release/v$RELEASE_TAG already exists"
40+
echo "If this version has already been released consider using a different one."
41+
exit 1
42+
fi
43+
44+
- name: Create and push branch from tag
45+
run: |
46+
git checkout -b release/v$RELEASE_VERSION ${{ github.ref }}
47+
git push origin release/v$RELEASE_VERSION
48+
49+
- name: Merge branch into main
50+
run: |
51+
git checkout main
52+
git merge release/v$RELEASE_VERSION
53+
git push origin main
54+
git push -d origin release/v$RELEASE_VERSION

packages/build/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ Execute the following steps to publish a new release:
3939
```
4040
Follow the instructions and verify the inferred release version is correct.
4141
7. Wait for Evergreen to finish the publication stage.
42-
8. The previous step will have pushed tags for the npm publishes. Check out the tag for `mongosh@<version>` (not `v<version>`), create a branch for it, push that branch and open a PR with it. Then immediately merge that branch **using the `git merge` CLI command into main** and push to main. **NEVER** use the Github PR merge functionality, since that would squash the commit and give it a new commit hash that is different from the one in the tag.
42+
8. Ensure the release version bump has been automatically merged into the main branch from the `release/vx.x.x` branch.
4343
9. Close the Jira ticket for the release, post an update in the `#mongosh` Slack channel and ping the docs team.
4444

4545
### Branches and Tags

0 commit comments

Comments
 (0)