Update scripts and fix build

This commit is contained in:
Netch
2021-07-16 06:00:50 +08:00
parent df76db1f07
commit 4f07cf20bf
24 changed files with 189 additions and 87 deletions

View File

@@ -33,7 +33,7 @@ jobs:
run: |
7z a -mx9 Netch.7z release
7z rn Netch.7z release Netch
echo "NETCH_SHA256=$(.\sha256.ps1 Netch.7z)" | Out-File -Append -Encoding UTF8 -FilePath $Env:GITHUB_ENV
echo "NETCH_SHA256=$((Get-FileHash Netch.7z -Algorithm SHA256).Hash.ToLower())" | Out-File -Append -Encoding UTF8 -FilePath $Env:GITHUB_ENV
- name: Release
uses: softprops/action-gh-release@v1

View File

@@ -133,7 +133,7 @@ namespace Netch.Controllers.Mode
public bool Create(Models.Server.Server s, Models.Mode.Mode m)
{
Global.Logger.Info(String.Format("{0:x} tun2socks.bin", Utils.FileHelper.Checksum("Bin\\tun2socks.bin"));
Global.Logger.Info(String.Format("{0:x} tun2socks.bin", Utils.FileHelper.Checksum("Bin\\tun2socks.bin")));
if (!this.Outbound.Get())
{

View File

@@ -1,7 +1,6 @@
$exec=(Split-Path $MyInvocation.MyCommand.Path -Parent)
$last=(Get-Location).Path
Set-Location $exec
Push-Location $exec
$Env:CGO_ENABLED="0"
$Env:GOROOT_FINAL="/usr"
@@ -10,5 +9,5 @@ $Env:GOOS="windows"
$Env:GOARCH="amd64"
go build -a -trimpath -asmflags "-s -w" -ldflags "-s -w" -o "..\release\aiodns.exe"
Set-Location $last
Pop-Location
exit $lastExitCode

View File

@@ -1,11 +1,10 @@
$exec=(Split-Path $MyInvocation.MyCommand.Path -Parent)
$last=(Get-Location).Path
Set-Location $exec
Push-Location $exec
rm -Force go.*
go mod init aiodns
go mod tidy
Set-Location $last
Pop-Location
exit $lastExitCode

View File

@@ -1,7 +1,6 @@
$exec=(Split-Path $MyInvocation.MyCommand.Path -Parent)
$last=(Get-Location).Path
Set-Location $exec
Push-Location $exec
.\clean.ps1
@@ -17,5 +16,14 @@ Get-ChildItem -Path . -Directory | ForEach-Object {
}
}
Set-Location $last
Write-Host
Get-ChildItem -Path .\release -File | ForEach-Object {
$name=$_.Name
$hash=(Get-FileHash ".\release\$name" -Algorithm SHA256).Hash.ToLower()
Write-Host "$hash $name"
}
Pop-Location
exit 0

View File

@@ -1,11 +1,10 @@
$exec=(Split-Path $MyInvocation.MyCommand.Path -Parent)
$last=(Get-Location).Path
Set-Location $exec
Push-Location $exec
if (Test-Path release) {
Remove-Item -Recurse -Force release
}
Set-Location $last
Pop-Location
exit 0

View File

@@ -1,7 +1,6 @@
$exec=(Split-Path $MyInvocation.MyCommand.Path -Parent)
$last=(Get-Location).Path
Set-Location $exec
Push-Location $exec
.\clean.ps1
@@ -14,5 +13,5 @@ Get-ChildItem -Path . -Directory | ForEach-Object {
}
}
Set-Location $last
Pop-Location
exit 0

View File

@@ -1,7 +1,6 @@
$exec=(Split-Path $MyInvocation.MyCommand.Path -Parent)
$last=(Get-Location).Path
Set-Location $exec
Push-Location $exec
$Env:CGO_ENABLED="0"
$Env:GOROOT_FINAL="/usr"
@@ -10,5 +9,5 @@ $Env:GOOS="windows"
$Env:GOARCH="amd64"
go build -a -trimpath -asmflags "-s -w" -ldflags "-s -w" -o "..\release\tap2socks.exe"
Set-Location $last
Pop-Location
exit $lastExitCode

View File

@@ -1,11 +1,10 @@
$exec=(Split-Path $MyInvocation.MyCommand.Path -Parent)
$last=(Get-Location).Path
Set-Location $exec
Push-Location $exec
rm -Force go.*
go mod init tap2socks
go mod tidy
Set-Location $last
Pop-Location
exit $lastExitCode

View File

@@ -1,7 +1,6 @@
$exec=(Split-Path $MyInvocation.MyCommand.Path -Parent)
$last=(Get-Location).Path
Set-Location $exec
Push-Location $exec
$Env:CGO_ENABLED="0"
$Env:GOROOT_FINAL="/usr"
@@ -10,5 +9,5 @@ $Env:GOOS="windows"
$Env:GOARCH="amd64"
go build -a -trimpath -asmflags "-s -w" -ldflags "-s -w" -o "..\release\tun2socks.exe"
Set-Location $last
Pop-Location
exit $lastExitCode

View File

@@ -1,11 +1,10 @@
$exec=(Split-Path $MyInvocation.MyCommand.Path -Parent)
$last=(Get-Location).Path
Set-Location $exec
Push-Location $exec
rm -Force go.*
go mod init tun2socks
go mod tidy
Set-Location $last
Pop-Location
exit $lastExitCode

View File

@@ -24,12 +24,25 @@ param (
Set-Location (Split-Path $MyInvocation.MyCommand.Path -Parent)
.\scripts\download.ps1 $OutputPath
if (Test-Path -Path $OutputPath) {
Remove-Item -Recurse -Force $OutputPath
}
if (Test-Path -Path $OutputPath -IsValid) {
New-Item -ItemType Directory -Name $OutputPath | Out-Null
}
.\deps.ps1 $OutputPath
if ( -Not $? ) { exit $lastExitCode }
.\Other\build.ps1
.\other\build.ps1
if ( -Not $? ) { exit $lastExitCode }
if (Test-Path .\other\release) {
Copy-Item -Recurse -Force .\other\release\* $OutputPath\bin
}
Write-Host
Write-Host "Building Netch"
dotnet publish `
-c $Configuration `
@@ -41,5 +54,11 @@ dotnet publish `
-p:PublishReadyToRun=$PublishReadyToRun `
-o $OutputPath `
Netch\Netch.csproj
if ( -Not $? ) { exit $lastExitCode }
exit $lastExitCode
if ( "Release".Equals($Configuration) ) {
Remove-Item -Force $OutputPath\*.pdb
Remove-Item -Force $OutputPath\*.xml
}
exit 0

35
deps.ps1 Normal file
View File

@@ -0,0 +1,35 @@
param (
[string]
$OutputPath = 'release'
)
Push-Location $OutputPath
New-Item -ItemType Directory -Name bin | Out-Null
New-Item -ItemType Directory -Name mode | Out-Null
New-Item -ItemType Directory -Name i18n | Out-Null
# Get-ChildItem -Path ..\scripts\deps\base -File | ForEach-Object {
# $name=$_.Name
# Write-Host "Executing $name"
# & "..\scripts\deps\base\$name"
# if (-Not $?) {
# Pop-Location
# exit $lastExitCode
# }
# }
Get-ChildItem -Path ..\scripts\deps -File | ForEach-Object {
$name=$_.Name
Write-Host "Executing $name"
& "..\scripts\deps\$name" -OutputPath bin
if (-Not $?) {
Pop-Location
exit $lastExitCode
}
}
Pop-Location
exit 0

View File

@@ -0,0 +1,14 @@
$name="data.zip"
$address="https://github.com/netchx/netch-data/archive/refs/heads/main.zip"
..\scripts\download.ps1 $name $address
if (-Not $?) { exit $lastExitCode }
..\scripts\extract.ps1 $name "bin"
if (-Not $?) { exit $lastExitCode }
Copy-Item -Recurse -Force .\netch-data-main\* .\bin
Remove-Item -Force $name
Remove-Item -Recurse -Force netch-data-main
exit 0

View File

@@ -0,0 +1,14 @@
$name="i18n.zip"
$address="https://github.com/netchx/netch-i18n/archive/refs/heads/main.zip"
..\scripts\download.ps1 $name $address
if (-Not $?) { exit $lastExitCode }
..\scripts\extract.ps1 $name "i18n"
if (-Not $?) { exit $lastExitCode }
Copy-Item -Recurse -Force .\netch-i18n-main\* .\i18n
Remove-Item -Force $name
Remove-Item -Recurse -Force netch-i18n-main
exit 0

View File

@@ -0,0 +1,14 @@
$name="mode.zip"
$address="https://github.com/netchx/netch-mode/archive/refs/heads/main.zip"
..\scripts\download.ps1 $name $address
if (-Not $?) { exit $lastExitCode }
..\scripts\extract.ps1 $name "mode"
if (-Not $?) { exit $lastExitCode }
Copy-Item -Recurse -Force .\netch-mode-main\* .\mode
Remove-Item -Force $name
Remove-Item -Recurse -Force netch-mode-main
exit 0

View File

@@ -2,7 +2,8 @@ param([string]$OutputPath)
$name="ck-client.exe"
$address="https://github.com/cbeuw/Cloak/releases/download/v2.5.4/ck-client-windows-amd64-v2.5.4.exe"
Invoke-WebRequest -Uri $address -OutFile $name
..\scripts\download.ps1 $name $address
if (-Not $?) { exit $lastExitCode }
Move-Item -Force $name $OutputPath
exit 0

View File

@@ -2,7 +2,8 @@ param([string]$OutputPath)
$name="geoip.dat"
$address="https://github.com/v2fly/geoip/releases/download/202107080024/geoip.dat"
Invoke-WebRequest -Uri $address -OutFile $name
..\scripts\download.ps1 $name $address
if (-Not $?) { exit $lastExitCode }
Move-Item -Force $name $OutputPath
exit 0

View File

@@ -2,7 +2,8 @@ param([string]$OutputPath)
$name="geosite.dat"
$address="https://github.com/v2fly/domain-list-community/releases/download/20210709152606/dlc.dat"
Invoke-WebRequest -Uri $address -OutFile $name
..\scripts\download.ps1 $name $address
if (-Not $?) { exit $lastExitCode }
Move-Item -Force $name $OutputPath
exit 0

View File

@@ -1,8 +1,12 @@
param([string]$OutputPath)
$name="v2ray-core.zip"
$address="https://github.com/v2fly/v2ray-core/releases/download/v4.40.1/v2ray-windows-64.zip"
Invoke-WebRequest -Uri $address -OutFile v2ray-core.zip
Expand-Archive -Force -Path v2ray-core.zip -DestinationPath v2ray-core
..\scripts\download.ps1 $name $address
if (-Not $?) { exit $lastExitCode }
..\scripts\extract.ps1 $name "v2ray-core"
if (-Not $?) { exit $lastExitCode }
Move-Item -Force v2ray-core\v2ctl.exe $OutputPath
Move-Item -Force v2ray-core\v2ray.exe $OutputPath

View File

@@ -0,0 +1,15 @@
param([string]$OutputPath)
$name="xray-core.zip"
$address="https://github.com/XTLS/Xray-core/releases/download/v1.4.2/Xray-windows-64.zip"
..\scripts\download.ps1 $name $address
if (-Not $?) { exit $lastExitCode }
..\scripts\extract.ps1 $name "xray-core"
if (-Not $?) { exit $lastExitCode }
Move-Item -Force "xray-core\xray.exe" $OutputPath
Remove-Item -Recurse -Force xray-core
Remove-Item -Recurse -Force xray-core.zip
exit 0

View File

@@ -1,42 +1,18 @@
param([string]$OutputPath)
param (
[string]
$name,
$NetchDataURL="https://github.com/netchx/netch-data/archive/refs/heads/main.zip"
$NetchModeURL="https://github.com/netchx/netch-mode/archive/refs/heads/main.zip"
$NetchI18NURL="https://github.com/netchx/netch-i18n/archive/refs/heads/main.zip"
[string]
$address
)
$last=(Get-Location).Path
New-Item -ItemType Directory -Name $OutputPath | Out-Null
Set-Location $OutputPath
try
{
Invoke-WebRequest -OutFile $name -Uri $address
}
catch
{
exit 1
}
Invoke-WebRequest -Uri $NetchDataURL -OutFile data.zip
Invoke-WebRequest -Uri $NetchModeURL -OutFile mode.zip
Invoke-WebRequest -Uri $NetchI18NURL -OutFile i18n.zip
Expand-Archive -Force -Path data.zip -DestinationPath .
Expand-Archive -Force -Path mode.zip -DestinationPath .
Expand-Archive -Force -Path i18n.zip -DestinationPath .
New-Item -ItemType Directory -Name Bin | Out-Null
New-Item -ItemType Directory -Name Mode | Out-Null
New-Item -ItemType Directory -Name I18N | Out-Null
Copy-Item -Recurse -Force .\netch-data-main\* .\Bin
Copy-Item -Recurse -Force .\netch-mode-main\mode\* .\Mode
Copy-Item -Recurse -Force .\netch-i18n-main\i18n\* .\I18N
Remove-Item -Recurse -Force netch-data-main
Remove-Item -Recurse -Force netch-mode-main
Remove-Item -Recurse -Force netch-i18n-main
Remove-Item -Force data.zip
Remove-Item -Force mode.zip
Remove-Item -Force i18n.zip
..\scripts\download\cloak.ps1 -OutputPath Bin
..\scripts\download\geoip.ps1 -OutputPath Bin
..\scripts\download\geosite.ps1 -OutputPath Bin
..\scripts\download\v2ray-core.ps1 -OutputPath Bin
..\scripts\download\x2ray-core.ps1 -OutputPath Bin
Get-Item *
Set-Location $last
exit 0
exit 0

View File

@@ -1,11 +0,0 @@
param([string]$OutputPath)
$address="https://github.com/XTLS/Xray-core/releases/download/v1.4.2/Xray-windows-64.zip"
Invoke-WebRequest -Uri $address -OutFile xray-core.zip
Expand-Archive -Force -Path xray-core.zip -DestinationPath xray-core
Move-Item -Force xray-core\xray.exe $OutputPath
Remove-Item -Recurse -Force xray-core
Remove-Item -Recurse -Force xray-core.zip
exit 0

19
scripts/extract.ps1 Normal file
View File

@@ -0,0 +1,19 @@
param (
[string]
$name,
[string]
$address
)
try
{
Expand-Archive -Force -Path $name -DestinationPath $address
}
catch
{
Write-Host "Extract $name failed"
exit 1
}
exit 0