|
|
|
@ -13,38 +13,51 @@ CoordMode, Mouse, Screen
|
|
|
|
|
; Menu, Tray, Icon, RMScriptManager.ico
|
|
|
|
|
|
|
|
|
|
;---Notes/Extra Info/#Includes------------------------------------------------------
|
|
|
|
|
; [IniFile]
|
|
|
|
|
; FileNameOfAHKScripttoCompile=
|
|
|
|
|
; ICOFileName=
|
|
|
|
|
#Include, %A_ScriptDir%\Lib\Freedomain-Posters-Shared-Functions\WindowCredentialManager.ahk
|
|
|
|
|
|
|
|
|
|
;---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
|
|
|
|
|
Exefilepath = %A_ScriptDir%\Freedomain Video Uploader.exe
|
|
|
|
|
icopath = %A_ScriptDir%\Assets\FreedomainVideo.ico
|
|
|
|
|
VersionIniFP = %A_ScriptDir%\Version.ini
|
|
|
|
|
;---\VARIABLES-----------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; Compile to .exe
|
|
|
|
|
; ------------------------------------------------
|
|
|
|
|
; Bump the version number in the version.ini file
|
|
|
|
|
IniRead, VersionNumber, %VersionIniFP%, Video-Uploader, Version, 0.0 ; , Filename, Section, Key [, Default]
|
|
|
|
|
VersionNumber += .01
|
|
|
|
|
VersionNumber := SubStr(VersionNumber, 1, 4)
|
|
|
|
|
; Msgbox % "VersionNumber: " VersionNumber
|
|
|
|
|
IniWrite, %VersionNumber%, %VersionIniFP%,Video-Uploader, Version
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; 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
|
|
|
|
|
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)){
|
|
|
|
|
msgbox, %AHKFilepath% does not exist`nExiting
|
|
|
|
|
ExitApp
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
; check if file exists and if not, give user error and stop
|
|
|
|
|
if(!FileExist(icopath)){
|
|
|
|
|
msgbox, %icopath% does not exist`nExiting
|
|
|
|
|
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")
|
|
|
|
|
GiteaToken := Cred.Password
|
|
|
|
|
; Create new Release on Gitea using Gitea-CreateRelease.ps1
|
|
|
|
|
; ------------------------------------------------
|
|
|
|
|
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
|
|
|
|
|
ReleaseTag := VersionNumber
|
|
|
|
|
; ReleaseBody := "-Fixed Item 1--Fixed Item 2--Fixed Item 3"
|
|
|
|
|
|
|
|
|
|
Command = Powershell "%PS1Filepath%" "%APIURL%" "%ReleaseName%" "%ReleaseTag%" "%ReleaseBody%"
|
|
|
|
|
Clipboard := Command
|
|
|
|
|
Msgbox % "Command: " Command
|
|
|
|
|
Returned := RunCMD(Command)
|
|
|
|
|
Clipboard := Returned
|
|
|
|
|
Msgbox % "Returned: " Returned
|
|
|
|
|
; Strings with spaces in them need to be surrounted by a single quote and double quote, eg: "'spaced string'"
|
|
|
|
|
Command = Powershell "%CreateReleasePS1Filepath%" "%CreateReleaseAPIURL%" "%ReleaseName%" "%ReleaseTag%" "'%ReleaseBody%'"
|
|
|
|
|
|
|
|
|
|
; 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=
|
|
|
|
|
SplitText2 = `;
|
|
|
|
|
ReleaseID := StrSplit(Returned, SplitText)[2]
|
|
|
|
|
ReleaseID := StrSplit(Results, SplitText)[2]
|
|
|
|
|
ReleaseID := StrSplit(ReleaseID, SplitText2)[1]
|
|
|
|
|
|
|
|
|
|
Clipboard := ReleaseID
|
|
|
|
|
Msgbox % "ReleaseID: " ReleaseID
|
|
|
|
|
Message = 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
|
|
|
|
@ -123,3 +148,6 @@ ExitApp
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
;---FUNCTIONS-----------------------------------------------------------------------
|
|
|
|
|
LogToErrorLogFile(Text, TextFileFilepath){
|
|
|
|
|
FileAppend, %Text%`n, %TextFileFilepath%
|
|
|
|
|
}
|