Skip to content

Commit

Permalink
chore: updated release workflow (#816)
Browse files Browse the repository at this point in the history
  • Loading branch information
prince-deriv authored Nov 7, 2022
1 parent 42aeb61 commit fc3f073
Showing 1 changed file with 40 additions and 18 deletions.
58 changes: 40 additions & 18 deletions scripts/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,49 @@ const generateNextTag = (tag) => {
return `production_${final_date}_${new_version}`;
};

exec("git fetch", (err, stdout) => {
exec(
"git describe --tags `git rev-list --tags --max-count=1`",
(err, stdout) => {
if (err) {
log(err);
return;
const getLatestTag = (tags) => {
const today = `V${getToday()}`;
let latest_version = 0;
let latest_tag = null;

tags.forEach((tag) => {
const tag_chunks = tag.split("_");
const date = tag_chunks[1];
const version = parseInt(tag_chunks[2]);

if (date === today) {
if (latest_version < version || latest_version === 0) {
latest_version = version;
latest_tag = tag;
}
}
});

if (isValidTag(stdout)) {
log(`Latest Production tag: ${stdout}`);
const new_tag = generateNextTag(stdout);
return latest_tag;
};

exec(`git tag ${new_tag}`, (err, stdout) => {
exec(`git push origin ${new_tag}`, (err, stdout) => {
log(`${new_tag} has been pushed`);
});
exec("git fetch", (err, stdout) => {
exec("git tag -l", (err, stdout) => {
if (err) {
log(err);
return;
}

const tags = stdout.split("\n");

const latest_tag = getLatestTag(tags);

if (isValidTag(stdout)) {
log(`Latest Production tag: ${latest_tag}`);
const new_tag = generateNextTag(latest_tag);

exec(`git tag ${new_tag}`, (err, stdout) => {
exec(`git push origin ${new_tag}`, (err, stdout) => {
log(`${new_tag} has been pushed`);
});
} else {
log("Latest tag is not a production tag!");
}
});
} else {
log("Latest tag is not a production tag!");
}
);
});
});

0 comments on commit fc3f073

Please sign in to comment.