build: enable GitCode fallback for local builds
This commit is contained in:
1 parent
5ad07df8ee
commit
7c2dab9fc2
2 files changed
+18
-2
No files matched your search
@@ -1,6 +1,8 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[int]$BuildJobs
|
||||
[int]$BuildJobs,
|
||||
|
||||
[string]$GitCodeRepository = 'lzt404/EasyCLIProxyAPI'
|
||||
)
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
@@ -25,12 +27,16 @@ if (-not $PSBoundParameters.ContainsKey('BuildJobs')) {
|
||||
if ($BuildJobs -lt 1 -or $BuildJobs -gt 256) {
|
||||
throw 'BuildJobs must be between 1 and 256.'
|
||||
}
|
||||
if ($GitCodeRepository -notmatch '^[A-Za-z0-9_.-]+/[A-Za-z0-9_.-]+$') {
|
||||
throw 'GitCodeRepository must use the owner/repository format.'
|
||||
}
|
||||
|
||||
if (-not (Get-Command bun -ErrorAction SilentlyContinue)) {
|
||||
throw 'bun is not installed or not in PATH.'
|
||||
}
|
||||
|
||||
Write-Host "Cargo build jobs: $BuildJobs"
|
||||
Write-Host "GitCode fallback repository: $GitCodeRepository"
|
||||
|
||||
& bun install
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
@@ -38,8 +44,10 @@ if ($LASTEXITCODE -ne 0) {
|
||||
}
|
||||
|
||||
$PreviousBuildJobs = $env:CARGO_BUILD_JOBS
|
||||
$PreviousGitCodeRepository = $env:GITCODE_REPOSITORY
|
||||
try {
|
||||
$env:CARGO_BUILD_JOBS = [string]$BuildJobs
|
||||
$env:GITCODE_REPOSITORY = $GitCodeRepository
|
||||
& bun tauri build --no-bundle
|
||||
if ($LASTEXITCODE -ne 0) {
|
||||
throw "Tauri build failed with exit code $LASTEXITCODE."
|
||||
@@ -52,6 +60,12 @@ finally {
|
||||
else {
|
||||
$env:CARGO_BUILD_JOBS = $PreviousBuildJobs
|
||||
}
|
||||
if ($null -eq $PreviousGitCodeRepository) {
|
||||
Remove-Item Env:GITCODE_REPOSITORY -ErrorAction SilentlyContinue
|
||||
}
|
||||
else {
|
||||
$env:GITCODE_REPOSITORY = $PreviousGitCodeRepository
|
||||
}
|
||||
}
|
||||
|
||||
if (-not (Test-Path -LiteralPath $AppBin -PathType Leaf)) {
|
||||
|
||||
@@ -5,6 +5,7 @@ ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
BUILD_JOBS="${CARGO_BUILD_JOBS:-20}"
|
||||
GITCODE_REPOSITORY="${GITCODE_REPOSITORY:-lzt404/EasyCLIProxyAPI}"
|
||||
APP_BIN="$ROOT_DIR/src-tauri/target/release/cpa-gui"
|
||||
BIN_DIR="$ROOT_DIR/bin-work"
|
||||
BIN_OUT="$BIN_DIR/EasyCLIProxyAPI"
|
||||
@@ -15,8 +16,9 @@ if ! command -v bun >/dev/null 2>&1; then
|
||||
fi
|
||||
|
||||
echo "Cargo build jobs: $BUILD_JOBS"
|
||||
echo "GitCode fallback repository: $GITCODE_REPOSITORY"
|
||||
bun install
|
||||
CARGO_BUILD_JOBS="$BUILD_JOBS" bun tauri build --no-bundle
|
||||
CARGO_BUILD_JOBS="$BUILD_JOBS" GITCODE_REPOSITORY="$GITCODE_REPOSITORY" bun tauri build --no-bundle
|
||||
|
||||
if [ ! -x "$APP_BIN" ]; then
|
||||
echo "Build finished, but executable not found: $APP_BIN"
|
||||
|
||||
Reference in new issue
Block a user