From 596828e8271d7003431f954b0c177b228d843512 Mon Sep 17 00:00:00 2001 From: htom Date: Sun, 9 Nov 2025 12:29:46 +0100 Subject: [PATCH] Added release workflow, started work on the upload to spreadsheet --- .github/workflows/dispatcher.yml | 15 ++++- .github/workflows/release.yml | 97 +++++++++++++++++++++++++++++++ .github/workflows/upload_data.yml | 57 ++++++++++++++++++ 3 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/release.yml create mode 100644 .github/workflows/upload_data.yml diff --git a/.github/workflows/dispatcher.yml b/.github/workflows/dispatcher.yml index 7efbf6f..efdf84d 100644 --- a/.github/workflows/dispatcher.yml +++ b/.github/workflows/dispatcher.yml @@ -62,9 +62,22 @@ jobs: uses: ./.github/workflows/ui_test.yml secrets: inherit + + #test-data-upload: + #needs: [engine, server, ui] + #if: always() + #uses: ./.github/workflows/upload_data.yml + #secrets: inherit + + release: + needs: test-data-upload + if: github.ref == 'refs/heads/master' + uses: ./.github/workflows/release.yml + secrets: inherit + cleanup: runs-on: self-hosted - needs: [engine, server, ui] + needs: [engine, server, ui, test-data-upload] if: always() steps: - name: Final cleanup diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..9fea580 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,97 @@ +name: Release build + +on: + pull_request: + workflow_dispatch: + workflow_call: + +permissions: + contents: write + +jobs: + release: + name: Build and release (master only) + runs-on: self-hosted + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build Engine for Linux + run: | + cd $(git rev-parse --show-toplevel) + pwd + mkdir release/linux -p + cd engine/ + rustup target add x86_64-unknown-linux-gnu + cargo build --release --target x86_64-unknown-linux-gnu + pwd + cp target/x86_64-unknown-linux-gnu/release/engine $(git rev-parse --show-toplevel)/release/linux/engine + + - name: Build Server for Linux + run: | + cd $(git rev-parse --show-toplevel) + pwd + mkdir release/linux -p + cd server/ + rustup target add x86_64-unknown-linux-gnu + cargo build --release --target x86_64-unknown-linux-gnu + pwd + cp target/x86_64-unknown-linux-gnu/release/server $(git rev-parse --show-toplevel)/release/linux/server + + - name: Build UI for Linux + run: | + cd $(git rev-parse --show-toplevel) + pwd + mkdir release/linux -p + cd ui/ + rustup target add x86_64-unknown-linux-gnu + cargo build --release --target x86_64-unknown-linux-gnu + pwd + cp target/x86_64-unknown-linux-gnu/release/ui $(git rev-parse --show-toplevel)/release/linux/ui + + + - name: Build Engine for Windows + run: | + cd $(git rev-parse --show-toplevel) + pwd + mkdir release/windows -p + cd engine/ + rustup target add x86_64-pc-windows-gnu + cargo build --release --target x86_64-pc-windows-gnu + pwd + cp target/x86_64-pc-windows-gnu/release/engine.exe $(git rev-parse --show-toplevel)/release/windows/engine.exe + + - name: Build Server for Windows + run: | + cd $(git rev-parse --show-toplevel) + pwd + mkdir release/windows -p + cd server/ + rustup target add x86_64-pc-windows-gnu + cargo build --release --target x86_64-pc-windows-gnu + pwd + cp target/x86_64-pc-windows-gnu/release/server.exe $(git rev-parse --show-toplevel)/release/windows/server.exe + + - name: Build UI for Windows + run: | + cd $(git rev-parse --show-toplevel) + pwd + mkdir release/windows -p + cd ui/ + rustup target add x86_64-pc-windows-gnu + cargo build --release --target x86_64-pc-windows-gnu + pwd + cp target/x86_64-pc-windows-gnu/release/ui.exe $(git rev-parse --show-toplevel)/release/windows/ui.exe + + + - name: Create GitHub Release + uses: softprops/action-gh-release@v2 + with: + tag_name: "v${{ github.run_number }}" + name: "Release v${{ github.run_number }}" + files: | + release/* + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + diff --git a/.github/workflows/upload_data.yml b/.github/workflows/upload_data.yml new file mode 100644 index 0000000..f8768ef --- /dev/null +++ b/.github/workflows/upload_data.yml @@ -0,0 +1,57 @@ +name: Upload Test Results to Google Sheets + +on: + workflow_dispatch: + +jobs: + upload: + runs-on: self-hosted + steps: + - name: Checkout repo + uses: actions/checkout@v4 + + - name: Setup Python (for Google Sheets API) + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install dependencies + run: | + pip install gspread google-auth + + - name: Upload test_data.log to Google Sheets + env: + GOOGLE_SERVICE_ACCOUNT_JSON: ${{ secrets.GOOGLE_SERVICE_ACCOUNT_JSON }} + SPREADSHEET_ID: ${{ secrets.SPREADSHEET_ID }} + run: | + echo "$GOOGLE_SERVICE_ACCOUNT_JSON" > service_account.json + + python <<'PYCODE' + import gspread, json, time + + # credentials + creds = json.load(open("service_account.json")) + gc = gspread.service_account_from_dict(creds) + sh = gc.open_by_key("${{ secrets.SPREADSHEET_ID }}") + + with open("test_data.log", "r") as f: + lines = [line.strip() for line in f if line.strip()] + + project = lines[0].lower() + worksheet = sh.worksheet(project) + + # project name + data = lines[1:] + + #blank rows + existing_rows = len(worksheet.get_all_values()) + start_row = existing_rows + 3 + + # Split data into columns (by spaces) + rows_to_append = [row.split() for row in data] + + for i, row in enumerate(rows_to_append): + worksheet.insert_row(row, start_row + i) + + print(f"Uploaded {len(rows_to_append)} rows to '{project}' tab.") + PYCODE