@@ -143905,9 +143905,15 @@ let workingDirectory = core.getInput("working-directory") || process.cwd();
143905143905workingDirectory = external_path_.isAbsolute(workingDirectory)
143906143906 ? workingDirectory
143907143907 : external_path_.join(process.cwd(), workingDirectory);
143908+ const staticCompilerVersionFileName = "esy-static-ocaml-compiler-version";
143909+ const compilerVersionFileName = "esy-ocaml-compiler-version";
143910+ function cli(cmd) {
143911+ console.log(`cli: ${cmd}`);
143912+ return external_child_process_.execSync(cmd).toString().trim();
143913+ }
143908143914function getEsyCLIVersion() {
143909143915 const cmd = "esy --version";
143910- return external_child_process_.execSync (cmd).toString().trim( );
143916+ return cli (cmd);
143911143917}
143912143918function getEsyStoreVersion() {
143913143919 const esyCLIVersion = getEsyCLIVersion();
@@ -143949,7 +143955,7 @@ function getCompilerVersion(sandbox) {
143949143955 const ocamlcVersionCmd = sandbox
143950143956 ? `esy ${sandbox} ocamlc --version`
143951143957 : "esy ocamlc --version";
143952- return external_child_process_.execSync (ocamlcVersionCmd).toString( );
143958+ return cli (ocamlcVersionCmd);
143953143959}
143954143960function run(name, command, args) {
143955143961 return __awaiter(this, void 0, void 0, function* () {
@@ -144143,12 +144149,15 @@ function prepareNPMArtifacts() {
144143144149 var _a, _b, _c;
144144144150 const statusCmd = manifestKey ? `esy ${manifestKey} status` : "esy status";
144145144151 try {
144152+ const compilerVersion = getCompilerVersion();
144153+ console.log("Found compiler version", compilerVersion);
144154+ const staticCompilerVersion = getCompilerVersion("static.esy");
144155+ console.log("Found static compiler version", staticCompilerVersion);
144146144156 const manifestFilePath = JSON.parse(external_child_process_.execSync(statusCmd, { cwd: workingDirectory }).toString()).rootPackageConfigPath;
144147144157 const manifest = JSON.parse(external_fs_.readFileSync(manifestFilePath).toString());
144148144158 if ((_a = manifest.esy) === null || _a === void 0 ? void 0 : _a.release) {
144149144159 const command = ["npm-release"];
144150144160 if ((_c = (_b = manifest.esy) === null || _b === void 0 ? void 0 : _b.release) === null || _c === void 0 ? void 0 : _c.rewritePrefix) {
144151- const compilerVersion = getCompilerVersion();
144152144161 command.push("--ocaml-version");
144153144162 command.push(compilerVersion);
144154144163 }
@@ -144169,6 +144178,32 @@ function prepareNPMArtifacts() {
144169144178 retentionDays: 10,
144170144179 });
144171144180 console.log(`Created artifact with id: ${id} (bytes: ${size}`);
144181+ external_fs_.writeFileSync(compilerVersionFileName, compilerVersion);
144182+ const { id: compilerVersionFileNameID, size: compilerVersionFileNameSize, } = yield artifact_default().uploadArtifact(compilerVersionFileName, [compilerVersionFileName], process.env.GITHUB_WORKSPACE, {
144183+ // The level of compression for Zlib to be applied to the artifact archive.
144184+ // - 0: No compression
144185+ // - 1: Best speed
144186+ // - 6: Default compression (same as GNU Gzip)
144187+ // - 9: Best compression
144188+ compressionLevel: 0,
144189+ // optional: how long to retain the artifact
144190+ // if unspecified, defaults to repository/org retention settings (the limit of this value)
144191+ retentionDays: 10,
144192+ });
144193+ console.log(`Created artifact with name: ${compilerVersionFileName} id: ${compilerVersionFileNameID} (bytes: ${compilerVersionFileNameSize}`);
144194+ external_fs_.writeFileSync(staticCompilerVersionFileName, staticCompilerVersion);
144195+ const { id: staticCompilerVersionFileNameID, size: staticCompilerVersionFileNameSize, } = yield artifact_default().uploadArtifact(staticCompilerVersionFileName, [staticCompilerVersionFileName], process.env.GITHUB_WORKSPACE, {
144196+ // The level of compression for Zlib to be applied to the artifact archive.
144197+ // - 0: No compression
144198+ // - 1: Best speed
144199+ // - 6: Default compression (same as GNU Gzip)
144200+ // - 9: Best compression
144201+ compressionLevel: 0,
144202+ // optional: how long to retain the artifact
144203+ // if unspecified, defaults to repository/org retention settings (the limit of this value)
144204+ retentionDays: 10,
144205+ });
144206+ console.log(`Created artifact with name: ${staticCompilerVersionFileNameID} id: ${id} (bytes: ${staticCompilerVersionFileNameSize}`);
144172144207 }
144173144208 else {
144174144209 console.error(external_fs_.readFileSync(manifestFilePath).toString());
@@ -144193,21 +144228,27 @@ function bundleNPMArtifacts() {
144193144228 external_fs_.mkdirSync(releaseFolder);
144194144229 const { artifacts } = yield artifact_default().listArtifacts();
144195144230 // TODO: filter out artifacts that dont have esy-npm-release-* prefix in their name
144196- const artifactFoldersList = yield Promise.all(artifacts.map((a) => __awaiter(this, void 0, void 0, function* () {
144197- const folderName = `platform-${a.name}`;
144198- const folderPath = external_path_.join(releaseFolder, folderName);
144199- yield artifact_default().downloadArtifact(a.id, {
144200- path: folderPath,
144201- });
144202- const npmTarballPath = external_path_.join(folderPath, "npm-tarball.tgz");
144203- yield uncompress(folderPath, npmTarballPath, 1);
144204- external_fs_.rmSync(npmTarballPath);
144205- return folderName;
144206- })));
144207- const artifactFolders = artifactFoldersList.reduce((acc, folderName) => {
144208- acc.push(folderName);
144209- return acc;
144210- }, []);
144231+ const artifactFoldersList = [];
144232+ for (let i = 0; i < artifacts.length; ++i) {
144233+ const a = artifacts[i];
144234+ if (a.name === compilerVersionFileName ||
144235+ a.name === staticCompilerVersionFileName) {
144236+ yield artifact_default().downloadArtifact(a.id, {
144237+ path: workingDirectory,
144238+ });
144239+ }
144240+ else {
144241+ const folderName = `platform-${a.name}`;
144242+ const folderPath = external_path_.join(releaseFolder, folderName);
144243+ yield artifact_default().downloadArtifact(a.id, {
144244+ path: folderPath,
144245+ });
144246+ const npmTarballPath = external_path_.join(folderPath, "npm-tarball.tgz");
144247+ yield uncompress(folderPath, npmTarballPath, 1);
144248+ external_fs_.rmSync(npmTarballPath);
144249+ artifactFoldersList.push(folderName);
144250+ }
144251+ }
144211144252 try {
144212144253 const esyInstallReleaseJS = "esyInstallRelease.js";
144213144254 external_fs_.cpSync(external_path_.join(releaseFolder, artifactFoldersList[0], esyInstallReleaseJS), external_path_.join(releaseFolder, esyInstallReleaseJS));
@@ -144234,15 +144275,11 @@ function bundleNPMArtifacts() {
144234144275 const rewritePrefix = mainPackageJson.esy &&
144235144276 mainPackageJson.esy.release &&
144236144277 mainPackageJson.esy.release.rewritePrefix;
144237- function exec(cmd) {
144238- console.log(`exec: ${cmd}`);
144239- return external_child_process_.execSync(cmd).toString().trim();
144240- }
144241- const version = exec("git describe --tags --always");
144242- const compilerVersion = getCompilerVersion();
144278+ const compilerVersion = "1"; // todo read from downloade artifact file
144279+ const staticCompilerVersion = "2"; // todo read from downloaded artifact file
144243144280 console.log("Found compiler version", compilerVersion);
144244- const staticCompilerVersion = getCompilerVersion("static.esy");
144245144281 console.log("Found static compiler version", staticCompilerVersion);
144282+ const version = cli("git describe --tags --always");
144246144283 const packageJson = JSON.stringify({
144247144284 name: mainPackageJson.name,
144248144285 version,
@@ -144260,7 +144297,7 @@ function bundleNPMArtifacts() {
144260144297 "bin/",
144261144298 "postinstall.js",
144262144299 "esyInstallRelease.js",
144263- ].concat(artifactFolders ),
144300+ ].concat(artifactFoldersList ),
144264144301 }, null, 2);
144265144302 external_fs_.writeFileSync(external_path_.join(releaseFolder, "package.json"), packageJson, {
144266144303 encoding: "utf8",
0 commit comments