-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci: check version has increased on PRs (#12)
- Loading branch information
Showing
4 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
const fs = require("fs"); | ||
const { execSync } = require("child_process"); | ||
const semver = require("semver"); | ||
|
||
// Read the current branch's package.json | ||
const currentPackage = JSON.parse(fs.readFileSync("package.json", "utf8")); | ||
const currentVersion = currentPackage.version; | ||
|
||
// Fetch the package.json from the main branch | ||
execSync("git fetch origin main:main"); | ||
const mainPackageJson = execSync("git show main:package.json").toString(); | ||
const mainPackage = JSON.parse(mainPackageJson); | ||
const mainVersion = mainPackage.version; | ||
|
||
if (semver.gt(currentVersion, mainVersion)) { | ||
console.log(`Version check passed: ${mainVersion} -> ${currentVersion}`); | ||
process.exit(0); | ||
} else { | ||
console.error(`Version check failed: ${mainVersion} -> ${currentVersion}`); | ||
console.error("Please increment the version number in package.json"); | ||
process.exit(1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters