From 09d7334b0797b7e83cb05e35d72258a7e497167f Mon Sep 17 00:00:00 2001 From: chishin Date: Mon, 29 Jan 2024 21:13:41 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=89=88=E6=9C=AC=E5=8F=B7?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.go | 4 ++-- version.bat | 5 +++++ version.vbs | 23 +++++++++++++++++++++++ 3 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 version.bat create mode 100644 version.vbs diff --git a/src/main.go b/src/main.go index c9e766d..257799c 100644 --- a/src/main.go +++ b/src/main.go @@ -1,4 +1,4 @@ -package main +package main import ( "crypto/md5" @@ -11,7 +11,7 @@ import ( ) var ( - VERSION = "1.5.54" + VERSION = "1.5.55" ) var ( diff --git a/version.bat b/version.bat new file mode 100644 index 0000000..6cc0bde --- /dev/null +++ b/version.bat @@ -0,0 +1,5 @@ +@echo off +for /f "delims=" %%i in ('type .version') do set v=%%i +echo version=%v% +cscript //nologo "version.vbs" ".\src\main.go" "%v%" +exit /b 0 diff --git a/version.vbs b/version.vbs new file mode 100644 index 0000000..77eaf46 --- /dev/null +++ b/version.vbs @@ -0,0 +1,23 @@ +Dim objFSO, objFile, strContent, objRegEx, args, adodbStream + +Set objFSO = CreateObject("Scripting.FileSystemObject") +Set args = WScript.Arguments +Set adodbStream = CreateObject("ADODB.Stream") + +adodbStream.Charset = "utf-8" +adodbStream.Open +adodbStream.LoadFromFile args(0) +strContent = adodbStream.ReadText +adodbStream.Close + +Set objRegEx = New RegExp +objRegEx.Global = True +objRegEx.IgnoreCase = True +objRegEx.Pattern = "VERSION\s+=\s+\""[\d\.]+\""" +strContent = objRegEx.Replace(strContent, "VERSION = """ & args(1) & """") + +adodbStream.Charset = "utf-8" +adodbStream.Open +adodbStream.WriteText strContent +adodbStream.SaveToFile args(0), 2 +adodbStream.Close \ No newline at end of file