ci: fix script and remove "-next" from workflow
MODIFY
.github/workflows/release_js_api.yml
.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: |

ADD
npm/js-api/scripts/update-nightly-version.mjs
+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}`);

DELETE
npm/js-api/scripts/updateVersionForPrerelease.mjs
-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);
- });

MODIFY
npm/rome/README.md
npm/rome/README.md
[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

MODIFY
npm/rome/scripts/update-nightly-version.mjs
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" ||

ci: fix script and remove "-next" from workflow (#3467)