This commit is contained in:
@@ -1,138 +0,0 @@
|
|||||||
name: Build and Release
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build-and-release:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- name: Checkout
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Check if version already released
|
|
||||||
id: version-check
|
|
||||||
env:
|
|
||||||
GITEA_TOKEN: ${{ secrets.DEST_GITEA_TOKEN }}
|
|
||||||
run: |
|
|
||||||
VERSION=$(grep '"version"' package.json | head -1 | sed 's/.*"version": *"\([^"]*\)".*/\1/')
|
|
||||||
TAG="v$VERSION"
|
|
||||||
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
|
|
||||||
echo "TAG=$TAG" >> "$GITHUB_OUTPUT"
|
|
||||||
|
|
||||||
STATUS=$(curl -s -o /dev/null -w "%{http_code}" \
|
|
||||||
"https://gitea.crjlab.net/api/v1/repos/bigjakk/krunker-civilian-client/releases/tags/$TAG" \
|
|
||||||
-H "Authorization: token $GITEA_TOKEN")
|
|
||||||
|
|
||||||
if [ "$STATUS" = "200" ]; then
|
|
||||||
echo "Release $TAG already exists, skipping build"
|
|
||||||
echo "SKIP=true" >> "$GITHUB_OUTPUT"
|
|
||||||
else
|
|
||||||
echo "No release for $TAG, proceeding with build"
|
|
||||||
echo "SKIP=false" >> "$GITHUB_OUTPUT"
|
|
||||||
fi
|
|
||||||
|
|
||||||
- name: Setup Node.js
|
|
||||||
if: steps.version-check.outputs.SKIP == 'false'
|
|
||||||
uses: actions/setup-node@v4
|
|
||||||
with:
|
|
||||||
node-version: '22'
|
|
||||||
|
|
||||||
- name: Install system dependencies
|
|
||||||
if: steps.version-check.outputs.SKIP == 'false'
|
|
||||||
run: |
|
|
||||||
dpkg --add-architecture i386
|
|
||||||
apt-get update -qq
|
|
||||||
apt-get install -y --no-install-recommends \
|
|
||||||
wine wine32 wine64 \
|
|
||||||
libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2t64 \
|
|
||||||
libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 \
|
|
||||||
libxfixes3 libxrandr2 libgbm1 libpango-1.0-0 \
|
|
||||||
libcairo2 libasound2t64 libgtk-3-0
|
|
||||||
WINEDEBUG=-all wine wineboot --init || true
|
|
||||||
|
|
||||||
- name: Install dependencies
|
|
||||||
if: steps.version-check.outputs.SKIP == 'false'
|
|
||||||
run: npm ci
|
|
||||||
|
|
||||||
- name: Build source
|
|
||||||
if: steps.version-check.outputs.SKIP == 'false'
|
|
||||||
run: npm run build
|
|
||||||
|
|
||||||
- name: Build Windows distributables
|
|
||||||
if: steps.version-check.outputs.SKIP == 'false'
|
|
||||||
env:
|
|
||||||
WINEDEBUG: "-all"
|
|
||||||
run: npx electron-builder --win -c.electronDist=node_modules/electron/dist-win --publish never
|
|
||||||
|
|
||||||
- name: Build Linux distributables
|
|
||||||
if: steps.version-check.outputs.SKIP == 'false'
|
|
||||||
run: npx electron-builder --linux --publish never
|
|
||||||
|
|
||||||
- name: Report build sizes
|
|
||||||
if: steps.version-check.outputs.SKIP == 'false'
|
|
||||||
run: |
|
|
||||||
echo "=== Build output sizes ==="
|
|
||||||
ls -lh out/*.exe out/*.AppImage out/*.deb 2>/dev/null || true
|
|
||||||
echo "=== Electron dist-win (patched Windows) ==="
|
|
||||||
du -sh node_modules/electron/dist-win/ 2>/dev/null || true
|
|
||||||
echo "=== Electron dist (stock Linux) ==="
|
|
||||||
du -sh node_modules/electron/dist/ 2>/dev/null || true
|
|
||||||
echo "=== Unpacked Windows build ==="
|
|
||||||
du -sh out/win-unpacked/ 2>/dev/null || true
|
|
||||||
du -sh out/win-unpacked/resources/ 2>/dev/null || true
|
|
||||||
du -sh out/win-unpacked/locales/ 2>/dev/null || true
|
|
||||||
|
|
||||||
- name: Create release and upload assets
|
|
||||||
if: steps.version-check.outputs.SKIP == 'false'
|
|
||||||
env:
|
|
||||||
GITEA_TOKEN: ${{ secrets.DEST_GITEA_TOKEN }}
|
|
||||||
TAG: ${{ steps.version-check.outputs.TAG }}
|
|
||||||
run: |
|
|
||||||
GITEA_BASE="https://gitea.crjlab.net"
|
|
||||||
REPO="bigjakk/krunker-civilian-client"
|
|
||||||
|
|
||||||
# Create tag
|
|
||||||
curl -s -X POST "$GITEA_BASE/api/v1/repos/$REPO/tags" \
|
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "{\"tag_name\": \"$TAG\", \"message\": \"$TAG\", \"target\": \"$GITHUB_SHA\"}"
|
|
||||||
|
|
||||||
# Create release
|
|
||||||
RESPONSE=$(curl -s -X POST "$GITEA_BASE/api/v1/repos/$REPO/releases" \
|
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
|
||||||
-H "Content-Type: application/json" \
|
|
||||||
-d "{
|
|
||||||
\"tag_name\": \"$TAG\",
|
|
||||||
\"name\": \"$TAG\",
|
|
||||||
\"body\": \"Automated build for $TAG\",
|
|
||||||
\"draft\": false,
|
|
||||||
\"prerelease\": false
|
|
||||||
}")
|
|
||||||
|
|
||||||
RELEASE_ID=$(echo "$RESPONSE" | jq -r '.id')
|
|
||||||
echo "Created release ID: $RELEASE_ID"
|
|
||||||
|
|
||||||
if [ "$RELEASE_ID" = "null" ] || [ -z "$RELEASE_ID" ]; then
|
|
||||||
echo "Failed to create release:"
|
|
||||||
echo "$RESPONSE"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Upload all built artifacts
|
|
||||||
for file in out/*.exe out/*.AppImage out/*.deb; do
|
|
||||||
[ -f "$file" ] || continue
|
|
||||||
FILENAME=$(basename "$file")
|
|
||||||
SAFE_NAME=$(echo "$FILENAME" | tr ' ' '_')
|
|
||||||
echo "Uploading: $SAFE_NAME ($(du -h "$file" | cut -f1))"
|
|
||||||
|
|
||||||
curl -s -X POST \
|
|
||||||
"$GITEA_BASE/api/v1/repos/$REPO/releases/$RELEASE_ID/assets?name=$SAFE_NAME" \
|
|
||||||
-H "Authorization: token $GITEA_TOKEN" \
|
|
||||||
-F "attachment=@$file" \
|
|
||||||
| jq -r '" -> \(.name) (\(.size) bytes)"'
|
|
||||||
done
|
|
||||||
|
|
||||||
echo "All assets uploaded"
|
|
||||||
@@ -0,0 +1,104 @@
|
|||||||
|
name: Build and Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-release:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Check if version already released
|
||||||
|
id: version-check
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
VERSION=$(grep '"version"' package.json | head -1 | sed 's/.*"version": *"\([^"]*\)".*/\1/')
|
||||||
|
TAG="v$VERSION"
|
||||||
|
echo "VERSION=$VERSION" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "TAG=$TAG" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
if gh release view "$TAG" --repo "$GITHUB_REPOSITORY" >/dev/null 2>&1; then
|
||||||
|
echo "Release $TAG already exists, skipping build"
|
||||||
|
echo "SKIP=true" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "No release for $TAG, proceeding with build"
|
||||||
|
echo "SKIP=false" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Setup Node.js
|
||||||
|
if: steps.version-check.outputs.SKIP == 'false'
|
||||||
|
uses: actions/setup-node@v4
|
||||||
|
with:
|
||||||
|
node-version: '22'
|
||||||
|
|
||||||
|
- name: Install system dependencies
|
||||||
|
if: steps.version-check.outputs.SKIP == 'false'
|
||||||
|
run: |
|
||||||
|
sudo dpkg --add-architecture i386
|
||||||
|
sudo apt-get update -qq
|
||||||
|
sudo apt-get install -y --no-install-recommends \
|
||||||
|
wine wine32 wine64 \
|
||||||
|
libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2t64 \
|
||||||
|
libdrm2 libxkbcommon0 libxcomposite1 libxdamage1 \
|
||||||
|
libxfixes3 libxrandr2 libgbm1 libpango-1.0-0 \
|
||||||
|
libcairo2 libasound2t64 libgtk-3-0
|
||||||
|
WINEDEBUG=-all wine wineboot --init || true
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
if: steps.version-check.outputs.SKIP == 'false'
|
||||||
|
run: npm ci --legacy-peer-deps
|
||||||
|
|
||||||
|
- name: Build source
|
||||||
|
if: steps.version-check.outputs.SKIP == 'false'
|
||||||
|
run: npm run build
|
||||||
|
|
||||||
|
- name: Build Windows distributables
|
||||||
|
if: steps.version-check.outputs.SKIP == 'false'
|
||||||
|
env:
|
||||||
|
WINEDEBUG: "-all"
|
||||||
|
run: npx electron-builder --win -c.electronDist=node_modules/electron/dist-win --publish never
|
||||||
|
|
||||||
|
- name: Build Linux distributables
|
||||||
|
if: steps.version-check.outputs.SKIP == 'false'
|
||||||
|
run: npx electron-builder --linux -c.electronDist=node_modules/electron/dist-linux --publish never
|
||||||
|
|
||||||
|
- name: Report build sizes
|
||||||
|
if: steps.version-check.outputs.SKIP == 'false'
|
||||||
|
run: |
|
||||||
|
echo "=== Build output sizes ==="
|
||||||
|
ls -lh out/*.exe out/*.AppImage out/*.deb 2>/dev/null || true
|
||||||
|
|
||||||
|
- name: Create GitHub release and upload assets
|
||||||
|
if: steps.version-check.outputs.SKIP == 'false'
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
run: |
|
||||||
|
# Collect built artifacts
|
||||||
|
ASSETS=()
|
||||||
|
for file in out/*.exe out/*.AppImage out/*.deb; do
|
||||||
|
[ -f "$file" ] || continue
|
||||||
|
ASSETS+=("$file")
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ ${#ASSETS[@]} -eq 0 ]; then
|
||||||
|
echo "ERROR: No build artifacts found in out/"
|
||||||
|
ls -la out/ 2>/dev/null || echo "out/ directory does not exist"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Uploading ${#ASSETS[@]} assets:"
|
||||||
|
printf ' %s\n' "${ASSETS[@]}"
|
||||||
|
|
||||||
|
gh release create "${{ steps.version-check.outputs.TAG }}" \
|
||||||
|
--repo "$GITHUB_REPOSITORY" \
|
||||||
|
--title "${{ steps.version-check.outputs.TAG }}" \
|
||||||
|
--notes "Automated build for ${{ steps.version-check.outputs.TAG }}" \
|
||||||
|
"${ASSETS[@]}"
|
||||||
@@ -3,10 +3,10 @@
|
|||||||
> a high-performance krunker client with unlimited FPS, built on a custom-patched Electron
|
> a high-performance krunker client with unlimited FPS, built on a custom-patched Electron
|
||||||
|
|
||||||
**Download:**
|
**Download:**
|
||||||
[Windows (x64)](https://gitea.crjlab.net/bigjakk/Krunker-Civilian-Client/releases/latest) -
|
[Windows (x64)](https://github.com/bigjakk/Krunker-Civilian-Client/releases/latest) -
|
||||||
[Linux (AppImage)](https://gitea.crjlab.net/bigjakk/Krunker-Civilian-Client/releases/latest)
|
[Linux (AppImage)](https://github.com/bigjakk/Krunker-Civilian-Client/releases/latest)
|
||||||
|
|
||||||
## features
|
## Features
|
||||||
|
|
||||||
- unlimited FPS with no aim freeze (custom Electron build, see [below](#custom-electron-build))
|
- unlimited FPS with no aim freeze (custom Electron build, see [below](#custom-electron-build))
|
||||||
- unobtrusive — all features can be disabled, no watermarks
|
- unobtrusive — all features can be disabled, no watermarks
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
- auto-updater
|
- auto-updater
|
||||||
- maintained & open source
|
- maintained & open source
|
||||||
|
|
||||||
## hotkeys
|
## Hotkeys
|
||||||
|
|
||||||
All hotkeys are rebindable in settings.
|
All hotkeys are rebindable in settings.
|
||||||
|
|
||||||
@@ -58,30 +58,31 @@ All hotkeys are rebindable in settings.
|
|||||||
| `Ctrl+Shift+T` | Reopen closed tab |
|
| `Ctrl+Shift+T` | Reopen closed tab |
|
||||||
| `Ctrl+1-9` | Jump to tab |
|
| `Ctrl+1-9` | Jump to tab |
|
||||||
|
|
||||||
## userscripts
|
## Userscripts
|
||||||
|
|
||||||
Any `.js` file in the scripts folder will be loaded as a userscript if enabled in settings. Scripts support Tampermonkey-style metadata blocks (`@name`, `@author`, `@version`, `@desc`) and can define custom settings (boolean, number, select, color, keybind).
|
Any `.js` file in the scripts folder will be loaded as a userscript if enabled in settings. Scripts support Tampermonkey-style metadata blocks (`@name`, `@author`, `@version`, `@desc`) and can define custom settings (boolean, number, select, color, keybind).
|
||||||
|
|
||||||
> **Use userscripts at your own risk.** Do not write or use any userscripts which would give you a competitive advantage.
|
> **Use userscripts at your own risk.** Do not write or use any userscripts which would give you a competitive advantage.
|
||||||
|
|
||||||
## custom Electron build
|
## Custom Electron Build
|
||||||
|
|
||||||
This client uses a custom-patched Electron 42 build to overcome the aim freezing issue present in modern Electron versions. The patched binary is downloaded automatically during `npm install`.
|
This client uses a custom-patched Electron 42 build to overcome the aim freezing issue present in modern Electron versions. The patched binary is downloaded automatically during `npm install`.
|
||||||
|
|
||||||
For details on the patch and build instructions, see [Electron-Websocket-Fix](https://github.com/bigjakk/Electron-Websocket-Fix).
|
For details on the patch and build instructions, see [Electron-Websocket-Fix](https://github.com/bigjakk/Electron-Websocket-Fix).
|
||||||
|
|
||||||
## building from source
|
## Building From Source
|
||||||
|
|
||||||
1. Install [git](https://git-scm.com/downloads), [Node.js](https://nodejs.org/), and npm
|
1. Install [git](https://git-scm.com/downloads), [Node.js](https://nodejs.org/), and npm
|
||||||
2. Clone and install:
|
2. Clone and install:
|
||||||
```bash
|
```bash
|
||||||
git clone https://gitea.crjlab.net/bigjakk/Krunker-Civilian-Client.git
|
git clone https://github.com/bigjakk/Krunker-Civilian-Client.git
|
||||||
cd Krunker-Civilian-Client
|
cd Krunker-Civilian-Client
|
||||||
npm install
|
npm install
|
||||||
```
|
```
|
||||||
3. Run: `npm start` or `npm run dev` (dev mode with sourcemaps)
|
3. Run: `npm start` or `npm run dev` (dev mode with sourcemaps)
|
||||||
4. Package: `npm run dist:win` or `npm run dist:linux`
|
4. Package: `npm run dist:win` or `npm run dist:linux`
|
||||||
|
|
||||||
## credits
|
## Credits
|
||||||
|
|
||||||
- Built on ideas from [Crankshaft](https://github.com/KraXen72/crankshaft) by KraXen72
|
- Built on ideas from [Crankshaft](https://github.com/KraXen72/crankshaft) by KraXen72
|
||||||
|
- Inspired by [Glorp](https://github.com/slavcp/glorp) by slav
|
||||||
|
|||||||
@@ -67,5 +67,5 @@ linux:
|
|||||||
|
|
||||||
publish:
|
publish:
|
||||||
provider: github
|
provider: github
|
||||||
owner: krunker-civilian
|
owner: bigjakk
|
||||||
repo: krunker-civilian-client
|
repo: Krunker-Civilian-Client
|
||||||
|
|||||||
+2
-2
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
"name": "krunker-civilian-client",
|
"name": "krunker-civilian-client",
|
||||||
"version": "0.5.6",
|
"version": "0.6.0",
|
||||||
"description": "Cross-platform Krunker game client",
|
"description": "Cross-platform Krunker game client",
|
||||||
"main": "dist/main/index.js",
|
"main": "dist/main/index.js",
|
||||||
"homepage": "https://gitea.crjlab.net/bigjakk/krunker-civilian-client",
|
"homepage": "https://github.com/bigjakk/Krunker-Civilian-Client",
|
||||||
"author": "Krunker Civilian Client <krunker@crjlab.net>",
|
"author": "Krunker Civilian Client <krunker@crjlab.net>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|||||||
+87
-101
@@ -1,13 +1,15 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Downloads the patched Electron build and extracts it into node_modules/electron/dist/.
|
* Downloads patched Electron builds for Windows (v42) and Linux (v43).
|
||||||
*
|
*
|
||||||
* The patched Electron fixes input starvation ("aim freeze") when --disable-frame-rate-limit
|
* The patched Electron fixes input starvation ("aim freeze") when --disable-frame-rate-limit
|
||||||
* is active on modern Chromium. Without this, uncapped FPS causes 50-300ms input delays.
|
* is active on modern Chromium. Without this, uncapped FPS causes 50-300ms input delays.
|
||||||
*
|
*
|
||||||
* The zip is hosted as a release asset on the same Gitea repo. The script checks the
|
* Platform behavior:
|
||||||
* local version file to skip re-downloading if already present.
|
* Windows: patched Win → dist/ (replaces stock)
|
||||||
|
* Linux (local): patched Linux → dist/ (replaces stock), Win → dist-win/
|
||||||
|
* CI (Linux): Win → dist-win/, Linux → dist-linux/ (stock stays in dist/)
|
||||||
*
|
*
|
||||||
* Usage:
|
* Usage:
|
||||||
* node scripts/download-electron.js # download if needed
|
* node scripts/download-electron.js # download if needed
|
||||||
@@ -21,26 +23,18 @@ const path = require('path');
|
|||||||
const { execSync } = require('child_process');
|
const { execSync } = require('child_process');
|
||||||
|
|
||||||
// ── Configuration ──────────────────────────────────────────────────────────
|
// ── Configuration ──────────────────────────────────────────────────────────
|
||||||
const ELECTRON_VERSION = '42.0.0-nightly.20260227';
|
const GITHUB_BASE = 'https://github.com';
|
||||||
const ASSET_NAME = 'electron-v42.0.0-nightly-patched-win32-x64.zip';
|
const REPO = 'bigjakk/Electron-Websocket-Fix';
|
||||||
const GITEA_BASE = 'https://gitea.crjlab.net';
|
const RELEASE_TAG = 'v1.0.0';
|
||||||
const REPO = 'bigjakk/Krunker-Civilian-Client';
|
|
||||||
// The release tag that holds the patched Electron zip.
|
const PLATFORMS = {
|
||||||
// Upload the zip as an asset to this release on Gitea.
|
win32: { asset: 'electron-v42.0.0-nightly-release-patched-win32-x64.zip' },
|
||||||
const RELEASE_TAG = 'electron-patched';
|
linux: { asset: 'electron-v43.0.0-nightly-release-patched-linux-x64.zip' },
|
||||||
|
};
|
||||||
|
|
||||||
// On Windows, overwrite the npm-installed Electron with our patched build.
|
|
||||||
// On Linux/macOS (CI cross-compilation), extract to a separate dist-win/ directory
|
|
||||||
// so the npm-installed platform-native Electron stays in dist/ for bytenode compilation.
|
|
||||||
const IS_WIN = process.platform === 'win32';
|
const IS_WIN = process.platform === 'win32';
|
||||||
const ELECTRON_DIST = IS_WIN
|
const IS_CI = !!process.env.CI;
|
||||||
? path.resolve(__dirname, '..', 'node_modules', 'electron', 'dist')
|
const ELECTRON_BASE = path.resolve(__dirname, '..', 'node_modules', 'electron');
|
||||||
: path.resolve(__dirname, '..', 'node_modules', 'electron', 'dist-win');
|
|
||||||
const VERSION_FILE = path.join(ELECTRON_DIST, 'version');
|
|
||||||
// Separate marker file to distinguish patched from stock electron-nightly.
|
|
||||||
// Both have the same version string, so VERSION_FILE alone is not sufficient.
|
|
||||||
const PATCHED_MARKER = path.join(ELECTRON_DIST, '.patched');
|
|
||||||
const TEMP_ZIP = path.join(ELECTRON_DIST, '..', '_electron-patched.zip');
|
|
||||||
|
|
||||||
// ── Helpers ────────────────────────────────────────────────────────────────
|
// ── Helpers ────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -96,31 +90,6 @@ function downloadToFile(url, dest) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getAssetUrl() {
|
|
||||||
const apiUrl = `${GITEA_BASE}/api/v1/repos/${REPO}/releases/tags/${RELEASE_TAG}`;
|
|
||||||
const res = await get(apiUrl);
|
|
||||||
const body = await new Promise((resolve, reject) => {
|
|
||||||
let data = '';
|
|
||||||
res.on('data', (chunk) => { data += chunk; });
|
|
||||||
res.on('end', () => resolve(data));
|
|
||||||
res.on('error', reject);
|
|
||||||
});
|
|
||||||
|
|
||||||
const release = JSON.parse(body);
|
|
||||||
const asset = release.assets.find((a) => a.name === ASSET_NAME);
|
|
||||||
if (!asset) {
|
|
||||||
const names = release.assets.map((a) => a.name).join(', ');
|
|
||||||
throw new Error(
|
|
||||||
`Asset "${ASSET_NAME}" not found in release "${RELEASE_TAG}".\n` +
|
|
||||||
` Available assets: ${names || '(none)'}\n` +
|
|
||||||
` Upload the patched Electron zip to: ${GITEA_BASE}/${REPO}/releases/tag/${RELEASE_TAG}`
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Gitea API returns browser_download_url for direct download
|
|
||||||
return asset.browser_download_url;
|
|
||||||
}
|
|
||||||
|
|
||||||
function extractZip(zipPath, destDir) {
|
function extractZip(zipPath, destDir) {
|
||||||
// Use PowerShell on Windows, unzip on Linux/macOS
|
// Use PowerShell on Windows, unzip on Linux/macOS
|
||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
@@ -133,76 +102,93 @@ function extractZip(zipPath, destDir) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Per-directory install ──────────────────────────────────────────────────
|
||||||
|
|
||||||
|
async function installTo(distDir, platform) {
|
||||||
|
const force = process.argv.includes('--force');
|
||||||
|
const patchedMarker = path.join(distDir, '.patched');
|
||||||
|
const tempZip = path.join(ELECTRON_BASE, `_electron-patched-${platform.asset}`);
|
||||||
|
const label = path.relative(path.resolve(__dirname, '..'), distDir);
|
||||||
|
|
||||||
|
// Check if this exact asset is already installed.
|
||||||
|
// The marker stores the asset filename to handle version changes.
|
||||||
|
if (!force && fs.existsSync(patchedMarker)) {
|
||||||
|
const installed = fs.readFileSync(patchedMarker, 'utf8').trim();
|
||||||
|
if (installed === platform.asset) {
|
||||||
|
console.log(` [${label}] ${platform.asset} already installed, skipping`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log(` [${label}] Installed: ${installed}, need: ${platform.asset}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Direct download from GitHub release
|
||||||
|
const url = `${GITHUB_BASE}/${REPO}/releases/download/${RELEASE_TAG}/${platform.asset}`;
|
||||||
|
console.log(` [${label}] Asset URL: ${url}`);
|
||||||
|
|
||||||
|
// Download
|
||||||
|
await downloadToFile(url, tempZip);
|
||||||
|
const zipSize = (fs.statSync(tempZip).size / 1048576).toFixed(1);
|
||||||
|
console.log(` [${label}] Downloaded: ${zipSize} MB`);
|
||||||
|
|
||||||
|
// Clear existing target dir and extract
|
||||||
|
console.log(` [${label}] Extracting...`);
|
||||||
|
if (fs.existsSync(distDir)) {
|
||||||
|
fs.rmSync(distDir, { recursive: true, force: true });
|
||||||
|
}
|
||||||
|
fs.mkdirSync(distDir, { recursive: true });
|
||||||
|
extractZip(tempZip, distDir);
|
||||||
|
|
||||||
|
// Clean up temp zip
|
||||||
|
fs.unlinkSync(tempZip);
|
||||||
|
|
||||||
|
// Write marker with asset name for future skip-check
|
||||||
|
fs.writeFileSync(patchedMarker, platform.asset);
|
||||||
|
const versionFile = path.join(distDir, 'version');
|
||||||
|
if (fs.existsSync(versionFile)) {
|
||||||
|
const ver = fs.readFileSync(versionFile, 'utf8').trim();
|
||||||
|
console.log(` [${label}] Installed patched Electron ${ver}`);
|
||||||
|
} else {
|
||||||
|
console.log(` [${label}] Installed ${platform.asset} (no version file)`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ── Main ───────────────────────────────────────────────────────────────────
|
// ── Main ───────────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
async function main() {
|
async function main() {
|
||||||
const force = process.argv.includes('--force');
|
if (IS_WIN) {
|
||||||
|
// Windows local dev: patched Win → dist/ (replaces stock)
|
||||||
// Check if patched version is already installed.
|
await installTo(path.join(ELECTRON_BASE, 'dist'), PLATFORMS.win32);
|
||||||
// The .patched marker distinguishes our build from stock electron-nightly
|
} else if (IS_CI) {
|
||||||
// (both share the same version string).
|
// CI (Linux): keep stock in dist/ untouched,
|
||||||
if (!force && fs.existsSync(PATCHED_MARKER)) {
|
// patched Win → dist-win/, patched Linux → dist-linux/
|
||||||
const installed = fs.readFileSync(PATCHED_MARKER, 'utf8').trim();
|
await installTo(path.join(ELECTRON_BASE, 'dist-win'), PLATFORMS.win32);
|
||||||
if (installed === ELECTRON_VERSION) {
|
await installTo(path.join(ELECTRON_BASE, 'dist-linux'), PLATFORMS.linux);
|
||||||
console.log(` Patched Electron ${ELECTRON_VERSION} already installed, skipping`);
|
} else {
|
||||||
console.log(' (use --force to re-download)');
|
// Linux local dev: patched Linux → dist/ (for npm run dev),
|
||||||
return;
|
// patched Win → dist-win/ (for cross-compilation)
|
||||||
}
|
await installTo(path.join(ELECTRON_BASE, 'dist'), PLATFORMS.linux);
|
||||||
console.log(` Installed: ${installed}, need: ${ELECTRON_VERSION}`);
|
await installTo(path.join(ELECTRON_BASE, 'dist-win'), PLATFORMS.win32);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Resolve download URL from Gitea release
|
|
||||||
console.log(` Fetching release info for "${RELEASE_TAG}"...`);
|
|
||||||
const url = await getAssetUrl();
|
|
||||||
console.log(` Asset URL: ${url}`);
|
|
||||||
|
|
||||||
// Download
|
|
||||||
await downloadToFile(url, TEMP_ZIP);
|
|
||||||
const zipSize = (fs.statSync(TEMP_ZIP).size / 1048576).toFixed(1);
|
|
||||||
console.log(` Downloaded: ${zipSize} MB`);
|
|
||||||
|
|
||||||
// Clear existing target dir and extract
|
|
||||||
console.log(` Extracting to ${path.relative(path.resolve(__dirname, '..'), ELECTRON_DIST)}/...`);
|
|
||||||
if (fs.existsSync(ELECTRON_DIST)) {
|
|
||||||
fs.rmSync(ELECTRON_DIST, { recursive: true, force: true });
|
|
||||||
}
|
|
||||||
fs.mkdirSync(ELECTRON_DIST, { recursive: true });
|
|
||||||
extractZip(TEMP_ZIP, ELECTRON_DIST);
|
|
||||||
|
|
||||||
// Clean up temp zip
|
|
||||||
fs.unlinkSync(TEMP_ZIP);
|
|
||||||
|
|
||||||
// Write path.txt so the electron package's lazy downloader (index.js)
|
// Write path.txt so the electron package's lazy downloader (index.js)
|
||||||
// considers the binary already installed and doesn't re-download stock.
|
// considers the binary already installed and doesn't re-download stock.
|
||||||
// On non-Windows (CI cross-compilation), skip this so electron-nightly still
|
const platformExe = IS_WIN ? 'electron.exe' : 'electron';
|
||||||
// downloads the native Linux binary into dist/ for the Linux build target.
|
fs.writeFileSync(path.join(ELECTRON_BASE, 'path.txt'), platformExe);
|
||||||
if (IS_WIN) {
|
|
||||||
fs.writeFileSync(path.join(ELECTRON_DIST, '..', 'path.txt'), 'electron.exe');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Write marker and verify
|
|
||||||
if (fs.existsSync(VERSION_FILE)) {
|
|
||||||
const ver = fs.readFileSync(VERSION_FILE, 'utf8').trim();
|
|
||||||
fs.writeFileSync(PATCHED_MARKER, ver);
|
|
||||||
console.log(` Installed patched Electron ${ver}`);
|
|
||||||
} else {
|
|
||||||
console.log(' Warning: version file not found after extraction');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('[KCC] Setting up patched Electron...');
|
console.log('[KCC] Setting up patched Electron...');
|
||||||
main().then(() => {
|
main().then(() => {
|
||||||
console.log('[KCC] Patched Electron ready.');
|
console.log('[KCC] Patched Electron ready.');
|
||||||
|
if (!IS_WIN) {
|
||||||
|
console.log(' (use --force to re-download)');
|
||||||
|
}
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.error('[KCC] Electron download failed:', err.message);
|
console.error('[KCC] Electron download failed:', err.message);
|
||||||
console.error('');
|
console.error('');
|
||||||
console.error(' If this is your first time building, you need the patched Electron zip');
|
console.error(' Download the patched Electron manually from:');
|
||||||
console.error(` uploaded as a release asset on ${GITEA_BASE}/${REPO}`);
|
console.error(` ${GITHUB_BASE}/${REPO}/releases/tag/${RELEASE_TAG}`);
|
||||||
console.error('');
|
console.error('');
|
||||||
console.error(' 1. Go to: ' + GITEA_BASE + '/' + REPO + '/releases/new');
|
console.error(` Win asset: ${PLATFORMS.win32.asset}`);
|
||||||
console.error(` 2. Create a release with tag: ${RELEASE_TAG}`);
|
console.error(` Linux asset: ${PLATFORMS.linux.asset}`);
|
||||||
console.error(` 3. Upload: ${ASSET_NAME}`);
|
|
||||||
console.error('');
|
|
||||||
console.error(' See electron-build/BUILD.md for how to build Electron from source.');
|
|
||||||
process.exit(1);
|
process.exit(1);
|
||||||
});
|
});
|
||||||
|
|||||||
+1
-1
@@ -683,7 +683,7 @@ async function launchApp(): Promise<void> {
|
|||||||
const tag = version.startsWith('v') ? version : `v${version}`;
|
const tag = version.startsWith('v') ? version : `v${version}`;
|
||||||
try {
|
try {
|
||||||
const data = await new Promise<string>((resolve, reject) => {
|
const data = await new Promise<string>((resolve, reject) => {
|
||||||
httpsGet(`https://gitea.crjlab.net/api/v1/repos/bigjakk/Krunker-Civilian-Client/releases/tags/${tag}`, (res) => {
|
httpsGet(`https://api.github.com/repos/bigjakk/Krunker-Civilian-Client/releases/tags/${tag}`, { headers: { 'User-Agent': 'KCC' } }, (res) => {
|
||||||
let body = '';
|
let body = '';
|
||||||
res.on('data', (chunk: string) => { body += chunk; });
|
res.on('data', (chunk: string) => { body += chunk; });
|
||||||
res.on('end', () => resolve(body));
|
res.on('end', () => resolve(body));
|
||||||
|
|||||||
+2
-4
@@ -13,11 +13,9 @@ export interface UpdateInfo {
|
|||||||
export type ProgressCallback = (percent: number) => void;
|
export type ProgressCallback = (percent: number) => void;
|
||||||
|
|
||||||
const UPDATE_CONFIG = {
|
const UPDATE_CONFIG = {
|
||||||
// Gitea provider
|
checkUrl: 'https://api.github.com/repos/bigjakk/Krunker-Civilian-Client/releases/latest',
|
||||||
checkUrl: 'https://gitea.crjlab.net/api/v1/repos/bigjakk/Krunker-Civilian-Client/releases/latest',
|
|
||||||
assetPattern: /Setup\.exe$/i,
|
assetPattern: /Setup\.exe$/i,
|
||||||
// Allowed hosts for update check and download (including redirects)
|
allowedHosts: ['github.com', 'api.github.com', 'objects.githubusercontent.com'],
|
||||||
allowedHosts: ['gitea.crjlab.net'],
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const CHECK_TIMEOUT_MS = 10000;
|
const CHECK_TIMEOUT_MS = 10000;
|
||||||
|
|||||||
Reference in New Issue
Block a user