Skip to content

Commit

Permalink
Add GitHub Action for versioning
Browse files Browse the repository at this point in the history
  • Loading branch information
TfTHacker committed Apr 4, 2024
1 parent e51e33e commit feb59a2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"dev": "node esbuild.config.mjs",
"build": "tsc -noEmit -skipLibCheck && node esbuild.config.mjs production",
"version": "node version-bump.mjs",
"githubaction": "node version-github-action.mjs",
"lint:check": "eslint --ext .ts,.tsx .",
"lint:fix": "eslint --fix --ext .ts,.tsx .",
"format:check": "prettier --check .",
Expand Down
25 changes: 25 additions & 0 deletions version-github-action.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import fs from 'fs';
import { exec } from 'child_process';

// Read the manifest.json file
fs.readFile('manifest.json', 'utf8', (err, data) => {
if (err) {
console.error(`Error reading file from disk: ${err}`);
} else {
// Parse the file content to a JavaScript object
const manifest = JSON.parse(data);

// Extract the version
const version = manifest.version;

// Execute the git commands
exec(`git tag -a ${version} -m "${version}" && git push origin ${version}`, (error, stdout, stderr) => {
if (error) {
console.error(`exec error: ${error}`);
return;
}
console.log(`stdout: ${stdout}`);
console.error(`stderr: ${stderr}`);
});
}
});

0 comments on commit feb59a2

Please sign in to comment.