Skip to content

Commit

Permalink
Script to manage release bumping
Browse files Browse the repository at this point in the history
  • Loading branch information
hisorange committed Dec 1, 2021
1 parent 66d7c2f commit d130f6e
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@
"autoprefixer": "^10.3.7",
"axios-hooks": "^3.0.0",
"cypress": "^9.1.0",
"enquirer": "^2.3.6",
"grapesjs": "^0.17.29",
"grapesjs-blocks-basic": "^0.1.8",
"grapesjs-preset-webpage": "^0.1.11",
Expand All @@ -158,6 +159,7 @@
"react-transition-group": "^4.4.2",
"recoil": "^0.4.0",
"recoil-persist": "^3.0.0",
"semver-utils": "^1.1.4",
"start-server-and-test": "^1.14.0",
"tailwindcss": "^2.2.7",
"tailwindcss-scrollbar": "^0.1.0",
Expand Down
44 changes: 44 additions & 0 deletions scripts/release.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const { Select } = require('enquirer');
const { readFileSync, writeFileSync, write } = require('fs');
const { join } = require('path');
const { parse, stringify } = require('semver-utils');
const { execSync } = require('child_process');

const prompt = new Select({
name: 'semver',
message: 'Choose a version change level (semver):',
choices: ['patch', 'minor', 'major'],
});

prompt
.run()
.then(async answer => {
const vfile = join(__dirname, '../version');
const pfile = join(__dirname, '../package.json');
const current = readFileSync(vfile).toString();
console.log('Current version:', current);

const semver = parse(current);

semver[answer] = parseInt(semver[answer], 10) + 1;
const bumped = stringify(semver);
console.log('New version:', bumped);

const package = require(pfile);
package.version = bumped;

writeFileSync(pfile, JSON.stringify(package, null, 2));
writeFileSync(vfile, bumped);

console.log('Version updated');

execSync(
`git add version package.json && git commit -m "Release ${bumped}"`,
{
cwd: join(__dirname, '../'),
},
);

console.log('Commit made for the automatic release');
})
.catch(console.error);
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7389,6 +7389,11 @@ semver-store@^0.3.0:
resolved "https://registry.yarnpkg.com/semver-store/-/semver-store-0.3.0.tgz#ce602ff07df37080ec9f4fb40b29576547befbe9"
integrity sha512-TcZvGMMy9vodEFSse30lWinkj+JgOBvPn8wRItpQRSayhc+4ssDs335uklkfvQQJgL/WvmHLVj4Ycv2s7QCQMg==

semver-utils@^1.1.4:
version "1.1.4"
resolved "https://registry.yarnpkg.com/semver-utils/-/semver-utils-1.1.4.tgz#cf0405e669a57488913909fc1c3f29bf2a4871e2"
integrity sha512-EjnoLE5OGmDAVV/8YDoN5KiajNadjzIp9BAHOhYeQHt7j0UWxjmgsx4YD48wp4Ue1Qogq38F1GNUJNqF1kKKxA==

semver@7.x, semver@^7.3.2, semver@^7.3.5:
version "7.3.5"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.5.tgz#0b621c879348d8998e4b0e4be94b3f12e6018ef7"
Expand Down

0 comments on commit d130f6e

Please sign in to comment.