]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
откат пиздецв
authorMaxSMokeSkaarj <vnazarov@smokeofanarchy.ru>
Sun, 12 Jan 2025 05:03:32 +0000 (15:03 +1000)
committerMaxSMokeSkaarj <vnazarov@smokeofanarchy.ru>
Sun, 12 Jan 2025 05:03:32 +0000 (15:03 +1000)
Corvax-SS14
RobustToolbox
Tools/publish_multi_request.mjs [new file with mode: 0644]
publish.sh [deleted file]

index e301f52e655c57d6df4a0475e75eb4b24f64e0e4..51eb31910902353a4df65ff4a3e3eb4a50edaafd 160000 (submodule)
@@ -1 +1 @@
-Subproject commit e301f52e655c57d6df4a0475e75eb4b24f64e0e4
+Subproject commit 51eb31910902353a4df65ff4a3e3eb4a50edaafd
index e4190f4f2900634e332208a77cd6df9cef75c29a..e47ba0faea6b1143f4810547b3d617a110bdb6a5 160000 (submodule)
@@ -1 +1 @@
-Subproject commit e4190f4f2900634e332208a77cd6df9cef75c29a
+Subproject commit e47ba0faea6b1143f4810547b3d617a110bdb6a5
diff --git a/Tools/publish_multi_request.mjs b/Tools/publish_multi_request.mjs
new file mode 100644 (file)
index 0000000..cd2ffab
--- /dev/null
@@ -0,0 +1,89 @@
+#!/usr/bin/env node
+
+import fs from 'fs';
+import path from 'path';
+import https from 'https';
+import { execSync } from 'child_process';
+
+const PUBLISH_TOKEN = process.env.PUBLISH_TOKEN;
+const VERSION = process.env.GITHUB_SHA;
+
+const RELEASE_DIR = 'release';
+const ROBUST_CDN_URL = 'https://ss14.smokeofanarchy.ru/cdn/';
+const FORK_ID = 'main';
+
+
+function getFilesToPublish() {
+    return fs.readdirSync(RELEASE_DIR).map(file => path.join(RELEASE_DIR, file));
+}
+
+function getEngineVersion() {
+    const tag = execSync('git describe --tags --abbrev=0', { cwd: 'RobustToolbox', encoding: 'utf-8' }).trim();
+    if (!tag.startsWith('v')) throw new Error('Tag does not start with v');
+    return tag.slice(1); // Cut off v prefix.
+}
+
+function postRequest(url, data, customHeaders = {}) {
+    return new Promise((resolve, reject) => {
+        const req = https.request(url, {
+            method: 'POST',
+            headers: {
+                'Authorization': `Bearer ${PUBLISH_TOKEN}`,
+                'Content-Type': 'application/json',
+                ...customHeaders,
+            },
+        }, (res) => {
+            let body = '';
+            res.on('data', chunk => {
+                body += chunk;
+            });
+            res.on('end', () => {
+                if (res.statusCode >= 200 && res.statusCode < 300) {
+                    resolve(body);
+                } else {
+                    reject(new Error(`Request failed with status code ${res.statusCode}: ${body}`));
+                }
+            });
+        });
+
+        req.on('error', (e) => {
+            reject(e);
+        });
+
+        if (data instanceof fs.ReadStream) {
+            data.pipe(req);
+        } else {
+            req.write(JSON.stringify(data));
+        }
+        req.end();
+    });
+}
+
+console.log(`Starting publish on Robust.Cdn for version ${VERSION}`);
+
+const data = {
+    version: VERSION,
+    engineVersion: getEngineVersion(),
+};
+
+await postRequest(`${ROBUST_CDN_URL}fork/${FORK_ID}/publish/start`, data);
+
+console.log("Publish successfully started, adding files...");
+
+for (const file of getFilesToPublish()) {
+    console.log(`Publishing ${file}`);
+    const fileStream = fs.createReadStream(file);
+    const headers = {
+        'Content-Type': 'application/octet-stream',
+        'Robust-Cdn-Publish-File': path.basename(file),
+        'Robust-Cdn-Publish-Version': VERSION,
+    };
+
+    await postRequest(`${ROBUST_CDN_URL}fork/${FORK_ID}/publish/file`, fileStream, headers);
+}
+
+console.log("Successfully pushed files, finishing publish...");
+
+await postRequest(`${ROBUST_CDN_URL}fork/${FORK_ID}/publish/finish`, { version: VERSION });
+
+console.log("SUCCESS!");
diff --git a/publish.sh b/publish.sh
deleted file mode 100755 (executable)
index 44bd83c..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-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 client --no-wipe-release