]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Автообновление RobustToolbox
authorMaxSMokeSkaarj <vnazarov@smokeofanarchy.ru>
Tue, 26 Nov 2024 06:19:02 +0000 (16:19 +1000)
committerMaxSMokeSkaarj <vnazarov@smokeofanarchy.ru>
Tue, 26 Nov 2024 06:19:02 +0000 (16:19 +1000)
Tools/publish_multi_request_local.js [deleted file]
Tools/publish_multi_request_local.mjs
build.sh

diff --git a/Tools/publish_multi_request_local.js b/Tools/publish_multi_request_local.js
deleted file mode 100644 (file)
index e69de29..0000000
index 857f9d8e05292e46a3bf0aae361782ddbeb4950b..0fac6dd0cc4cb0f5eab4f7d53f53d0058e8cb5a5 100644 (file)
@@ -1,13 +1,16 @@
 import { exec, spawn } from 'node:child_process';
-import http from 'node:http';
+import * as path from 'node:path';
+import { request } from 'node:https';
 import { Buffer } from 'node:buffer';
 
-const ROBUST_CDN_URL = "https://ss14.smokeofanarchy.ru/cdn/";
-const FORK_ID = "SMoA";
+const RobustCDNURLStr = 'https://ss14.smokeofanarchy.ru/cdn';
+const ForkID = 'SMoA';
 
-const RELEASE_DIR = "release";
+const ReleaseDir = 'release';
 
-const PUBLISH_TOKEN = process.env.PUBLISH_TOKEN
+const PublishToken = process.env.PUBLISH_TOKEN;
+
+const RobustCDNURL = new URL(RobustCDNURLStr);
 
 const getEngineVersion = () => {
     return new Promise( (res,rej) => {
@@ -19,7 +22,7 @@ const getEngineVersion = () => {
             res(stdout);
         });
     });
-}
+};
 
 const getVersion = () => {
     return new Promise( (res,rej) => {
@@ -27,7 +30,7 @@ const getVersion = () => {
             if (err) {
                 console.error(err);
                 rej(err);
-            }
+            };
             res(stdout);
         });
     });
@@ -35,19 +38,65 @@ const getVersion = () => {
 
 const getFilesToPublish = () => {
     return new Promise( (res,rej) => {
-        exec(`cd ${RELEASE_DIR} && ls`, (err, stdout, stderr) => {
+        exec(`cd ${ReleaseDir} && ls`, (err, stdout, stderr) => {
             if (err) {
                 console.error(err);
                 rej(err);
-            }
+            };
             res(stdout);
         });
     });
 };
 
-const VERSION = await getVersion();
-const ENGINE_VERSION = await getEngineVersion();
+const repoSHA = await getVersion();
+const engineVersion = await getEngineVersion();
+const FilesToUpload = (await getFilesToPublish()).split('\n').filter( (file) => {return file});
+
+const headers = {
+    'Content-Type': 'application/json',
+    'Authorization': `Bearer ${PublishToken}`,
+}
 
-console.log(await getFilesToPublish());
+const optionsStart = {
+    hostname: RobustCDNURL.host.split(':')[0],
+    port: RobustCDNURL.port,
+    path: `${RobustCDNURL.pathname}/fork/${ForkID}/publish/start`,
+    method: 'POST',
+    headers,
+};
 
+const optionsFile = {
+    hostname: RobustCDNURL.host.split(':')[0],
+    port: RobustCDNURL.port,
+    path: `${RobustCDNURL.pathname}/fork/${ForkID}/publish/file`,
+    method: 'POST',
+    headers,
+};
+
+const optionsFinish = {
+    hostname: RobustCDNURL.host.split(':')[0],
+    port: RobustCDNURL.port,
+    path: `${RobustCDNURL.pathname}/fork/${ForkID}/publish/finish`,
+    method: 'POST',
+    headers,
+};
+
+const data = {
+    "version": repoSHA.trim(),
+    "engineVersion": engineVersion.trim()
+}
+
+const req = request(optionsStart, (res) => {
+    console.log('statusCode:', res.statusCode);
+    console.log('headers:', res.headers);
+    res.on('data', (d) => {
+        //d = JSON.parse(d.toString())
+        console.log(d.toString());
+    });
+});
+req.write(JSON.stringify(data));
+req.on('error', (e) => {
+    console.error(e);
+});
+req.end();
 
index 774cd183d0f56c5f9b52ffeb80ad1a920988c2c8..c1cbe53f1c0278f7208bef60b2c76c48018c78ba 100755 (executable)
--- a/build.sh
+++ b/build.sh
@@ -24,19 +24,16 @@ function updateSS14() {
 };
 
 function buildServer() {
+    cd RobustToolbox
        git fetch --depth 1
+    cd ..
        dotnet restore
        dotnet build Content.Packaging --configuration Release --no-restore /m;
        dotnet run --project Content.Packaging server --platform win-x64 --platform linux-x64 --platform osx-x64 --platform linux-arm64;
-       dotnet run --project Content.Packaging server --platform linux-x64;
        dotnet run --project Content.Packaging client --no-wipe-release
-       
-};
 
-function buildServerOld() {
-       dotnet build Content.Packaging --configuration Release;
-       dotnet run --project Content.Packaging server --hybrid-acz --platform linux-x64;
-       
 };
 
-eval $1
+
+updateSS14
+buildServer