From bc8ef05be70d5bd188c36b202d1d7cb67bd4f004 Mon Sep 17 00:00:00 2001 From: MaxSMokeSkaarj Date: Tue, 26 Nov 2024 16:19:02 +1000 Subject: [PATCH] =?utf8?q?=D0=90=D0=B2=D1=82=D0=BE=D0=BE=D0=B1=D0=BD=D0=BE?= =?utf8?q?=D0=B2=D0=BB=D0=B5=D0=BD=D0=B8=D0=B5=20RobustToolbox?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Tools/publish_multi_request_local.js | 0 Tools/publish_multi_request_local.mjs | 73 ++++++++++++++++++++++----- build.sh | 13 ++--- 3 files changed, 66 insertions(+), 20 deletions(-) delete mode 100644 Tools/publish_multi_request_local.js diff --git a/Tools/publish_multi_request_local.js b/Tools/publish_multi_request_local.js deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/Tools/publish_multi_request_local.mjs b/Tools/publish_multi_request_local.mjs index 857f9d8e05..0fac6dd0cc 100644 --- a/Tools/publish_multi_request_local.mjs +++ b/Tools/publish_multi_request_local.mjs @@ -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(); diff --git a/build.sh b/build.sh index 774cd183d0..c1cbe53f1c 100755 --- 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 -- 2.52.0