From c470615bd3b8713010a1376fa38040b3da5f706d Mon Sep 17 00:00:00 2001 From: Jason Jafari Date: Thu, 13 Jun 2024 23:38:54 -0400 Subject: [PATCH] chore: bump version to 1.0.4 --- .husky/pre-commit | 6 ++-- increaseVersion.ts | 64 +++++++++++++++++++++++++++++++++++ package.json | 7 ++-- releaseNewVersionAndAddTag.sh | 21 ++++++++++++ requirements.txt | 1 - setup.py | 2 +- tsconfig.json | 28 +++++++++++++++ 7 files changed, 121 insertions(+), 8 deletions(-) create mode 100755 increaseVersion.ts create mode 100755 releaseNewVersionAndAddTag.sh create mode 100644 tsconfig.json diff --git a/.husky/pre-commit b/.husky/pre-commit index 57cf245..7b99298 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,6 +1,6 @@ #!/bin/sh . "$(dirname "$0")/_/husky.sh" -npm run healthy-check -npm run increase-version -git add package.json \ No newline at end of file +# npm run healthy-check +# npm run increase-version +# git add package.json \ No newline at end of file diff --git a/increaseVersion.ts b/increaseVersion.ts new file mode 100755 index 0000000..da8ec31 --- /dev/null +++ b/increaseVersion.ts @@ -0,0 +1,64 @@ +#!/usr/bin/env bun + +const fs = require("fs"); +const path = require("path"); + +function incrementVersion(version) { + let [major, minor, patch] = version.split(".").map(Number); + patch += 1; + if (patch >= 10) { + patch = 0; + minor += 1; + if (minor >= 10) { + minor = 0; + major += 1; + } + } + return `${major}.${minor}.${patch}`; +} + +function updateSetupPy(newVersion) { + const setupPyPath = path.join(__dirname, "setup.py"); + let setupPyContent = fs.readFileSync(setupPyPath, "utf8"); + setupPyContent = setupPyContent.replace( + /version=['"](\d+\.\d+\.\d+)['"]/, + `version='${newVersion}'` + ); + fs.writeFileSync(setupPyPath, setupPyContent, "utf8"); +} + +function updatePackageJson(newVersion) { + const packageJsonPath = path.join(__dirname, "package.json"); + const packageJsonContent = JSON.parse( + fs.readFileSync(packageJsonPath, "utf8") + ); + packageJsonContent.version = newVersion; + fs.writeFileSync( + packageJsonPath, + JSON.stringify(packageJsonContent, null, 2), + "utf8" + ); +} + +function main() { + const setupPyPath = path.join(__dirname, "setup.py"); + const setupPyContent = fs.readFileSync(setupPyPath, "utf8"); + const currentVersionMatch = setupPyContent.match( + /version=['"](\d+\.\d+\.\d+)['"]/ + ); + + if (!currentVersionMatch) { + console.error("Failed to find version in setup.py"); + process.exit(1); + } + + const currentVersion = currentVersionMatch[1]; + const newVersion = incrementVersion(currentVersion); + + updateSetupPy(newVersion); + updatePackageJson(newVersion); + + console.log(`Version updated to ${newVersion}`); +} + +main(); diff --git a/package.json b/package.json index 458aca2..694024c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mlModelSaver", - "version": "1.0.2", + "version": "1.0.4", "description": "Make life easier for save and serving ml models", "main": "index.js", "repository": "git@github.com:smartdev-ca/mlModelSaver.git", @@ -11,8 +11,9 @@ "husky": "^9.0.11" }, "scripts": { - "increase-version": "npm --force --no-git-tag-version version patch", + "increase-version": "./increaseVersion.ts", + "releaseNewVersionAndAddTag": "./releaseNewVersionAndAddTag.sh", "healthy-check": "ls -la", "prepare": "husky install" } -} +} \ No newline at end of file diff --git a/releaseNewVersionAndAddTag.sh b/releaseNewVersionAndAddTag.sh new file mode 100755 index 0000000..18b2b93 --- /dev/null +++ b/releaseNewVersionAndAddTag.sh @@ -0,0 +1,21 @@ +#!/bin/bash + + +./increaseVersion.ts + +new_version=$(node -p "require('./package.json').version") + +python setup.py sdist bdist_wheel + +twine upload dist/* + +git add . + +git commit -m "chore: bump version to $new_version" + +git tag -a "v$new_version" -m "Version $new_version" + +git push origin main +git push origin "v$new_version" + +echo "Version updated to $new_version, committed, and pushed with tag v$new_version" diff --git a/requirements.txt b/requirements.txt index 73e1aa3..1a876e6 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,7 +9,6 @@ jaraco.functools==4.0.1 keyring==25.2.1 markdown-it-py==3.0.0 mdurl==0.1.2 --e git+ssh://git@github.com/smartdev-ca/mlModelSaver.git@a0fb6ac93d247e7aba3c2b1f901db279e782e996#egg=mlModelSaver more-itertools==10.3.0 nh3==0.2.17 pkginfo==1.11.1 diff --git a/setup.py b/setup.py index 3882589..ef946e6 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name='mlModelSaver', - version='1.0.1', + version='1.0.4', packages=find_packages(), description='Make life easier for save and serving ml models', author='Jason Jafari', diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..0d2e2a2 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,28 @@ +{ + "compilerOptions": { + "jsx": "react-jsx", + "module": "CommonJS", + "target": "ES6", + "moduleResolution": "node", + "resolveJsonModule": true, + + "allowJs": true, + "esModuleInterop": true, + "emitDecoratorMetadata": true, + "experimentalDecorators": true, + "noImplicitAny": false, + + "baseUrl": ".", + "paths": { + "@common/*": ["./common/*"], + "@helpers/*": ["./helpers/*"], + }, + "types": [ + "node" + ] + }, + "exclude": [ + "node_modules", + "dist" + ] +}