From 60c8e64d1c5801dabdf3104c94dee9ce05e5a104 Mon Sep 17 00:00:00 2001 From: Vasilis Date: Mon, 15 Jul 2024 01:27:15 +0300 Subject: [PATCH 1/2] New publish steps --- .github/workflows/publish.yml | 37 ++++++++++++++++---------------- Tools/publish_github_artifact.py | 4 ++-- 2 files changed, 20 insertions(+), 21 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 053e76d657c5..16fe92e79f60 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -44,25 +44,24 @@ jobs: - name: Update Build Info run: Tools/gen_build_info.py - - name: Shuffle files around - run: | - mkdir "release/${{ github.sha }}" - mv release/*.zip "release/${{ github.sha }}" - - - name: Upload files to axolotl - uses: appleboy/scp-action@master + - name: Upload build artifact + id: artifact-upload-step + uses: actions/upload-artifact@v4 with: - host: axolotl.yuniiworks.de - username: builds-the-server - key: ${{ secrets.PUSH }} - source: "release/${{ github.sha }}" - target: "/home/builds-the-server/cdn/builds/" - strip_components: 1 + name: build + path: release/*.zip + compression-level: 0 + retention-days: 0 + + - name: Publish version + run: Tools/publish_github_artifact.py + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + PUBLISH_TOKEN: ${{ secrets.PUBLISH_TOKEN }} + ARTIFACT_ID: ${{ steps.artifact-upload-step.outputs.artifact-id }} + GITHUB_REPOSITORY: ${{ vars.GITHUB_REPOSITORY }} - - name: Update manifest JSON - uses: appleboy/ssh-action@master + - uses: geekyeggo/delete-artifact@v5 + if: always() with: - host: axolotl.yuniiworks.de - username: builds-the-server - key: ${{ secrets.PUSH }} - script: /home/builds-the-server/push.ps1 ${{ github.sha }} + name: build diff --git a/Tools/publish_github_artifact.py b/Tools/publish_github_artifact.py index b488ccdf2ecd..871b8df86e89 100755 --- a/Tools/publish_github_artifact.py +++ b/Tools/publish_github_artifact.py @@ -14,8 +14,8 @@ # CONFIGURATION PARAMETERS # Forks should change these to publish to their own infrastructure. # -ROBUST_CDN_URL = "https://wizards.cdn.spacestation14.com/" -FORK_ID = "wizards" +ROBUST_CDN_URL = "https://axolotl.yuniiworks.de/cdn/" +FORK_ID = "axolotl" def main(): print("Fetching artifact URL from API...") From 74a8033938ed6f7529750e37ebe937656fcec696 Mon Sep 17 00:00:00 2001 From: Vasilis Date: Mon, 15 Jul 2024 01:40:23 +0300 Subject: [PATCH 2/2] also this --- Tools/gen_build_info.py | 93 ----------------------------------------- 1 file changed, 93 deletions(-) delete mode 100755 Tools/gen_build_info.py diff --git a/Tools/gen_build_info.py b/Tools/gen_build_info.py deleted file mode 100755 index 39b984d9e8b9..000000000000 --- a/Tools/gen_build_info.py +++ /dev/null @@ -1,93 +0,0 @@ -#!/usr/bin/env python3 - -# Generates build info and injects it into the server zip files. - -import codecs -import hashlib -import io -import json -import os -import subprocess -from zipfile import ZipFile, ZIP_DEFLATED - -FILE = "SS14.Client.zip" - -SERVER_FILES = [ - "SS14.Server_linux-x64.zip", -] - -VERSION = os.environ['GITHUB_SHA'] -FORK_ID = "wizards" -BUILD_URL = f"https://axolotl.yuniiworks.de/manifest/builds/{{FORK_VERSION}}/{FILE}" -MANIFEST_URL = f"https://axolotl.yuniiworks.de/cdn/version/{{FORK_VERSION}}/manifest" -MANIFEST_DOWNLOAD_URL = f"https://axolotl.yuniiworks.de/cdn/version/{{FORK_VERSION}}/download" - -def main() -> None: - client_file = os.path.join("release", FILE) - manifest = generate_build_json(client_file) - - for server in SERVER_FILES: - inject_manifest(os.path.join("release", server), manifest) - - -def inject_manifest(zip_path: str, manifest: str) -> None: - with ZipFile(zip_path, "a", compression=ZIP_DEFLATED) as z: - z.writestr("build.json", manifest) - - -def generate_build_json(file: str) -> str: - # Env variables set by Jenkins. - - hash = sha256_file(file) - engine_version = get_engine_version() - manifest_hash = generate_manifest_hash(file) - - return json.dumps({ - "download": BUILD_URL, - "hash": hash, - "version": VERSION, - "fork_id": FORK_ID, - "engine_version": engine_version, - "manifest_url": MANIFEST_URL, - "manifest_download_url": MANIFEST_DOWNLOAD_URL, - "manifest_hash": manifest_hash - }) - -def generate_manifest_hash(file: str) -> str: - zip = ZipFile(file) - infos = zip.infolist() - infos.sort(key=lambda i: i.filename) - - bytesIO = io.BytesIO() - writer = codecs.getwriter("UTF-8")(bytesIO) - writer.write("Robust Content Manifest 1\n") - - for info in infos: - if info.filename[-1] == "/": - continue - - bytes = zip.read(info) - hash = hashlib.blake2b(bytes, digest_size=32).hexdigest().upper() - writer.write(f"{hash} {info.filename}\n") - - manifestHash = hashlib.blake2b(bytesIO.getbuffer(), digest_size=32) - - return manifestHash.hexdigest().upper() - -def get_engine_version() -> str: - proc = subprocess.run(["git", "describe","--tags", "--abbrev=0"], stdout=subprocess.PIPE, cwd="RobustToolbox", check=True, encoding="UTF-8") - tag = proc.stdout.strip() - assert tag.startswith("v") - return tag[1:] # Cut off v prefix. - - -def sha256_file(path: str) -> str: - with open(path, "rb") as f: - h = hashlib.sha256() - for b in iter(lambda: f.read(4096), b""): - h.update(b) - - return h.hexdigest() - -if __name__ == '__main__': - main()