Skip to content

Commit

Permalink
Update release.js
Browse files Browse the repository at this point in the history
  • Loading branch information
UziTech authored Feb 12, 2025
1 parent 4f77306 commit ca9fd7b
Showing 1 changed file with 26 additions and 19 deletions.
45 changes: 26 additions & 19 deletions release.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@ const {execSync} = require("child_process");
const {writeFileSync} = require("fs");
const {version} = require("./package.json");

function exec(command, skipIfFail) {
function exec(command) {
console.log(`> ${command}`);
let output;
try {
output = execSync(command, {cwd: __dirname, encoding: "utf8"});
} catch (ex) {
console.error(ex.stdout ? ex.stdout : ex.stderr);
if (skipIfFail) {
return;
}
process.exit(1);
throw new Error(ex.stdout ? ex.stdout : ex.stderr);
}
output = output.trim();
console.log(`${output}\n`);
Expand All @@ -31,17 +27,28 @@ console.log(`> Curent version\n${version}\n`);
if (eslintVersion === version) {
console.log("No update available");
} else {
exec("npm install");
exec(`npm install eslint@${eslintVersion} --save-dev --save-exact`);
exec(`npm install @eslint/js@${eslintVersion} --save-dev --save-exact`, true);
exec("npm run lint");
exec("npm run build");
exec("npm test");
exec("git config user.email \"<>\"");
exec("git config user.name \"Github Actions\"");
exec(`git commit -am "update eslint to v${eslintVersion}"`);
exec(`npm version ${eslintVersion}`);
writeFileSync(".npmrc", "//registry.npmjs.org/:_authToken=${NPM_TOKEN}");
exec("npm publish");
exec("git push \"https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git\" HEAD:master --follow-tags");
try {
exec("npm install");
exec(`npm install eslint@${eslintVersion} --save-dev --save-exact`);
try {
exec(`npm install @eslint/js@${eslintVersion} --save-dev --save-exact`);
} catch (ex) {
console.error(ex);
console.log("Trying @eslint/js@latest");
exec(`npm install @eslint/js@latest --save-dev --save-exact`);
}
exec("npm run lint");
exec("npm run build");
exec("npm test");
exec("git config user.email \"<>\"");
exec("git config user.name \"Github Actions\"");
exec(`git commit -am "update eslint to v${eslintVersion}"`);
exec(`npm version ${eslintVersion}`);
writeFileSync(".npmrc", "//registry.npmjs.org/:_authToken=${NPM_TOKEN}");
exec("npm publish");
exec("git push \"https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git\" HEAD:master --follow-tags");
} catch (ex) {
console.error(ex);
process.exit(1);
}
}

0 comments on commit ca9fd7b

Please sign in to comment.