Skip to content

Commit

Permalink
重写 构建脚本为PS1
Browse files Browse the repository at this point in the history
  • Loading branch information
xrgzs committed Sep 25, 2024
1 parent 850bc23 commit 561562f
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 55 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,11 @@ jobs:
# nsis-version: 3.09

- name: Build XROSC
shell: cmd
shell: pwsh
env:
GITHUB_WORKFLOW_VERSION: ${{ steps.generate_version.outputs.version }}
run: |
cmd /c build.bat
. .\build.ps1
# - name: Disconnect Cloudflare WRAP
# shell: pwsh
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ jobs:
# nsis-version: 3.09

- name: Build XROSC
shell: cmd
shell: pwsh
env:
GITHUB_WORKFLOW_VERSION: ${{ steps.generate_version.outputs.version }}
run: |
cmd /c build.bat
. .\build.ps1
# - name: Disconnect Cloudflare WRAP
# shell: pwsh
Expand Down
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"recommendations": [
"editorconfig.editorconfig"
"editorconfig.editorconfig",
"ms-vscode.powershell"
]
}
50 changes: 0 additions & 50 deletions build.bat

This file was deleted.

59 changes: 59 additions & 0 deletions build.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
$ErrorActionPreference = 'Stop'

# 切换到当前目录
Set-Location $PSScriptRoot

# 下载文件
function Get-LanzouFile {
param(
[Parameter(Mandatory = $true,Position=0)]
[string]
$Uri,

[Parameter(Mandatory = $true,Position=1)]
[string]
$OutFile
)

try {
Invoke-WebRequest -Uri "https://api.xrgzs.top/lanzou/?type=down&url=$Uri" -OutFile $OutFile -ErrorAction Stop -ConnectionTimeoutSeconds 3
}
catch {
try {
Invoke-WebRequest -Uri "https://api.hanximeng.com/lanzou/?type=down&url=$Uri" -OutFile $OutFile -ErrorAction Stop -ConnectionTimeoutSeconds 3
}
catch {
Invoke-WebRequest -Uri "https://lz.qaiu.top/parser?url=$Uri" -OutFile $OutFile -ErrorAction Stop -ConnectionTimeoutSeconds 3
}
}
}

# 检查
Write-Host "version: $env:GITHUB_WORKFLOW_VERSION"
if (-not (Test-Path "C:\Program Files (x86)\NSIS\makensis.exe")) {
Write-Host "Cannot find nsis!"
exit 1
}
if (Test-Path 'osc\xrsoft.exe') {
Write-Host "xrsoft.exe already exists."
}
else {
# 下载所需文件
Get-LanzouFile -Uri "https://xrgzs.lanzouv.com/irdVI27gi2pg" -OutFile "osc\runtime\DirectX_Redist_Repack_x86_x64_Final.exe"
Get-LanzouFile -Uri "https://xrgzs.lanzouv.com/ihcxj29z4hbe" -OutFile "osc\runtime\flash.exe"
Get-LanzouFile -Uri "https://xrgzs.lanzouv.com/iWN6I27gi6ch" -OutFile "osc\runtime\MSVCRedist.AIO.exe"
Get-LanzouFile -Uri "https://xrgzs.lanzouv.com/iEOKz27gibqb" -OutFile "osc\xrkms\KMS_VL_ALL_AIO.cmd"
Get-LanzouFile -Uri "https://xrgzs.lanzouv.com/i8NFT2a8fagh" -OutFile "osc\xrkms\kms.exe"
Get-LanzouFile -Uri "https://xrgzs.lanzouv.com/ixdbP27giisf" -OutFile "osc\xrsoft.exe"

# 下载其他文件
Invoke-WebRequest -Uri "http://url.xrgzs.top/osconline" -OutFile "osc\oscoffline.bat" -ErrorAction Stop -ConnectionTimeoutSeconds 3
Invoke-WebRequest -Uri "http://url.xrgzs.top/oscsoft" -OutFile "osc\oscsoftof.txt" -ErrorAction Stop -ConnectionTimeoutSeconds 3
}

# 构建
if (-not $env:GITHUB_WORKFLOW_VERSION) {
$env:GITHUB_WORKFLOW_VERSION = "2.5.0.0"
}
Set-Content -Path "osc\apifiles\Version.txt" -Value $env:GITHUB_WORKFLOW_VERSION
& "C:\Program Files (x86)\NSIS\makensis.exe" /V4 /DCUSTOM_VERSION=$env:GITHUB_WORKFLOW_VERSION "osc.nsi" || exit 1

0 comments on commit 561562f

Please sign in to comment.