fix: 修复安装脚本在低版本PowerShell编码错误 #20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: .NET | |
| on: | |
| push: | |
| branches: [ "master"] | |
| pull_request: | |
| branches: [ "master" ] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: 9.x | |
| - name: Build | |
| shell: bash | |
| run: | | |
| dotnet build OTAPIXmlDocument.sln -c Release | |
| ota_content=$(cat OTAPI/OTAPI.xml) | |
| powershell_script=$(cat <<EOL | |
| [Console]::OutputEncoding = [System.Text.Encoding]::UTF8 | |
| \$OutputEncoding = [System.Text.Encoding]::UTF8 | |
| \$OTA = @" | |
| $ota_content | |
| "@ | |
| \$dllFiles = Get-ChildItem -Path "\$env:USERPROFILE/.nuget/packages/otapi.upcoming" -Recurse -Filter "OTAPI.dll" | |
| if (\$dllFiles.Count -eq 0) { | |
| Write-Host "未找到任何 OTAPI.dll 文件。" | |
| } else { | |
| foreach (\$dllFile in \$dllFiles) { | |
| \$targetDir = \$dllFile.DirectoryName | |
| \$xmlPath = Join-Path -Path \$targetDir -ChildPath "OTAPI.xml" | |
| New-Item -Path \$xmlPath -ItemType "file" -Force | Out-Null | |
| Set-Content -Path \$xmlPath -Value $OTA -Encoding UTF8 | |
| Write-Host "已创建 OTAPI.xml 在: \$xmlPath" | |
| } | |
| } | |
| Pause | |
| EOL | |
| ) | |
| echo "$powershell_script" > install.ps1 | |
| echo "PowerShell安装脚本已生成: install.ps1" | |
| - name: Set Release Tag | |
| id: set_tag | |
| run: echo "::set-output name=tag::v$(date +'%Y.%m.%d')" | |
| - name: Update Tag | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
| run: | | |
| git tag -f ${{ steps.set_tag.outputs.tag }} | |
| git push -f origin ${{ steps.set_tag.outputs.tag }} | |
| - name: Release | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/master' | |
| uses: ncipollo/release-action@v1 | |
| with: | |
| tag: ${{ steps.set_tag.outputs.tag }} | |
| name: OTAPIXmlDocument ${{ steps.set_tag.outputs.tag }} | |
| body: | | |
| # OTAPIXmlDocument Ciallo~(∠・ω< )⌒☆ | |
| ### 📅 使用Powershell打开脚本即可安装 | |
| ### 📖 默认路径为最新的OTAPI Nuget所在路径 | |
| ### 📦 Auto Build By Github Action | |
| artifacts: | | |
| ./OTAPI/OTAPI.xml | |
| ./install.ps1 | |
| allowUpdates: true | |
| removeArtifacts: true |