🎨 update github actions performance

This commit is contained in:
Tw93
2025-08-20 15:52:30 +08:00
parent facdfb564e
commit fe10dc7848
4 changed files with 45 additions and 56 deletions

View File

@@ -68,7 +68,7 @@ jobs:
uses: actions/setup-node@v4 uses: actions/setup-node@v4
with: with:
node-version: 22 node-version: 22
cache: 'npm' cache: "npm"
- name: Install Rust for ubuntu-24.04 - name: Install Rust for ubuntu-24.04
if: inputs.platform == 'ubuntu-24.04' if: inputs.platform == 'ubuntu-24.04'
@@ -90,7 +90,7 @@ jobs:
with: with:
toolchain: stable toolchain: stable
target: x86_64-apple-darwin target: x86_64-apple-darwin
- name: Add additional Rust target for multi-arch - name: Add additional Rust target for multi-arch
if: inputs.platform == 'macos-latest' && inputs.multi_arch == true if: inputs.platform == 'macos-latest' && inputs.multi_arch == true
run: | run: |

View File

@@ -77,6 +77,16 @@ jobs:
node-version: 22 node-version: 22
cache: "npm" cache: "npm"
- name: Cache Node dependencies
uses: actions/cache@v4
with:
path: |
node_modules
~/.npm
key: ${{ runner.os }}-node-deps-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-deps-
- name: Install dependencies (ubuntu only) - name: Install dependencies (ubuntu only)
if: matrix.os == 'ubuntu-latest' if: matrix.os == 'ubuntu-latest'
uses: awalsh128/cache-apt-pkgs-action@v1.4.3 uses: awalsh128/cache-apt-pkgs-action@v1.4.3
@@ -94,7 +104,7 @@ jobs:
~/.cargo/registry/cache/ ~/.cargo/registry/cache/
~/.cargo/git/db/ ~/.cargo/git/db/
src-tauri/target/ src-tauri/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
- name: Config App - name: Config App
env: env:
@@ -108,23 +118,30 @@ jobs:
- name: Build for Ubuntu - name: Build for Ubuntu
if: matrix.os == 'ubuntu-latest' if: matrix.os == 'ubuntu-latest'
timeout-minutes: 15
run: | run: |
npm run tauri build npm run tauri build
mkdir -p output/linux mkdir -p output/linux
mv src-tauri/target/release/bundle/deb/*.deb output/linux/${{inputs.title}}_`arch`.deb mv src-tauri/target/release/bundle/deb/*.deb output/linux/${{inputs.title}}_`arch`.deb
mv src-tauri/target/release/bundle/appimage/*.AppImage output/linux/"${{inputs.title}}"_`arch`.AppImage mv src-tauri/target/release/bundle/appimage/*.AppImage output/linux/"${{inputs.title}}"_`arch`.AppImage
- name: Build for macOS - name: Add Rust targets for macOS universal build
if: matrix.os == 'macos-latest' if: matrix.os == 'macos-latest'
run: | run: |
rustup target add aarch64-apple-darwin rustup target add aarch64-apple-darwin
rustup target add x86_64-apple-darwin rustup target add x86_64-apple-darwin
- name: Build for macOS
if: matrix.os == 'macos-latest'
timeout-minutes: 20
run: |
npm run tauri build -- --target universal-apple-darwin npm run tauri build -- --target universal-apple-darwin
mkdir -p output/macos mkdir -p output/macos
mv src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg output/macos/"${{inputs.title}}".dmg mv src-tauri/target/universal-apple-darwin/release/bundle/dmg/*.dmg output/macos/"${{inputs.title}}".dmg
- name: Build for Windows - name: Build for Windows
if: matrix.os == 'windows-latest' if: matrix.os == 'windows-latest'
timeout-minutes: 15
run: | run: |
npm run tauri build -- --target x86_64-pc-windows-msvc npm run tauri build -- --target x86_64-pc-windows-msvc
New-Item -Path "output\windows" -ItemType Directory New-Item -Path "output\windows" -ItemType Directory
@@ -144,7 +161,7 @@ jobs:
~/.cargo/registry/cache/ ~/.cargo/registry/cache/
~/.cargo/git/db/ ~/.cargo/git/db/
src-tauri/target/ src-tauri/target/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} key: ${{ runner.os }}-cargo-release-${{ hashFiles('**/Cargo.lock') }}
- name: Upload For Single Build - name: Upload For Single Build
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4

View File

@@ -71,7 +71,7 @@ jobs:
name_zh: ${{ matrix.name_zh }} name_zh: ${{ matrix.name_zh }}
url: ${{ matrix.url }} url: ${{ matrix.url }}
# Publish Docker image # Publish Docker image (runs in parallel with app builds)
publish-docker: publish-docker:
if: | if: |
(github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) || (github.event_name == 'push' && startsWith(github.ref, 'refs/tags/')) ||

View File

@@ -1,7 +1,7 @@
import fs from "fs"; import fs from "fs";
import path from "path"; import path from "path";
import axios from "axios";
import { execa } from "execa"; import { execa } from "execa";
// We'll call the CLI directly for icon handling
// Configuration logging // Configuration logging
const logConfiguration = () => { const logConfiguration = () => {
@@ -58,33 +58,7 @@ const buildParameters = () => {
return params; return params;
}; };
// Icon download handling // Icon will be handled directly by CLI
const downloadIcon = async (iconFile) => {
try {
const response = await axios.get(process.env.ICON, {
responseType: "arraybuffer",
});
fs.writeFileSync(iconFile, response.data);
return ["--icon", iconFile];
} catch (error) {
console.error("Error occurred during icon download:", error);
throw error;
}
};
// Get icon file name based on platform
const getIconFileName = () => {
switch (process.platform) {
case "linux":
return "icon.png";
case "darwin":
return "icon.icns";
case "win32":
return "icon.ico";
default:
throw new Error("Unable to detect your OS system");
}
};
// Main execution // Main execution
const main = async () => { const main = async () => {
@@ -97,24 +71,16 @@ const main = async () => {
let params = buildParameters(); let params = buildParameters();
// Multi-arch target is now handled in GitHub Actions workflow // Multi-arch target is now handled in GitHub Actions workflow
// Download icon in parallel with parameter preparation if needed // Add icon parameter if provided - CLI will handle download and conversion
let iconPromise = null;
if (process.env.ICON && process.env.ICON !== "") { if (process.env.ICON && process.env.ICON !== "") {
const iconFile = getIconFileName(); params.push("--icon", process.env.ICON);
iconPromise = downloadIcon(iconFile);
} else { } else {
console.log( console.log(
"Won't download the icon as ICON environment variable is not defined!", "Won't use 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("Pake parameters:", params.join(" "));
console.log("Compiling...."); console.log("Compiling....");
@@ -129,19 +95,25 @@ const main = async () => {
// Move built files to output directory more efficiently // Move built files to output directory more efficiently
const buildPaths = [ const buildPaths = [
`src-tauri/target/release/bundle`, `src-tauri/target/release/bundle`,
`src-tauri/target/universal-apple-darwin/release/bundle` `src-tauri/target/universal-apple-darwin/release/bundle`,
]; ];
for (const buildPath of buildPaths) { for (const buildPath of buildPaths) {
if (fs.existsSync(buildPath)) { if (fs.existsSync(buildPath)) {
const bundleFiles = fs.readdirSync(buildPath, { recursive: true }) const bundleFiles = fs
.filter(file => { .readdirSync(buildPath, { recursive: true })
.filter((file) => {
const fullPath = path.join(buildPath, file); const fullPath = path.join(buildPath, file);
return fs.statSync(fullPath).isFile() && return (
(file.endsWith('.dmg') || file.endsWith('.exe') || fs.statSync(fullPath).isFile() &&
file.endsWith('.deb') || file.endsWith('.rpm') || file.endsWith('.AppImage')); (file.endsWith(".dmg") ||
file.endsWith(".exe") ||
file.endsWith(".deb") ||
file.endsWith(".rpm") ||
file.endsWith(".AppImage"))
);
}); });
for (const file of bundleFiles) { for (const file of bundleFiles) {
const srcPath = path.join(buildPath, file); const srcPath = path.join(buildPath, file);
const destPath = path.join("output", path.basename(file)); const destPath = path.join("output", path.basename(file));
@@ -150,7 +122,7 @@ const main = async () => {
break; // Found files, no need to check other paths break; // Found files, no need to check other paths
} }
} }
// Fallback to original method if no bundle files found // Fallback to original method if no bundle files found
const files = fs.readdirSync("."); const files = fs.readdirSync(".");
const namePattern = new RegExp(`^${process.env.NAME}\\..*$`); const namePattern = new RegExp(`^${process.env.NAME}\\..*$`);
@@ -161,7 +133,7 @@ const main = async () => {
foundFiles = true; foundFiles = true;
} }
} }
if (!foundFiles) { if (!foundFiles) {
console.log("Warning: No output files found matching pattern"); console.log("Warning: No output files found matching pattern");
} }