Skip to content

Commit

Permalink
mod: error check when bumping versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Odaimoko committed Nov 29, 2024
1 parent 33c005d commit 651d818
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
9 changes: 8 additions & 1 deletion ci/bump_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@ if [ ! -f "package.json" ]; then
echo "Error: should be run from the root of the repo"
exit 1
fi
node ci/version-bump.mjs
node ci/version-bump.mjs
# exit if current-version.txt doesn't exist
if [ ! -f "current-version.txt" ]; then
echo "Error: current-version.txt not found"
exit 1
fi
targetVersion=$(<"current-version.txt") # read the current version from the file
echo "Bumping version to $targetVersion"

Expand All @@ -17,3 +22,5 @@ git commit -m "Bump version to $targetVersion"
#git push
git tag -a "$targetVersion" -m "Bump version tag to $targetVersion"
#git push --tags

rm current-version.txt
8 changes: 6 additions & 2 deletions ci/version-bump.mjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import {readFileSync, writeFileSync} from "fs";

// This is the version defined in package.json
const targetVersion = process.env.npm_package_version;
const targetVersion = process.env.npm_package_version ?? JSON.parse(readFileSync('./package.json', 'utf-8')).version;
if (targetVersion === undefined || targetVersion === null) {

console.error(`target version: ${targetVersion} is invalid`)
process.exit(1)
}
// read minAppVersion from manifest.json and bump version to target version
let manifest = JSON.parse(readFileSync("manifest.json", "utf8"));
const {minAppVersion} = manifest;
Expand All @@ -13,4 +17,4 @@ writeFileSync("manifest.json", JSON.stringify(manifest, null, "\t"));
let versions = JSON.parse(readFileSync("versions.json", "utf8"));
versions[targetVersion] = minAppVersion;
writeFileSync("versions.json", JSON.stringify(versions, null, "\t"));
writeFileSync("current-version.txt", targetVersion);
writeFileSync("current-version.txt", targetVersion);

0 comments on commit 651d818

Please sign in to comment.