-
Notifications
You must be signed in to change notification settings - Fork 73
chore(ci): move releasing to GitHub Actions MONGOSH-1871 #2309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
gagik
wants to merge
36
commits into
main
Choose a base branch
from
gagik/move-release-ga
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
36 commits
Select commit
Hold shift + click to select a range
e2d6ee5
WIP: individual publishing of packages
gagik f759846
use 2.3.7
gagik 2296340
update package-lock.json and packages
gagik 546574a
restore changes
gagik f71c326
wip
gagik dfa6d5c
switch to bump script
gagik f54e208
check if bump is necessary for installs
gagik b55f0e8
add publish-packages
gagik 986305e
remove package.json changes
gagik 7eab63a
Update .github/workflows/release-packages.yml
gagik b2335d9
fix removed compass skip
gagik 871a99c
switch to use app token
gagik 1cbc99a
use bump in install script
gagik 7d5b099
remove bump step
gagik 908ec91
align with future release move changes
gagik 9f4b462
fix naming
gagik a0c7dee
re-add bump
gagik 723dff1
use npx and use tags in all cases
gagik 2a569ce
use monorepo tools as dependency
gagik f5bd303
remove bump, use version
gagik 5ffec0d
use a shell-api constant and switch to 2.3.8
gagik 0df1e98
set all packages to 2.3.8
gagik b9a1726
revert to dev version
gagik 4fa2164
use 2.3.8
gagik 75bc72d
fix tests and match with mongosh --version
gagik 0feeebe
add bumping
gagik 25df857
WIP: move parts of release to GitHub Actions
gagik 68f93dd
use publish
gagik a6e3cbe
remove no-tagging
gagik fb65c9a
add setting release publisher to the publish step
gagik f220798
add spaces
gagik f62b2a8
set the release submitter papertrail in evergreen
gagik 837e516
add papertrail submitter from package.json
gagik e880d36
feat: update docs, remove triggers, requrie publisher, use tag-based …
gagik 68c0e09
refactor(ci): use more object-oriented structure during publishing an…
gagik 233a4b4
fix(ci): use path.join to fix cross-platform test failures
gagik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Merge mongosh Release PR | ||
|
||
on: | ||
push: | ||
tags: | ||
- 'v*' | ||
|
||
jobs: | ||
prepare-release: | ||
runs-on: ubuntu-latest | ||
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: Merge Pull Request | ||
shell: bash | ||
env: | ||
MONGOSH_RELEASE_VERSION: ${{ env.NEXT_VERSION }} | ||
GH_TOKEN: ${{ steps.app-token.outputs.token }} | ||
run: | | ||
gh pr merge release/${{ github.ref_name }} --squash |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
name: Prepare mongosh Release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
jiraTicket: | ||
description: 'Jira ticket for the release, e.g. MONGOSH-1234' | ||
required: true | ||
|
||
versionBump: | ||
description: 'Version bump' | ||
type: choice | ||
required: true | ||
default: 'patch' | ||
options: | ||
- patch | ||
- minor | ||
- major | ||
- exact-version | ||
|
||
exactVersion: | ||
description: 'Exact version: (Only effective selecting "exact-version" as version bump)' | ||
required: false | ||
|
||
jobs: | ||
prepare-release: | ||
runs-on: ubuntu-latest | ||
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: Setup Node.js Environment | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20.18.1 | ||
|
||
- name: Determine Next Version | ||
shell: bash | ||
run: | | ||
set -e | ||
|
||
VERSION_BUMP=${{ github.event.inputs.versionBump }} | ||
|
||
if [[ "$VERSION_BUMP" == "major" || "$VERSION_BUMP" == "minor" || "$VERSION_BUMP" == "patch" ]]; then | ||
PREV_VERSION_TAG=$(gh api repos/:owner/:repo/releases --jq '. | map(select(.draft == false)) | .[0] | .tag_name') | ||
PREV_VERSION=$(npx semver --coerce ${PREV_VERSION_TAG}) | ||
|
||
NEXT_VERSION=$(npx semver -i $VERSION_BUMP $PREV_VERSION) | ||
else | ||
NEXT_VERSION=${{ github.event.inputs.exactVersion }} | ||
fi | ||
|
||
# Remove the 'v' prefix from NEXT_VERSION if it exists | ||
NEXT_VERSION="${NEXT_VERSION#v}" | ||
|
||
# Validates the version before using it | ||
npx semver v"${NEXT_VERSION}" | ||
|
||
echo "RELEASE_TAG=v${NEXT_VERSION}" >> "$GITHUB_ENV" | ||
|
||
- name: Validate release tag | ||
shell: bash | ||
run: | | ||
if [ -z "${RELEASE_TAG}" ]; then | ||
echo "RELEASE_TAG is not set or is empty" | ||
exit 1 | ||
fi | ||
|
||
if git rev-parse "$RELEASE_TAG" >/dev/null 2>&1; then | ||
echo "Error: Tag $RELEASE_TAG already exists" | ||
echo "If you are trying to re-create a draft release with this version, please delete the release and the tag first." | ||
echo "If this version has already been release consider using a different one." | ||
exit 1 | ||
fi | ||
|
||
- name: Bump mongosh and package versions | ||
shell: bash | ||
env: | ||
MONGOSH_RELEASE_VERSION: ${{ env.NEXT_VERSION }} | ||
run: | | ||
set -e | ||
echo Bumping mongosh versions to ${NEXT_VERSION} and packages | ||
|
||
npm run bump | ||
|
||
git add . | ||
git commit --no-allow-empty -m "chore(release): prepare for mongosh v${NEXT_VERSION} ${{ github.event.inputs.jiraTicket }}" || true | ||
|
||
- name: Create Pull Request | ||
uses: peter-evans/create-pull-request@5e914681df9dc83aa4e4905692ca88beb2f9e91f # 7.0.5 | ||
with: | ||
token: ${{ steps.app-token.outputs.token }} | ||
commit-message: "chore(release): prepare for mongosh v${NEXT_VERSION} ${{ github.event.inputs.jiraTicket }}" | ||
branch: release/${RELEASE_TAG} | ||
title: "chore(release): prepare for mongosh v${NEXT_VERSION} ${{ github.event.inputs.jiraTicket }}" | ||
body: | | ||
- [${{ github.event.inputs.jiraTicket }}](https://jira.mongodb.org/browse/${{ github.event.inputs.jiraTicket }}) | ||
- This PR is for the release of mongosh v${NEXT_VERSION}. | ||
- **Do not merge manually, use the Release mongosh action instead.** |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
name: Release mongosh | ||
on: | ||
workflow_run: | ||
workflows: ["CheckQL", "Run Smoke Tests", "evergreen"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am not sure if evergreen is considered a workflow since it seems to be created by a bot/integration(?). Could leave and see what happens or just make it manual-only |
||
types: ["completed"] | ||
branches: ["release/**"] | ||
workflow_dispatch: | ||
|
||
jobs: | ||
publish: | ||
if: | | ||
startsWith(github.head_ref, 'refs/heads/release/') | ||
runs-on: ubuntu-latest | ||
|
||
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: Extract version from the branch | ||
run: | | ||
set -e | ||
export NEXT_VERSION=$(echo "${GITHUB_REF}" | sed -n 's/refs\/heads\/release\/\(.*\)/\1/p') | ||
|
||
echo "NEXT_VERSION=${NEXT_VERSION}" >> "$GITHUB_ENV" | ||
echo "RELEASE_TAG=v${NEXT_VERSION}" >> "$GITHUB_ENV" | ||
|
||
- name: Validate release tag | ||
shell: bash | ||
run: | | ||
if [ -z "${RELEASE_TAG}" ]; then | ||
echo "RELEASE_TAG is not set or is empty" | ||
exit 1 | ||
fi | ||
|
||
if git rev-parse "$RELEASE_TAG" >/dev/null 2>&1; then | ||
echo "Error: Tag $RELEASE_TAG already exists" | ||
echo "If you are trying to re-create a draft release with this version, please delete the release and the tag first." | ||
echo "If this version has already been released consider using a different one." | ||
exit 1 | ||
fi | ||
|
||
- name: "Trigger mongosh publish" | ||
env: | ||
NPM_TOKEN: ${{ secrets.DEVTOOLSBOT_NPM_TOKEN }} | ||
MONGOSH_RELEASE_PUBLISHER: ${{ github.triggering_actor }} | ||
run: | | ||
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> ~/.npmrc | ||
npm run publish |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.