diff --git a/.github/workflows/release_js_api.yml b/.github/workflows/release_js_api.yml index 2431d0ad1352..9dc8fed13a8f 100644 --- a/.github/workflows/release_js_api.yml +++ b/.github/workflows/release_js_api.yml @@ -87,7 +87,7 @@ jobs: if: needs.check.outputs.prerelease == 'true' run: | echo "prerelease=true" >> $GITHUB_ENV - node npm/rome/scripts/update-nightly-version.mjs >> $GITHUB_ENV + node npm/js-api/scripts/update-nightly-version.mjs >> $GITHUB_ENV - name: Set release infos if: needs.check.outputs.prerelease != 'true' run: | diff --git a/npm/js-api/scripts/update-nightly-version.mjs b/npm/js-api/scripts/update-nightly-version.mjs new file mode 100644 index 000000000000..2882859fb127 --- /dev/null +++ b/npm/js-api/scripts/update-nightly-version.mjs @@ -0,0 +1,27 @@ +import { resolve } from "node:path"; +import { fileURLToPath } from "node:url"; +import * as fs from "node:fs"; + +const ROME_ROOT = resolve(fileURLToPath(import.meta.url), "../.."); +const MANIFEST_PATH = resolve(ROME_ROOT, "package.json"); + +const rootManifest = JSON.parse( + fs.readFileSync(MANIFEST_PATH).toString("utf-8"), +); + +let version = rootManifest["version"]; + +if ( + typeof process.env.GITHUB_SHA !== "string" || + process.env.GITHUB_SHA === "" +) { + throw new Error("GITHUB_SHA environment variable is undefined"); +} + +version += `.${process.env.GITHUB_SHA.substring(0, 7)}`; +rootManifest["version"] = version; + +const content = JSON.stringify(rootManifest); +fs.writeFileSync(MANIFEST_PATH, content); + +console.log(`version=${version}`); diff --git a/npm/js-api/scripts/updateVersionForPrerelease.mjs b/npm/js-api/scripts/updateVersionForPrerelease.mjs deleted file mode 100644 index 8f76420d8122..000000000000 --- a/npm/js-api/scripts/updateVersionForPrerelease.mjs +++ /dev/null @@ -1,44 +0,0 @@ -import { readFile, writeFile } from "node:fs/promises"; -import { join, resolve } from "node:path"; - -const manifestPath = resolve(join("package.json")); - -function pad(date) { - if (date < 10) { - return `0${date}`; - } - return `${date}`; -} - -// read the package.json file -readFile(manifestPath, "utf8") - .then(async (value) => { - const manifest = JSON.parse(value); - const currentVersion = manifest.version; - const versionAsSemver = currentVersion.split("."); - // first one is the major - const currentMajor = parseInt(versionAsSemver[0]); - // second one is the minor - const currentMinor = parseInt(versionAsSemver[1]); - - const date = new Date(); - const newMinor = currentMinor + 1; - const newPatch = [ - pad(date.getFullYear()), - pad(date.getMonth() + 1), - pad(date.getDate()), - ].join(""); - // update the version field - manifest.version = `${currentMajor}.${newMinor}.${newPatch}`; - try { - await writeFile(manifestPath, JSON.stringify(manifest, null, "\t")); - console.log(`version=${manifest.version}`); - } catch { - console.log(`Could not write the package.json file at ${manifestPath}`); - process.exit(1); - } - }) - .catch(() => { - console.log(`Could not read the package.json file at ${manifestPath}`); - process.exit(1); - }); diff --git a/npm/rome/README.md b/npm/rome/README.md index 7a3e064b9f41..9f91079d4ab1 100644 --- a/npm/rome/README.md +++ b/npm/rome/README.md @@ -20,7 +20,7 @@ [ci-badge]: https://github.com/rome/tools/actions/workflows/main.yml/badge.svg [ci-url]: https://github.com/rome/tools/actions/workflows/main.yml [npm-badge]: https://img.shields.io/npm/v/rome/next?color=brightgreen -[npm-url]: https://www.npmjs.com/package/rome/v/0.7.0-next +[npm-url]: https://www.npmjs.com/package/rome/v/next [vscode-badge]: https://img.shields.io/visual-studio-marketplace/v/rome.rome?color=brightgreen&label=vscode [vscode-url]: (https://marketplace.visualstudio.com/items?itemName=rome.rome diff --git a/npm/rome/scripts/update-nightly-version.mjs b/npm/rome/scripts/update-nightly-version.mjs index 1b2fbeabb404..34fb5ffba822 100644 --- a/npm/rome/scripts/update-nightly-version.mjs +++ b/npm/rome/scripts/update-nightly-version.mjs @@ -10,9 +10,6 @@ const rootManifest = JSON.parse( ); let version = rootManifest["version"]; -if (!version.includes("-")) { - version += "-next"; -} if ( typeof process.env.GITHUB_SHA !== "string" ||