windows-mingw-publish.ps1 1.0 KB

12345678910111213141516171819202122232425262728293031323334
  1. [CmdletBinding()]
  2. param (
  3. [string] $archiveName, [string] $targetName
  4. )
  5. # 外部环境变量包括:
  6. # archiveName: ${{ matrix.qt_ver }}-${{ matrix.qt_arch }}
  7. # archiveName: 5.15.2-win64_mingw81
  8. $scriptDir = $PSScriptRoot
  9. $currentDir = Get-Location
  10. Write-Host "currentDir" $currentDir
  11. Write-Host "scriptDir" $scriptDir
  12. function Main() {
  13. New-Item -ItemType Directory $archiveName
  14. # 拷贝exe
  15. Copy-Item bin\release\* $archiveName\ -Force -Recurse | Out-Null
  16. # 拷贝依赖
  17. windeployqt --qmldir . --plugindir $archiveName\plugins --no-translations --compiler-runtime $archiveName\$targetName
  18. # 删除不必要的文件
  19. $excludeList = @("*.qmlc", "*.ilk", "*.exp", "*.lib", "*.pdb")
  20. Remove-Item -Path $archiveName -Include $excludeList -Recurse -Force
  21. # 打包zip
  22. Compress-Archive -Path $archiveName $archiveName'.zip'
  23. }
  24. if ($null -eq $archiveName || $null -eq $targetName) {
  25. Write-Host "args missing, archiveName is" $archiveName ", targetName is" $targetName
  26. return
  27. }
  28. Main