From a6e6b50a6ae8e329fd2d9942adf9adead8960da7 Mon Sep 17 00:00:00 2001 From: Connection Refused Date: Sat, 16 Oct 2021 11:47:24 +0800 Subject: [PATCH] [GitHub CI] Update build.yml --- .github/workflows/build.yml | 22 +++++++--------------- .github/workflows/release.yml | 22 +++++++--------------- Other/sha256.ps1 | 17 ----------------- sha256.ps1 | 21 +++++++++------------ 4 files changed, 23 insertions(+), 59 deletions(-) delete mode 100644 Other/sha256.ps1 diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ed368439..0a6cdbf7 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -11,39 +11,31 @@ jobs: with: fetch-depth: 1 - - name: Checksum Other + - name: Checksum shell: pwsh run: | - echo "OTHER_SHA256=$(.\Other\sha256.ps1)" | Out-File -Append -Encoding UTF8 -FilePath $Env:GITHUB_ENV - - - name: Checksum Redirector - shell: pwsh - run: | - echo "REDIRECTOR_SHA256=$(.\sha256.ps1 .\Redirector)" | Out-File -Append -Encoding UTF8 -FilePath $Env:GITHUB_ENV - - - name: Checksum RouteHelper - shell: pwsh - run: | - echo "ROUTEHELPER_SHA256=$(.\sha256.ps1 .\RouteHelper)" | Out-File -Append -Encoding UTF8 -FilePath $Env:GITHUB_ENV + echo "SOURCE_OTHER_SHA256=$(.\sha256.ps1 .\Other)" | Out-File -Append -Encoding UTF8 -FilePath $Env:GITHUB_ENV + echo "SOURCE_REDIRECTOR_SHA256=$(.\sha256.ps1 .\Redirector)" | Out-File -Append -Encoding UTF8 -FilePath $Env:GITHUB_ENV + echo "SOURCE_ROUTEHELPER_SHA256=$(.\sha256.ps1 .\RouteHelper)" | Out-File -Append -Encoding UTF8 -FilePath $Env:GITHUB_ENV - name: Cache Other uses: actions/cache@v2 with: - key: Netch-${{ runner.os }}-Other-${{ env.OTHER_SHA256 }} + key: Netch-${{ runner.os }}-Other-${{ env.SOURCE_OTHER_SHA256 }} path: | .\Other\release - name: Cache Redirector uses: actions/cache@v2 with: - key: Netch-${{ runner.os }}-Redirector-${{ env.REDIRECTOR_SHA256 }} + key: Netch-${{ runner.os }}-Redirector-${{ env.SOURCE_REDIRECTOR_SHA256 }} path: | .\Redirector\bin - name: Cache RouteHelper uses: actions/cache@v2 with: - key: Netch-${{ runner.os }}-RouteHelper-${{ env.ROUTEHELPER_SHA256 }} + key: Netch-${{ runner.os }}-RouteHelper-${{ env.SOURCE_ROUTEHELPER_SHA256 }} path: | .\RouteHelper\bin diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 72580d9a..6bebd1fd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -14,39 +14,31 @@ jobs: with: fetch-depth: 1 - - name: Checksum Other + - name: Checksum shell: pwsh run: | - echo "OTHER_SHA256=$(.\Other\sha256.ps1)" | Out-File -Append -Encoding UTF8 -FilePath $Env:GITHUB_ENV - - - name: Checksum Redirector - shell: pwsh - run: | - echo "REDIRECTOR_SHA256=$(.\sha256.ps1 .\Redirector)" | Out-File -Append -Encoding UTF8 -FilePath $Env:GITHUB_ENV - - - name: Checksum RouteHelper - shell: pwsh - run: | - echo "ROUTEHELPER_SHA256=$(.\sha256.ps1 .\RouteHelper)" | Out-File -Append -Encoding UTF8 -FilePath $Env:GITHUB_ENV + echo "SOURCE_OTHER_SHA256=$(.\sha256.ps1 .\Other)" | Out-File -Append -Encoding UTF8 -FilePath $Env:GITHUB_ENV + echo "SOURCE_REDIRECTOR_SHA256=$(.\sha256.ps1 .\Redirector)" | Out-File -Append -Encoding UTF8 -FilePath $Env:GITHUB_ENV + echo "SOURCE_ROUTEHELPER_SHA256=$(.\sha256.ps1 .\RouteHelper)" | Out-File -Append -Encoding UTF8 -FilePath $Env:GITHUB_ENV - name: Cache Other uses: actions/cache@v2 with: - key: Netch-${{ runner.os }}-Other-${{ env.OTHER_SHA256 }} + key: Netch-${{ runner.os }}-Other-${{ env.SOURCE_OTHER_SHA256 }} path: | .\Other\release - name: Cache Redirector uses: actions/cache@v2 with: - key: Netch-${{ runner.os }}-Redirector-${{ env.REDIRECTOR_SHA256 }} + key: Netch-${{ runner.os }}-Redirector-${{ env.SOURCE_REDIRECTOR_SHA256 }} path: | .\Redirector\bin - name: Cache RouteHelper uses: actions/cache@v2 with: - key: Netch-${{ runner.os }}-RouteHelper-${{ env.ROUTEHELPER_SHA256 }} + key: Netch-${{ runner.os }}-RouteHelper-${{ env.SOURCE_ROUTEHELPER_SHA256 }} path: | .\RouteHelper\bin diff --git a/Other/sha256.ps1 b/Other/sha256.ps1 deleted file mode 100644 index 313cffc6..00000000 --- a/Other/sha256.ps1 +++ /dev/null @@ -1,17 +0,0 @@ -Push-Location (Split-Path $MyInvocation.MyCommand.Path -Parent) - -$ms = [System.IO.MemoryStream]::new(); -$wr = [System.IO.StreamWriter]::new($ms); -Get-ChildItem -Path '.' -Directory | ForEach-Object { - $dirName=$_.Name - - Get-ChildItem -Path ".\$dirName" -File | ForEach-Object { - $fileName=$_.Name - - $wr.Write((Get-FileHash -Path ".\$dirName\$fileName" -Algorithm SHA256).Hash.ToLower()) - } -} -$ms.Position = 0 - -Write-Output (Get-FileHash -InputStream $ms).Hash.ToLower() -Pop-Location \ No newline at end of file diff --git a/sha256.ps1 b/sha256.ps1 index c962fe64..7cbc0208 100644 --- a/sha256.ps1 +++ b/sha256.ps1 @@ -5,31 +5,28 @@ param ( Push-Location $Location -$ms = [System.IO.MemoryStream]::new(); -$wr = [System.IO.StreamWriter]::new($ms); - +$global:data = "" function Scan { param ( [string] $path = '' ) - foreach ( $item in ( Get-ChildItem -Path $path ) ) { + foreach ( $item in ( Get-ChildItem -Path $path -File ) ) { $name = $item.Name - if ( Test-Path -Path ".\$path\$name" -PathType Container ) { - Scan -Path ".\$path\$name" - continue - } + $global:data += (Get-FileHash -Path ".\$path\$name" -Algorithm SHA256).Hash.ToLower() + } - if ( Test-Path -Path ".\$path\$name" -PathType Leaf ) { - $wr.Write((Get-FileHash -Path ".\$path\$name" -Algorithm SHA256).Hash.ToLower()) - } + foreach ( $item in ( Get-ChildItem -Path $path -Directory ) ) { + $name = $item.Name + + Scan -Path ".\$path\$name" } } Scan -Path '.' -Write-Output (Get-FileHash -InputStream $ms).Hash.ToLower() +Write-Output (Get-FileHash -InputStream ([System.IO.MemoryStream]::New([System.Text.Encoding]::UTF8.GetBytes($data)))).Hash.ToLower() Pop-Location exit 0 \ No newline at end of file