From 772604d2814b615cd330968ee379f6903d36abee Mon Sep 17 00:00:00 2001 From: Tlntin Date: Wed, 8 Mar 2023 15:47:02 +0800 Subject: [PATCH] update powershell file for windows --- .github/workflows/pake_build.yaml | 3 +- .github/workflows/pake_build_with_cache.yaml | 3 +- script/build.ps1 | 69 ++++++++++---------- src-tauri/tauri.windows.conf.json | 3 - 4 files changed, 38 insertions(+), 40 deletions(-) diff --git a/.github/workflows/pake_build.yaml b/.github/workflows/pake_build.yaml index 2b2f8ae..1cc7903 100644 --- a/.github/workflows/pake_build.yaml +++ b/.github/workflows/pake_build.yaml @@ -79,8 +79,7 @@ jobs: if: matrix.os == 'windows-latest' shell: pwsh run: | - $PSVersionTable - .\script\build.ps1 + build:all-windows - name: Upload files env: diff --git a/.github/workflows/pake_build_with_cache.yaml b/.github/workflows/pake_build_with_cache.yaml index 84932c6..4adb497 100644 --- a/.github/workflows/pake_build_with_cache.yaml +++ b/.github/workflows/pake_build_with_cache.yaml @@ -76,8 +76,7 @@ jobs: if: matrix.os == 'windows-latest' shell: pwsh run: | - $PSVersionTable - .\script\build.ps1 + build:all-windows - name: Upload files env: diff --git a/script/build.ps1 b/script/build.ps1 index 9e0bfb6..e71ae83 100644 --- a/script/build.ps1 +++ b/script/build.ps1 @@ -17,8 +17,13 @@ if (-not (Test-Path output\windows)) { Write-Host "`n=======================" Write-Host "build for windows" +Write-Host "make ture powershell == 7.2.10" +Write-Host "powershell 7.2.10 download url: https://github.com/PowerShell/PowerShell/releases/tag/v7.2.10" +Write-Host "Powershell info in your localhost " +$PSVersionTable Write-Host "=======================`n" + $identifier_prefix = "com.tw93" # total package number @@ -44,36 +49,34 @@ ForEach ($line in (Get-Content -Path .\app.csv | Select-Object -Skip 1)) { Write-Host "==========================" # -- replace url -- # clear url with regex - .\script\sd.exe "`"url`":\s`"(.*?)`"" '"url": ""' $common_conf_path + (Get-Content -Path $common_conf_path -Raw) -replace '"url":\s*"[^"]*"', '"url": ""' | Set-Content -Path $common_conf_path # replace url with no regex - .\script\sd.exe -s '"url": ""' "`"url`": `"${url}`"" $common_conf_path + (Get-Content -Path $common_conf_path -Raw) | ForEach-Object { $_.Replace('"url": ""', "`"url`": `"${url}`"") } | Set-Content $common_conf_path + # replace package name # clear package_name with regex - .\script\sd.exe "`"productName`":\s`"(.*?)`"" '"productName": ""' $common_conf_path + (Get-Content -Path $common_conf_path -Raw) -replace '"productName":\s*"[^"]*"', '"productName": ""' | Set-Content -Path $common_conf_path # replace package_name with no regex - .\script\sd.exe -s '"productName": ""' "`"productName`": `"$title`"" $common_conf_path + (Get-Content -Path $common_conf_path -Raw) | ForEach-Object { $_.Replace('"productName": ""', "`"productName`": `"${title}`"") } | Set-Content $common_conf_path # -- replace icon -- # clear icon path with regex - # (Get-Content -Path $windows_conf_path -Raw) -replace '(?s)"icon":\s*\[[^\]]*\]', '"icon": []' | Set-Content -Path $windows_conf_path - .\script\sd.exe "`"icon`":\s(.*)`]" '"icon": []' $windows_conf_path + (Get-Content -Path $windows_conf_path -Raw) -replace '(?s)"icon":\s*\[[^\]]*\]', '"icon": []' | Set-Content -Path $windows_conf_path # replace icon path with no regex - .\script\sd.exe -s '"icon": []' "`"icon`": [`"png/${name}_256.ico`", `"png/${name}_32.ico`"]" $windows_conf_path + (Get-Content -Path $windows_conf_path -Raw) | ForEach-Object { $_.Replace('"icon": []', "`"icon`": [`"png/${name}_256.ico`", `"png/${name}_32.ico`"]") } | Set-Content $windows_conf_path # -- replace identifier -- # clear identifier with regex - # (Get-Content -Path $windows_conf_path -Raw) -replace '"identifier":\s*"[^"]*"', '"identifier": ""' | Set-Content -Path $windows_conf_path - .\script\sd.exe "`"identifier`":\s`"(.*?)`"" '"identifier": ""' $windows_conf_path + (Get-Content -Path $windows_conf_path -Raw) -replace '"identifier":\s*"[^"]*"', '"identifier": ""' | Set-Content -Path $windows_conf_path # -- replace identifier with no regex -- - .\script\sd.exe -s '"identifier": ""' "`"identifier`": `"${identifier_prefix}.${name}`"" $windows_conf_path + (Get-Content -Path $windows_conf_path -Raw) | ForEach-Object { $_.Replace('"identifier": ""', "`"identifier`": `"${identifier_prefix}.${name}`"") } | Set-Content $windows_conf_path # -- replace icon resources -- # clear resources with regex - #(Get-Content -Path $windows_conf_path -Raw) -replace '(?s)"resources":\s*\[[^\]]*\]', '"resources": []' | Set-Content -Path $windows_conf_path - .\script\sd.exe "`"resources`":\s(.*)`]" '"resources": []' $windows_conf_path + (Get-Content -Path $windows_conf_path -Raw) -replace '(?s)"resources":\s*\[[^\]]*\]', '"resources": []' | Set-Content -Path $windows_conf_path # replace resources with no regex - .\script\sd.exe -s '"resources": []' "`"resources`": [`"png/${name}_32.ico`"]" $windows_conf_path + (Get-Content -Path $windows_conf_path -Raw) | ForEach-Object { $_.Replace('"resources": []', "`"resources`": [`"png/${name}_32.ico`"]") } | Set-Content $windows_conf_path if (-not (Test-Path "src-tauri\png\${name}_32.ico")) { Copy-Item "src-tauri\png\icon_32.ico" "src-tauri\png\${name}_32.ico" @@ -97,27 +100,27 @@ ForEach ($line in (Get-Content -Path .\app.csv | Select-Object -Skip 1)) { Write-Host "package build success!" Write-Host "" $index++ - # # strip blank line for common_conf_path - # $lines = Get-Content ${common_conf_path} - # $lastNonEmptyLineIndex = ($lines.Count - 1) - # while ($lastNonEmptyLineIndex -ge 0 -and -not $lines[$lastNonEmptyLineIndex].Trim()) { - # $lastNonEmptyLineIndex-- - # } - # if ($lastNonEmptyLineIndex -lt ($lines.Count - 1)) { - # $lines = $lines[0..$lastNonEmptyLineIndex] - # } - # Set-Content -Path ${common_conf_path} -Value $lines + # strip blank line for common_conf_path + $lines = Get-Content ${common_conf_path} + $lastNonEmptyLineIndex = ($lines.Count - 1) + while ($lastNonEmptyLineIndex -ge 0 -and -not $lines[$lastNonEmptyLineIndex].Trim()) { + $lastNonEmptyLineIndex-- + } + if ($lastNonEmptyLineIndex -lt ($lines.Count - 1)) { + $lines = $lines[0..$lastNonEmptyLineIndex] + } + Set-Content -Path ${common_conf_path} -Value $lines - # # strip blank line for windows conf_path - # $lines = Get-Content ${windows_conf_path} - # $lastNonEmptyLineIndex = ($lines.Count - 1) - # while ($lastNonEmptyLineIndex -ge 0 -and -not $lines[$lastNonEmptyLineIndex].Trim()) { - # $lastNonEmptyLineIndex-- - # } - # if ($lastNonEmptyLineIndex -lt ($lines.Count - 1)) { - # $lines = $lines[0..$lastNonEmptyLineIndex] - # } - # Set-Content -Path ${windows_conf_path} -Value $lines + # strip blank line for windows conf_path + $lines = Get-Content ${windows_conf_path} + $lastNonEmptyLineIndex = ($lines.Count - 1) + while ($lastNonEmptyLineIndex -ge 0 -and -not $lines[$lastNonEmptyLineIndex].Trim()) { + $lastNonEmptyLineIndex-- + } + if ($lastNonEmptyLineIndex -lt ($lines.Count - 1)) { + $lines = $lines[0..$lastNonEmptyLineIndex] + } + Set-Content -Path ${windows_conf_path} -Value $lines } Write-Host "output dir is output\windows" diff --git a/src-tauri/tauri.windows.conf.json b/src-tauri/tauri.windows.conf.json index c95e88d..b46b429 100644 --- a/src-tauri/tauri.windows.conf.json +++ b/src-tauri/tauri.windows.conf.json @@ -23,6 +23,3 @@ } } } - - -