Skip to content
Open
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
73 changes: 34 additions & 39 deletions packages/release/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,15 @@ const runProjectRootCommand = (command, force) => {
};

const checkBranchSync = () => {
if (noSyncCheck) {
console.log("Skipping sync check.");
return;
}
console.log("Checking if local branch is master...");
const currentBranch = runProjectRootCommand(
"git branch --show-current",
).trim();
if (currentBranch !== "master") {
if (currentBranch !== "master" && !isDryRun) {
console.error(
"Local branch is not master. Please checkout the master branch.",
);
Expand All @@ -72,32 +76,26 @@ const checkBranchSync = () => {

console.log("Checking if local master branch is in sync with origin...");

if (noSyncCheck) {
console.log("Skipping sync check.");
} else if (isDryRun) {
console.log("[Dry Run] Checking sync...");
} else {
try {
// Fetch the latest changes from the remote repository
runProjectRootCommand("git fetch origin");

// Get the commit hashes of the local and remote master branches
const localMaster = runProjectRootCommand("git rev-parse master").trim();
const remoteMaster = runProjectRootCommand(
"git rev-parse origin/master",
).trim();

if (localMaster !== remoteMaster) {
console.error(
"Local master branch is not in sync with origin. Please pull the latest changes before proceeding.",
);
process.exit(1);
}
} catch (error) {
console.error("Error checking branch sync status.");
console.error(error);
try {
// Fetch the latest changes from the remote repository
runProjectRootCommand("git fetch origin");

// Get the commit hashes of the local and remote master branches
const localMaster = runProjectRootCommand("git rev-parse master").trim();
const remoteMaster = runProjectRootCommand(
"git rev-parse origin/master",
).trim();

if (localMaster !== remoteMaster && !isDryRun) {
console.error(
"Local master branch is not in sync with origin. Please pull the latest changes before proceeding.",
);
process.exit(1);
}
} catch (error) {
console.error("Error checking branch sync status.");
console.error(error);
process.exit(1);
}
};

Expand Down Expand Up @@ -156,9 +154,8 @@ const updatePackage = (newVersion) => {
const checkUncommittedChanges = () => {
console.log("Checking uncommitted changes...");
const status = execSync("git status --porcelain").toString().trim();
if (isDryRun) {
console.log("[Dry Run] Checking uncommitted changes...");
} else if (status) {

if (status && !isDryRun) {
console.error(
"You have uncommitted changes. Please commit or stash them before proceeding.",
);
Expand All @@ -168,11 +165,7 @@ const checkUncommittedChanges = () => {

const installDependencies = () => {
console.log("Installing dependencies...");
if (isDryRun) {
console.log("[Dry Run] Dependencies would be installed.");
} else {
runProjectRootCommand("pnpm i");
}
runProjectRootCommand("pnpm i");
};

const buildProject = () => {
Expand Down Expand Up @@ -233,11 +226,13 @@ const generateContributors = () => {
contributors.replaceAll("\n", "").replace(/^.*?\[/, "["),
);

fs.writeFileSync(
`${PROJECT_ROOT}/frontend/static/contributors.json`,
JSON.stringify(contributors, null, 2),
"utf8",
);
if (!isDryRun) {
fs.writeFileSync(
`${PROJECT_ROOT}/frontend/static/contributors.json`,
JSON.stringify(contributors, null, 2),
"utf8",
);
}

console.log("Contributors list updated.");
} catch (e) {
Expand All @@ -249,7 +244,7 @@ const generateContributors = () => {
const createCommitAndTag = (version) => {
console.log("Creating commit and tag... Pushing to Github...");
runCommand(`git add .`);
runCommand(`git commit -m "chore: release ${version}" --no-verify`);
runCommand(`git commit -m "chore: release ${version}"`);
runCommand(`git tag ${version}`);
runCommand(`git push origin master --tags --no-verify`);
};
Expand Down
Loading