mirror of
https://github.com/LCE-Hub/LCE-Emerald-Launcher.git
synced 2026-08-20 04:27:29 +00:00
feat: android!
This commit is contained in:
parent
31a1835503
commit
0adf4b3264
3
.github/workflows/experimental.yml
vendored
3
.github/workflows/experimental.yml
vendored
|
|
@ -208,6 +208,9 @@ jobs:
|
||||||
- name: install frontend dependencies
|
- name: install frontend dependencies
|
||||||
run: pnpm install
|
run: pnpm install
|
||||||
|
|
||||||
|
- name: download android bundled assets
|
||||||
|
run: pnpm android:assets
|
||||||
|
|
||||||
- name: restore gradle wrapper jar
|
- name: restore gradle wrapper jar
|
||||||
run: |
|
run: |
|
||||||
VER=$(sed -n 's/.*gradle-\([0-9][0-9.]*\)-bin\.zip.*/\1/p' src-tauri/gen/android/gradle/wrapper/gradle-wrapper.properties)
|
VER=$(sed -n 's/.*gradle-\([0-9][0-9.]*\)-bin\.zip.*/\1/p' src-tauri/gen/android/gradle/wrapper/gradle-wrapper.properties)
|
||||||
|
|
|
||||||
3
.github/workflows/publish.yml
vendored
3
.github/workflows/publish.yml
vendored
|
|
@ -180,6 +180,9 @@ jobs:
|
||||||
- name: install frontend dependencies
|
- name: install frontend dependencies
|
||||||
run: pnpm install
|
run: pnpm install
|
||||||
|
|
||||||
|
- name: download android bundled assets
|
||||||
|
run: pnpm android:assets
|
||||||
|
|
||||||
- name: restore gradle wrapper jar
|
- name: restore gradle wrapper jar
|
||||||
run: |
|
run: |
|
||||||
VER=$(sed -n 's/.*gradle-\([0-9][0-9.]*\)-bin\.zip.*/\1/p' src-tauri/gen/android/gradle/wrapper/gradle-wrapper.properties)
|
VER=$(sed -n 's/.*gradle-\([0-9][0-9.]*\)-bin\.zip.*/\1/p' src-tauri/gen/android/gradle/wrapper/gradle-wrapper.properties)
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@
|
||||||
"tauri": "tauri",
|
"tauri": "tauri",
|
||||||
"tauri:build": "tauri build && pnpm run post-build:macos",
|
"tauri:build": "tauri build && pnpm run post-build:macos",
|
||||||
"post-build:macos": "bash src-tauri/scripts/post-build-macos.sh",
|
"post-build:macos": "bash src-tauri/scripts/post-build-macos.sh",
|
||||||
|
"android:assets": "node scripts/download-android-assets.mjs",
|
||||||
"flatpak": "flatpak-builder --user --install-deps-from=flathub --repo=emerald-repo --force-clean build-flatpak flatpak/io.github.Emerald_Legacy_Launcher.Emerald_Legacy_Launcher.yml && flatpak build-bundle emerald-repo emerald.flatpak io.github.Emerald_Legacy_Launcher.Emerald_Legacy_Launcher"
|
"flatpak": "flatpak-builder --user --install-deps-from=flathub --repo=emerald-repo --force-clean build-flatpak flatpak/io.github.Emerald_Legacy_Launcher.Emerald_Legacy_Launcher.yml && flatpak build-bundle emerald-repo emerald.flatpak io.github.Emerald_Legacy_Launcher.Emerald_Legacy_Launcher"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|
|
||||||
87
scripts/download-android-assets.mjs
Normal file
87
scripts/download-android-assets.mjs
Normal file
|
|
@ -0,0 +1,87 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
import {
|
||||||
|
createWriteStream,
|
||||||
|
createReadStream,
|
||||||
|
existsSync,
|
||||||
|
rename,
|
||||||
|
} from "node:fs";
|
||||||
|
import { mkdir } from "node:fs/promises";
|
||||||
|
import { createHash } from "node:crypto";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
import path from "node:path";
|
||||||
|
const RELEASE_TAG = "android-assets-v1";
|
||||||
|
const REPO = "LCE-Hub/LCE-Emerald-Launcher";
|
||||||
|
const ASSET_DIR = fileURLToPath(
|
||||||
|
new URL("../src-tauri/gen/android/app/src/main/assets/", import.meta.url),
|
||||||
|
);
|
||||||
|
|
||||||
|
const ASSETS = [
|
||||||
|
{
|
||||||
|
file: "imagefs.tar.zst",
|
||||||
|
sha256: "7838756e6a05c91afff68f4bf12aa2780f815877753f8dd354e203e99b9caf8a",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
file: "proton-11.0-arm64ec.tar.zst",
|
||||||
|
sha256: "ceb768396c2d44256518f94ae236f0c1f40738cf050a52e990e2fef67ff161df",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
function sha256File(file) {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const hash = createHash("sha256");
|
||||||
|
const stream = createReadStream(file);
|
||||||
|
stream.on("data", (chunk) => hash.update(chunk));
|
||||||
|
stream.on("end", () => resolve(hash.digest("hex")));
|
||||||
|
stream.on("error", reject);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async function download(url, dest) {
|
||||||
|
const res = await fetch(url, { redirect: "follow" });
|
||||||
|
if (!res.ok) {
|
||||||
|
throw new Error(`HTTP ${res.status} ${res.statusText} for ${url}`);
|
||||||
|
}
|
||||||
|
const fileStream = createWriteStream(dest);
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
res.body.pipe(fileStream);
|
||||||
|
res.body.on("error", reject);
|
||||||
|
fileStream.on("finish", resolve);
|
||||||
|
fileStream.on("error", reject);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
let failed = false;
|
||||||
|
for (const asset of ASSETS) {
|
||||||
|
const target = path.join(ASSET_DIR, asset.file);
|
||||||
|
const exists = existsSync(target);
|
||||||
|
if (exists) {
|
||||||
|
const actual = await sha256File(target);
|
||||||
|
if (actual === asset.sha256) {
|
||||||
|
console.log(`ok ${asset.file} (up to date)`);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
console.error(
|
||||||
|
`error ${asset.file}: sha256 mismatch (expected ${asset.sha256}, got ${actual}); delete it and rerun`,
|
||||||
|
);
|
||||||
|
failed = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const url = `https://github.com/${REPO}/releases/download/${RELEASE_TAG}/${asset.file}`;
|
||||||
|
console.log(`get ${asset.file} <- ${url}`);
|
||||||
|
await mkdir(path.dirname(target), { recursive: true });
|
||||||
|
const tmp = target + ".part";
|
||||||
|
await download(url, tmp);
|
||||||
|
const actual = await sha256File(tmp);
|
||||||
|
if (actual !== asset.sha256) {
|
||||||
|
console.error(
|
||||||
|
`error ${asset.file}: downloaded sha256 mismatch (expected ${asset.sha256}, got ${actual})`,
|
||||||
|
);
|
||||||
|
failed = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
await rename(tmp, target);
|
||||||
|
console.log(`okay ${asset.file} (downloaded)`);
|
||||||
|
}
|
||||||
|
|
||||||
|
process.exit(failed ? 1 : 0);
|
||||||
Loading…
Reference in a new issue