🐛 GitHub action cli packaging issue fixed

This commit is contained in:
Tw93
2025-08-21 15:28:40 +08:00
parent 23c817606d
commit b51fa5e2b7
5 changed files with 71 additions and 19 deletions

View File

@@ -113,18 +113,11 @@ jobs:
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') }}-${{ inputs.multi_arch }}
- name: Install pake-cli
shell: bash
run: |
echo "Installing pake-cli..."
npm install pake-cli --no-package-lock
echo "Installing latest pake-cli..."
npm install pake-cli@latest --no-package-lock
# Verify installation
if [ ! -d "node_modules/pake-cli" ]; then

View File

@@ -169,18 +169,25 @@ export default abstract class BaseBuilder {
fullCommand += ' --bundles app';
}
// Add features
const features = ['cli-build'];
// Add macos-proxy feature for modern macOS (Darwin 23+ = macOS 14+)
if (IS_MAC) {
const macOSVersion = this.getMacOSMajorVersion();
if (macOSVersion >= 23) {
fullCommand += ' --features macos-proxy';
features.push('macos-proxy');
}
}
if (features.length > 0) {
fullCommand += ` --features ${features.join(',')}`;
}
return fullCommand;
}
private getMacOSMajorVersion(): number {
protected getMacOSMajorVersion(): number {
try {
const os = require('os');
const release = os.release();

View File

@@ -1,3 +1,4 @@
import path from 'path';
import tauriConfig from '@/helpers/tauriConfig';
import { PakeAppOptions } from '@/types';
import BaseBuilder from './BaseBuilder';
@@ -33,9 +34,35 @@ export default class MacBuilder extends BaseBuilder {
}
protected getBuildCommand(): string {
return this.options.multiArch
? 'npm run build:mac'
: super.getBuildCommand();
if (this.options.multiArch) {
const baseCommand = this.options.debug
? 'npm run tauri build -- --debug'
: 'npm run tauri build --';
// Use temporary config directory to avoid modifying source files
const configPath = path.join(
'src-tauri',
'.pake',
'tauri.conf.json',
);
let fullCommand = `${baseCommand} --target universal-apple-darwin -c "${configPath}"`;
// Add features
const features = ['cli-build'];
// Add macos-proxy feature for modern macOS (Darwin 23+ = macOS 14+)
const macOSVersion = this.getMacOSMajorVersion();
if (macOSVersion >= 23) {
features.push('macos-proxy');
}
if (features.length > 0) {
fullCommand += ` --features ${features.join(',')}`;
}
return fullCommand;
}
return super.getBuildCommand();
}
protected getBasePath(): string {

View File

@@ -1,8 +1,14 @@
import pakeConf from '../../src-tauri/pake.json';
import CommonConf from '../../src-tauri/tauri.conf.json';
import WinConf from '../../src-tauri/tauri.windows.conf.json';
import MacConf from '../../src-tauri/tauri.macos.conf.json';
import LinuxConf from '../../src-tauri/tauri.linux.conf.json';
import path from 'path';
import fsExtra from 'fs-extra';
import { npmDirectory } from '@/utils/dir';
// Load configs from npm package directory, not from project source
const tauriSrcDir = path.join(npmDirectory, 'src-tauri');
const pakeConf = fsExtra.readJSONSync(path.join(tauriSrcDir, 'pake.json'));
const CommonConf = fsExtra.readJSONSync(path.join(tauriSrcDir, 'tauri.conf.json'));
const WinConf = fsExtra.readJSONSync(path.join(tauriSrcDir, 'tauri.windows.conf.json'));
const MacConf = fsExtra.readJSONSync(path.join(tauriSrcDir, 'tauri.macos.conf.json'));
const LinuxConf = fsExtra.readJSONSync(path.join(tauriSrcDir, 'tauri.linux.conf.json'));
const platformConfigs = {
win32: WinConf,

View File

@@ -47,6 +47,25 @@ const main = async () => {
console.log("Cleaned previous .pake directory for fresh build");
}
// Also clean any potential target directories that might contain cached configs
const targetDirs = [
"src-tauri/target",
"src-tauri/target/debug",
"src-tauri/target/release",
"src-tauri/target/universal-apple-darwin"
];
targetDirs.forEach(dir => {
if (fs.existsSync(dir)) {
// Only remove .pake subdirectories, not the entire target directory
const targetPakeDir = path.join(dir, ".pake");
if (fs.existsSync(targetPakeDir)) {
fs.rmSync(targetPakeDir, { recursive: true, force: true });
console.log(`Cleaned .pake directory in ${dir}`);
}
}
});
// Build CLI parameters
let params = [
"dist/cli.js",