From facdfb564e70bc2a99699f31b872447668b62c31 Mon Sep 17 00:00:00 2001 From: Tw93 Date: Wed, 20 Aug 2025 15:44:43 +0800 Subject: [PATCH] :art: update pake cli actions --- .github/workflows/pake-cli.yaml | 35 ++++++++++++++++++------- bin/builders/BaseBuilder.ts | 2 +- script/build_with_pake_cli.js | 46 ++++++++++++++++++++++++++++++--- 3 files changed, 69 insertions(+), 14 deletions(-) diff --git a/.github/workflows/pake-cli.yaml b/.github/workflows/pake-cli.yaml index 193634e..aed2041 100644 --- a/.github/workflows/pake-cli.yaml +++ b/.github/workflows/pake-cli.yaml @@ -68,6 +68,7 @@ jobs: uses: actions/setup-node@v4 with: node-version: 22 + cache: 'npm' - name: Install Rust for ubuntu-24.04 if: inputs.platform == 'ubuntu-24.04' @@ -102,11 +103,32 @@ jobs: packages: libsoup-3.0-dev libdbus-1-dev libjavascriptcoregtk-4.1-dev libwebkit2gtk-4.1-dev build-essential curl wget file libxdo-dev libssl-dev libgtk-3-dev libayatana-appindicator3-dev librsvg2-dev gnome-video-effects gnome-video-effects-extra version: 1.1 - - name: Install pake-cli local - shell: bash + - name: Cache Node dependencies + uses: actions/cache@v4 + with: + path: | + node_modules + ~/.npm + key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} + restore-keys: | + ${{ runner.os }}-node- + + - name: Cache pake-cli installation + uses: actions/cache@v4 + id: pake_cache + with: + path: node_modules/pake-cli + key: ${{ runner.os }}-pake-cli-${{ hashFiles('**/package.json') }} + + - name: Install pake-cli and script dependencies run: | - echo "install pake on local" - npm install pake-cli + if [ ! -d "node_modules/pake-cli" ]; then + echo "Installing pake-cli..." + npm install pake-cli + else + echo "pake-cli found in cache" + fi + npm install execa axios --no-package-lock - name: Rust cache restore uses: actions/cache/restore@v4.2.0 @@ -120,11 +142,6 @@ jobs: node_modules/pake-cli/src-tauri/target/ key: ${{ inputs.platform }}-cargo-${{ hashFiles('node_modules/pake-cli/src-tauri/Cargo.lock') }} - - name: Install dependencies - run: | - npm install execa - npm install axios - - name: Build with pake-cli timeout-minutes: 15 run: | diff --git a/bin/builders/BaseBuilder.ts b/bin/builders/BaseBuilder.ts index 1854a59..ef5f974 100644 --- a/bin/builders/BaseBuilder.ts +++ b/bin/builders/BaseBuilder.ts @@ -36,7 +36,7 @@ export default abstract class BaseBuilder { } private getBuildTimeout(): number { - return 300000; // 5 minutes for build process + return 900000; // 15 minutes for all builds } async prepare() { diff --git a/script/build_with_pake_cli.js b/script/build_with_pake_cli.js index 0d5f506..df0c4b5 100644 --- a/script/build_with_pake_cli.js +++ b/script/build_with_pake_cli.js @@ -97,17 +97,24 @@ const main = async () => { let params = buildParameters(); // Multi-arch target is now handled in GitHub Actions workflow - + + // Download icon in parallel with parameter preparation if needed + let iconPromise = null; if (process.env.ICON && process.env.ICON !== "") { const iconFile = getIconFileName(); - const iconParams = await downloadIcon(iconFile); - params.push(...iconParams); + iconPromise = downloadIcon(iconFile); } else { console.log( "Won't download the icon as ICON environment variable is not defined!", ); } + // If icon is being downloaded, wait for it and add to params + if (iconPromise) { + const iconParams = await iconPromise; + params.push(...iconParams); + } + console.log("Pake parameters:", params.join(" ")); console.log("Compiling...."); @@ -119,14 +126,45 @@ const main = async () => { fs.mkdirSync("output"); } - // Move built files to output directory + // Move built files to output directory more efficiently + const buildPaths = [ + `src-tauri/target/release/bundle`, + `src-tauri/target/universal-apple-darwin/release/bundle` + ]; + + for (const buildPath of buildPaths) { + if (fs.existsSync(buildPath)) { + const bundleFiles = fs.readdirSync(buildPath, { recursive: true }) + .filter(file => { + const fullPath = path.join(buildPath, file); + return fs.statSync(fullPath).isFile() && + (file.endsWith('.dmg') || file.endsWith('.exe') || + file.endsWith('.deb') || file.endsWith('.rpm') || file.endsWith('.AppImage')); + }); + + for (const file of bundleFiles) { + const srcPath = path.join(buildPath, file); + const destPath = path.join("output", path.basename(file)); + await execa("cp", [srcPath, destPath]); + } + break; // Found files, no need to check other paths + } + } + + // Fallback to original method if no bundle files found const files = fs.readdirSync("."); const namePattern = new RegExp(`^${process.env.NAME}\\..*$`); + let foundFiles = false; for (const file of files) { if (namePattern.test(file)) { await execa("mv", [file, path.join("output", file)]); + foundFiles = true; } } + + if (!foundFiles) { + console.log("Warning: No output files found matching pattern"); + } console.log("Build Success"); process.chdir("../..");