diff --git a/.github/workflows/publish-on-main.yml b/.github/workflows/publish-on-main.yml index eae3c92..25e3d6d 100644 --- a/.github/workflows/publish-on-main.yml +++ b/.github/workflows/publish-on-main.yml @@ -77,14 +77,14 @@ jobs: const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf8")); // base: take only X.Y.Z part (strip any prerelease part) const base = String(pkg.version || "0.0.0").split("-")[0]; - const sha = process.env.SHORT_SHA || "unknown"; + const sha = process.env.SHORT_SHA.substring(0, 4); || "unknown"; const newVersion = `${base}-${sha}`; if (!/^\d+\.\d+\.\d+(-[0-9A-Za-z-]+)?$/.test(newVersion)) { console.error("Computed version not semver:", newVersion); process.exit(1); } pkg.version = newVersion; - fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2) + "\\n"); + fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2)); console.log("Updated package.json version to", newVersion); ' env: