diff --git a/Taskfile.yml b/Taskfile.yml index befbaabe..98027535 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -28,5 +28,15 @@ tasks: esclient:publish: dir: ./libs/es-client cmds: + - task: esclient:bump - devbox run publish silent: true + + esclient:bump: + dir: ./libs/es-client + cmds: + - pnpm version patch + - git add package.json + - git commit -m "chore: bump version to {{.VERSION}} [skip ci]" + - git push + silent: true diff --git a/libs/es-client/devbox.json b/libs/es-client/devbox.json index 32895736..36437628 100644 --- a/libs/es-client/devbox.json +++ b/libs/es-client/devbox.json @@ -13,7 +13,6 @@ "pnpm run build" ], "publish": [ - "pnpm version patch", "pnpm publish" ] } diff --git a/libs/es-client/package.json b/libs/es-client/package.json index 0697e47a..3f88e173 100644 --- a/libs/es-client/package.json +++ b/libs/es-client/package.json @@ -1,6 +1,6 @@ { "name": "@onsonr/es", - "version": "0.0.3", + "version": "0.0.2", "private": false, "packageManager": "pnpm@8.3.0", "sideEffects": false, diff --git a/libs/es-client/scripts/check-version.mjs b/libs/es-client/scripts/check-version.mjs deleted file mode 100644 index a5bcff8f..00000000 --- a/libs/es-client/scripts/check-version.mjs +++ /dev/null @@ -1,67 +0,0 @@ -// scripts/check-version.mjs -import { readFileSync } from "fs"; -import { execSync } from "child_process"; -import { join } from "path"; - -async function checkNpmVersion() { - try { - // Read package.json - const pkg = JSON.parse(readFileSync("package.json", "utf8")); - const currentVersion = pkg.version; - - console.log(`Checking version ${currentVersion} on npm...`); - - try { - // Check if version exists on npm - const npmInfo = execSync(`npm view ${pkg.name} versions --json`, { - encoding: "utf8", - stdio: ["pipe", "pipe", "pipe"], - }); - - const publishedVersions = JSON.parse(npmInfo); - - if (publishedVersions.includes(currentVersion)) { - console.log(`Version ${currentVersion} already exists on npm`); - - // Configure git - execSync( - 'git config --local user.email "github-actions[bot]@users.noreply.github.com"' - ); - execSync('git config --local user.name "github-actions[bot]"'); - - // Run pnpm version patch - console.log("Bumping patch version..."); - execSync("pnpm version patch --no-git-tag-version", { - stdio: "inherit", - }); - - // Read new version - const updatedPkg = JSON.parse(readFileSync("package.json", "utf8")); - const newVersion = updatedPkg.version; - - // Commit changes - execSync("git add package.json"); - execSync( - `git commit -m "chore: bump version to ${newVersion} [skip ci]"` - ); - - console.log(`Version bumped to ${newVersion}`); - process.exit(0); - } else { - console.log(`Version ${currentVersion} is not published yet`); - process.exit(0); - } - } catch (error) { - if (error.stderr && error.stderr.includes("404")) { - console.log("Package not found on npm - assuming first publish"); - process.exit(0); - } - throw error; - } - } catch (error) { - console.error("Error:", error.message); - process.exit(1); - } -} - -checkNpmVersion();