From 3921edccda12c382778956a6e669afdedd1813b6 Mon Sep 17 00:00:00 2001 From: dark Date: Tue, 24 Dec 2024 02:37:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E6=96=87=E4=BB=B6=E8=87=B3?= =?UTF-8?q?=20''?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- go-release-set.ps1 | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 go-release-set.ps1 diff --git a/go-release-set.ps1 b/go-release-set.ps1 new file mode 100644 index 0000000..32603f6 --- /dev/null +++ b/go-release-set.ps1 @@ -0,0 +1,36 @@ +# powershell 脚本,等待输入ID +$Type = Read-Host "input deploy type(api/web):" +# 如果输入不是api或者web,则退出 +if ($Type -ne "api" -and $Type -ne "web") { + Write-Host "error, input must be api or web" + exit +} + +# 获取文件夹下所有文件的文件名,不包括扩展名,赋值给变量 +$files = Get-ChildItem '.\etc\*.yaml' | ForEach-Object { $_.BaseName } + +# 获取Dockerfile +Invoke-WebRequest https://gitea.gxxhygroup.com/dark/gotools/raw/branch/master/Dockerfile -o Dockerfile +# 使用文件名替换Dockerfile中的Name-For-Replace +$files | ForEach-Object { (Get-Content 'Dockerfile') -replace 'Name-For-Replace', $_ | Set-Content 'Dockerfile' } + +# 获取k8s.yaml +Invoke-WebRequest https://gitea.gxxhygroup.com/dark/gotools/raw/branch/master/k8s.yaml -o k8s.yaml +# 使用文件名替换k8s.yaml中的Name-For-Replace +$files | ForEach-Object { (Get-Content 'k8s.yaml') -replace 'Name-For-Replace', $_ | Set-Content 'k8s.yaml' } + +# 使用$type替换k8s.yaml中的Type-For-Replace +(Get-Content 'k8s.yaml') -replace 'Type-For-Replace', $Type | Set-Content 'k8s.yaml' + + +# 获取replaceTag.ps1,不做改动 +Invoke-WebRequest https://gitea.gxxhygroup.com/dark/gotools/raw/branch/master/replaceTag.ps1 -o replaceTag.ps1 + +# 获取swagger.bat, +Invoke-WebRequest https://gitea.gxxhygroup.com/dark/gotools/raw/branch/master/swagger.bat -o swagger.bat +# $files去除字符串中的-,赋值给变量 +$filesjson = $files -replace '-', '' +# 再去除字符串最后的api或者web +$filesjson = $filesjson -replace 'api', '' +# 使用新文件名替换swagger.bat中的Name-For-Replace +$filesjson | ForEach-Object { (Get-Content 'swagger.bat') -replace 'Name-For-Replace', $_ | Set-Content 'swagger.bat' }