From 152f49c16145c39dfa745ecce33e583cbcac7c5a Mon Sep 17 00:00:00 2001 From: Connection Refused Date: Thu, 7 May 2020 21:00:34 +0800 Subject: [PATCH] Update build scripts --- .github/workflows/build.yml | 55 ++++++++++++++++++------------------- build.ps1 | 26 +++++++----------- 2 files changed, 36 insertions(+), 45 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index c31bffe9..4aefec44 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,44 +1,44 @@ -name: GitHub Actions & Netch CI - +name: Netch CI on: [push] - jobs: build: name: Build runs-on: windows-latest - - steps: - - uses: actions/checkout@v2 - - - name: Get tag name - uses: olegtarasov/get-tag@v1 + steps: + - name: NuGet + uses: nuget/setup-nuget@v1 - - name: submodules-init - uses: snickerbockers/submodules-init@v4 - - - uses: nuget/setup-nuget@v1 - - run: nuget restore Netch.sln - - - name: Setup MSBuild.exe + - name: MSBuild uses: microsoft/setup-msbuild@v1.0.0 - - name: Build .NET 4.8 Netch + - name: Checkout + uses: actions/checkout@v2 + + - name: Update submodules + uses: snickerbockers/submodules-init@v4 + + - name: Restore NuGet Package + run: nuget restore Netch.sln + + - name: Build .NET 4.8 shell: pwsh run: | - .\build.ps1 + .\BUILD.ps1 New-Item -ItemType Directory -Path C:\builtfiles -Force > $null Compress-Archive -Path Netch\bin\x64\Release\win-x64\* -DestinationPath C:\builtfiles\Netch-${{ env.GITHUB_TAG_NAME }}.zip - echo "::set-env name=Netch_SHA256::$(.\getSHA256.ps1 C:\builtfiles\Netch-${{ env.GITHUB_TAG_NAME }}.zip)" + echo "::set-env name=Netch_SHA256::$(.\GetSHA256.ps1 C:\builtfiles\Netch-${{ env.GITHUB_TAG_NAME }}.zip)" - - name: Upload Netch + - name: Upload uses: actions/upload-artifact@v1 with: name: Netch path: Netch\bin\x64\Release\win-x64 - - # Create a new release: create a tag, then 'git push origin ', wait for it to build - - name: Create a new GitHub release if a new tag is pushed + + - name: Release uses: softprops/action-gh-release@v1 + env: + GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + if: startsWith(github.ref, 'refs/tags/') with: name: ${{ env.GITHUB_TAG_NAME }} prerelease: true @@ -50,12 +50,9 @@ jobs: [![](https://img.shields.io/badge/Telegram-Channel-blue)](https://t.me/Netch) [![](https://img.shields.io/badge/Telegram-Group-green)](https://t.me/Netch_Discuss_Group) ## 更新日志: - * 这是 GitHub Action 自动化部署,更新日志应该很快会手动更新:D + * 这是 GitHub Action 自动化部署,更新日志应该很快会手动更新 - ## 文件校验 + ## 校验和 | 文件名 | SHA256 | | :- | :- | - | Netch-${{ env.GITHUB_TAG_NAME }}.zip | ${{ env.Netch_SHA256 }} | - if: startsWith(github.ref, 'refs/tags/') - env: - GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} + | Netch-${{ env.GITHUB_TAG_NAME }}.zip | ${{ env.Netch_SHA256 }} | diff --git a/build.ps1 b/build.ps1 index 48735de3..fa09c6dc 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,4 +1,3 @@ -# REM The reason we don't use dotnet build is that dotnet build doesn't support COM references yet https://github.com/microsoft/msbuild/issues/3986 param([string]$buildtfm = 'all') Write-Host 'dotnet SDK version' @@ -14,28 +13,23 @@ Write-Host $net_baseoutput function Build-NetFrameworkx64 { Write-Host 'Building .NET Framework x64' - + $outdir = "$net_baseoutput\x64" - + msbuild -v:m -m -t:Build /p:Configuration="Release" /p:Platform="x64" /p:TargetFramework=net48 /p:Runtimeidentifier=win-x64 /restore if ($LASTEXITCODE) { cd $mainDir ; exit $LASTEXITCODE } - Write-Host 'Build x64 Complete ,Started Copy bin,mode,i18n file' - -Copy-Item "$mainDir\translations\i18n\*" "$net_baseoutput\x64\Release\win-x64\i18n" -recurse - -Copy-Item "$mainDir\modes\mode\*" "$net_baseoutput\x64\Release\win-x64\mode" -recurse - -Remove-Item -path "$net_baseoutput\x64\Release\win-x64\bin\tap-driver" - -Copy-Item "$mainDir\binaries\*" -destination "$net_baseoutput\x64\Release\win-x64\bin" -recurse - - Write-Host 'Netch Build ALL DONE' + Write-Host 'Build x64 Completed, start copy bin, mode, i18n file' + Copy-Item -Recurse "$mainDir\binaries\*" -destination "$net_baseoutput\x64\Release\win-x64\bin" + Copy-Item -Recurse "$mainDir\modes\mode\*" "$net_baseoutput\x64\Release\win-x64\mode" + Copy-Item -Recurse "$mainDir\translations\i18n\*" "$net_baseoutput\x64\Release\win-x64\i18n" + Remove-Item -Path "$net_baseoutput\x64\Release\win-x64\bin\tap-driver" + Write-Host 'Build done' } cd $mainDir\Netch - Build-NetFrameworkx64 - cd $mainDir + +exit 0