Automated New Releases Process

pull/49/head
Yuriy 5 months ago
parent dbdefc5a95
commit 8b43ddc8be

Before

Width:  |  Height:  |  Size: 302 KiB

After

Width:  |  Height:  |  Size: 302 KiB

@ -13,38 +13,51 @@ CoordMode, Mouse, Screen
; Menu, Tray, Icon, RMScriptManager.ico ; Menu, Tray, Icon, RMScriptManager.ico
;---Notes/Extra Info/#Includes------------------------------------------------------ ;---Notes/Extra Info/#Includes------------------------------------------------------
; [IniFile] #Include, %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\WindowCredentialManager.ahk
; FileNameOfAHKScripttoCompile=
; ICOFileName=
;---VARIABLES-----------------------------------------------------------------------
ProgramName = Freedomain Video Uploader
ExeProgramName = %ProgramName%.exe
AHKFilepath = %A_ScriptDir%\%ProgramName%.ahk
Exefilepath = %A_ScriptDir%\%ProgramName%.exe
icopath = %A_ScriptDir%\Assets\Icon.ico
VersionIniFP = %A_ScriptDir%\Version.ini
; Generate a new errorlog text file each run
FormatTime, TodayDate , YYYYMMDDHH24MISS, yyyyMMdd_hhmmss
ErrorLogTextFile = %A_ScriptDir%\Lib\ErrorLogging\Compiler_%TodayDate%.txt
;---VARIABLES-----------------------------------------------------------------------
; Read Credential token from Windows Credential Manager using WindowCredentialManager.ahk
cred := CredRead("FDR-Gitea-Token")
GiteaToken := Cred.Password
; Info for Creating the Release with Gitea-CreateRelease.ps1
CreateReleasePS1Filepath = %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Gitea-CreateRelease.ps1
CreateReleaseAPIURL = https://freedomain.dev/api/v1/repos/yuriy/video-uploader/releases?token=%GiteaToken%
;---MAIN SCRIPT--------------------------------------------------------------------- ; Info for Attaching exe file to release using Gitea-AttachAssetToRelease.ps1
AttachAssetToReleasePS1Filepath = %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Gitea-AttachAssetToRelease.ps1
AttachAssetToReleaseAPIURL = https://freedomain.dev/api/v1/repos/yuriy/video-uploader/releases/%ReleaseID%/assets
AHKFilepath = %A_ScriptDir%\Freedomain Video Uploader.ahk ;---\VARIABLES-----------------------------------------------------------------------
Exefilepath = %A_ScriptDir%\Freedomain Video Uploader.exe
icopath = %A_ScriptDir%\Assets\FreedomainVideo.ico
VersionIniFP = %A_ScriptDir%\Version.ini
; Compile to .exe
; ------------------------------------------------
; Bump the version number in the version.ini file ; Bump the version number in the version.ini file
IniRead, VersionNumber, %VersionIniFP%, Video-Uploader, Version, 0.0 ; , Filename, Section, Key [, Default] IniRead, VersionNumber, %VersionIniFP%, Video-Uploader, Version, 0.0 ; , Filename, Section, Key [, Default]
VersionNumber += .01 VersionNumber += .01
VersionNumber := SubStr(VersionNumber, 1, 4) VersionNumber := SubStr(VersionNumber, 1, 4)
; Msgbox % "VersionNumber: " VersionNumber
IniWrite, %VersionNumber%, %VersionIniFP%,Video-Uploader, Version IniWrite, %VersionNumber%, %VersionIniFP%,Video-Uploader, Version
; Kill any active intances of the uploaders so the .exe file can be overwriten by the compilation ; Kill any active intances of the uploaders so the .exe file can be overwriten by the compilation
process, close, Freedomain Video Uploader.exe process, close, %ExeProgramName%
sleep, 1000 sleep, 500
; Delete the .exe file so it can be repalced ; Delete the .exe file so it can be repalced
if(FileExist(Exefilepath)){ if(FileExist(Exefilepath)){
@ -55,57 +68,69 @@ if(FileExist(Exefilepath)){
} }
} }
; check if file exists and if not, give user error and stop
if(!FileExist(AHKFilepath)){ if(!FileExist(AHKFilepath)){
msgbox, %AHKFilepath% does not exist`nExiting msgbox, %AHKFilepath% does not exist`nExiting
ExitApp ExitApp
} }
; check if file exists and if not, give user error and stop
if(!FileExist(icopath)){ if(!FileExist(icopath)){
msgbox, %icopath% does not exist`nExiting msgbox, %icopath% does not exist`nExiting
ExitApp ExitApp
} }
; run, %comspec% /c ""C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe" /in "%AHKFilepath%" /out "%exefilepath%" /icon "%icopath%""
Command = "C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe" /in "%AHKFilepath%" /out "%exefilepath%" /icon "%icopath%"
Results := RunCMD(Command)
LogToErrorLogFile(Results, ErrorLogTextFile)
run, %comspec% /c ""C:\Program Files\AutoHotkey\Compiler\Ahk2Exe.exe" /in "%AHKFilepath%" /out "%exefilepath%" /icon "%icopath%"" if(!InStr(Results, "Successfully")){
Msgbox, Error, Compilation failed with the following error:`n`n%Results%
ExitApp
}
InputBox, ReleaseBody, Release Body, Please Input Release Body,
cred := CredRead("FDR-Gitea-Token") ; Create new Release on Gitea using Gitea-CreateRelease.ps1
GiteaToken := Cred.Password ; ------------------------------------------------
InputBox, ReleaseBody, Release Body, Please Input Text to be used in the Release Body
; Info for Creating the Release with Gitea-CreateRelease.ps1
PS1Filepath = %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\Gitea-CreateRelease.ps1
APIURL = https://freedomain.dev/api/v1/repos/yuriy/video-uploader/releases?token=%GiteaToken%
ReleaseName := VersionNumber ReleaseName := VersionNumber
ReleaseTag := VersionNumber ReleaseTag := VersionNumber
; ReleaseBody := "-Fixed Item 1--Fixed Item 2--Fixed Item 3"
Command = Powershell "%PS1Filepath%" "%APIURL%" "%ReleaseName%" "%ReleaseTag%" "%ReleaseBody%" ; Strings with spaces in them need to be surrounted by a single quote and double quote, eg: "'spaced string'"
Clipboard := Command Command = Powershell "%CreateReleasePS1Filepath%" "%CreateReleaseAPIURL%" "%ReleaseName%" "%ReleaseTag%" "'%ReleaseBody%'"
Msgbox % "Command: " Command
Returned := RunCMD(Command)
Clipboard := Returned
Msgbox % "Returned: " Returned
; Pull out the relead ID Number, used for uploading attachmenets Message = PowerShell Command to Create Release:`n%Command%
LogToErrorLogFile(Message, ErrorLogTextFile)
Results := RunCMD(Command)
LogToErrorLogFile(Results, ErrorLogTextFile)
; Pull out the release ID Number, needed for attaching a file to the release
SplitText = @{id= SplitText = @{id=
SplitText2 = `; SplitText2 = `;
ReleaseID := StrSplit(Returned, SplitText)[2] ReleaseID := StrSplit(Results, SplitText)[2]
ReleaseID := StrSplit(ReleaseID, SplitText2)[1] ReleaseID := StrSplit(ReleaseID, SplitText2)[1]
Clipboard := ReleaseID Message = ReleaseID: %ReleaseID%
Msgbox % "ReleaseID: " ReleaseID LogToErrorLogFile(Message, ErrorLogTextFile)
; runcmd()
; Attach .exe File to Release using Gitea-AttachAssetToRelease.ps1
; ------------------------------------------------
; Strings with spaces in them need to be surrounted by a single quote and double quote, eg: "'spaced string'"
Command = Powershell "%AttachAssetToReleasePS1Filepath%" "%AttachAssetToReleaseAPIURL%" "%GiteaToken%" "'%ExeProgramName%'" "'%Exefilepath%'"
LogToErrorLogFile(Command, ErrorLogTextFile)
Results := RunCMD(Command)
LogToErrorLogFile(Results, ErrorLogTextFile)
ExitApp ExitApp
@ -123,3 +148,6 @@ ExitApp
;---FUNCTIONS----------------------------------------------------------------------- ;---FUNCTIONS-----------------------------------------------------------------------
LogToErrorLogFile(Text, TextFileFilepath){
FileAppend, %Text%`n, %TextFileFilepath%
}

@ -11,7 +11,7 @@ DetectHiddenWindows, ON ; used for finding Running .ahk scripts
; Only Set tool tray icon if this is the source .ahk script. ; Only Set tool tray icon if this is the source .ahk script.
; The .exe has the icon compiled into it ; The .exe has the icon compiled into it
if(InStr(A_ScriptFullPath, ".ahk")){ if(InStr(A_ScriptFullPath, ".ahk")){
try Menu, Tray, Icon, %A_ScriptDir%\Assets\FreedomainVideo.ico try Menu, Tray, Icon, %A_ScriptDir%\Assets\Icon.ico
} }
; Parameter passed in to script ; Parameter passed in to script

@ -1,4 +1,4 @@
[Video-Uploader] [Video-Uploader]
Version=3.43 Version=3.49
Name=Freedomain Video Uploader Name=Freedomain Video Uploader
APIURL= APIURL=
Loading…
Cancel
Save