Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

DEVPROD-5788: Allow upgrading to minor or major version #2315

Merged
merged 2 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 11 additions & 5 deletions scripts/deploy/deploy-production.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,20 @@ const evergreenDeploy = async () => {
// Print all commits between the last tag and the current commit
console.log(`Commit messages:\n${commitMessages}`);

const { value: shouldCreateTagAndPush } = await prompts({
type: "confirm",
const { value: version } = await prompts({
type: "select",
name: "value",
message: "Are you sure you want to deploy to production?",
message: "How should this deploy be versioned?",
choices: [
{ title: "Patch", value: "patch" },
{ title: "Minor", value: "minor" },
{ title: "Major", value: "major" },
],
initial: 0,
});

if (shouldCreateTagAndPush) {
createTagAndPush();
if (version) {
createTagAndPush(version);
}
} catch (err) {
console.error(err);
Expand Down
7 changes: 5 additions & 2 deletions scripts/deploy/utils/git/tag/mock-tag-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@ import { yellow } from "../../../../utils/colors";

/**
* `createTagAndPush` is a helper function that creates a new tag and pushes to remote.
* @param version - version indicates the type of upgrade of the new tag.
*/
const createTagAndPush = () => {
console.log(yellow("Dry run mode enabled. Created new tag and pushed."));
const createTagAndPush = (version: "patch" | "minor" | "major") => {
console.log(
yellow(`Dry run mode enabled. Created new ${version} tag and pushed.`),
);
};

/**
Expand Down
11 changes: 6 additions & 5 deletions scripts/deploy/utils/git/tag/tag-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ import { green, underline } from "../../../../utils/colors";
/**
* `createTagAndPush` is a helper function that creates a new tag.
* Pushing occurs in the postversion hook triggered by "yarn version"
* @param version - version indicates the type of upgrade of the new tag.
*/
const createTagAndPush = () => {
const createTagAndPush = (version: "patch" | "minor" | "major") => {
console.log("Creating new tag...");
try {
execSync("yarn version --new-version patch", {
execSync(`yarn version --new-version ${version}`, {
encoding: "utf-8",
stdio: "inherit",
});
Expand All @@ -19,9 +20,9 @@ const createTagAndPush = () => {
console.log(
green(
`Track deploy progress at ${underline(
"https://spruce.mongodb.com/commits/spruce?requester=git_tag_request"
)}`
)
"https://spruce.mongodb.com/commits/spruce?requester=git_tag_request",
)}`,
),
);
};

Expand Down
Loading