diff --git a/.gitignore b/.gitignore index b9eb38e..9f34a8d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,5 +2,5 @@ *.log .env .vscode -dist +bin .wix \ No newline at end of file diff --git a/Taskfile.yml b/Taskfile.yml index 29e4e65..ff9e39b 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -1,5 +1,9 @@ version: '3' +vars: + APP_NAME: 'HATray' + VERSION: '0.0.1' + includes: build: taskfile: tasks/Taskfile_{{OS}}.yml diff --git a/tasks/Taskfile_windows.yml b/tasks/Taskfile_windows.yml index 9d5495c..7f96e38 100644 --- a/tasks/Taskfile_windows.yml +++ b/tasks/Taskfile_windows.yml @@ -1,18 +1,37 @@ version: '3' vars: - APP_NAME: 'HATray' - EXE_NAME: '{{.APP_NAME}}.exe' - VERSION: '0.0.1' + BINARY_NAME: '{{.APP_NAME}}.exe' tasks: build: cmds: - - go build -o ./dist/{{.EXE_NAME}} ./cmd/main.go + - go build -o ./bin/{{.BINARY_NAME}} ./cmd/main.go + service: + desc: "Install the service" + deps: [build] + cmds: + # Create the service, if not already present + - cmd: pwsh -c 'sc create HATray binPath= "$env:USERPROFILE\AppData\Local\HATray\{{.BINARY_NAME}}" start=auto' + ignore_error: true + # Stop the service, if running + - cmd: pwsh -c 'sc stop HATray' + ignore_error: true + # Replace the binary + - cmd: pwsh -c 'Copy-Item -Force -Path .\bin\{{.BINARY_NAME}} -Destination $env:USERPROFILE\AppData\Local\HATray\{{.BINARY_NAME}}' + # Start the service + - cmd: pwsh -c 'sc start HATray' + + tail: + desc: "Tail the log file" + cmds: + - cmd: pwsh -c 'Get-Content -Path $env:USERPROFILE\AppData\Local\HATray\current.log -Tail 100 -Wait' + package: + desc: "Package the application as a MSI" deps: [build] cmds: - wix extension add WixToolset.Util.wixext - wix extension add WixToolset.UI.wixext - - wix build -ext WixToolset.Util.wixext -ext WixToolset.UI.wixext -o ./dist/{{.APP_NAME}}-{{.VERSION}}.msi build/msi/HATray.wxs -arch x64 -d VERSION={{.VERSION}} -d SOURCE=./dist/{{.EXE_NAME}} \ No newline at end of file + - wix build -ext WixToolset.Util.wixext -ext WixToolset.UI.wixext -o ./bin/{{.APP_NAME}}-{{.VERSION}}.msi build/msi/HATray.wxs -arch x64 -d VERSION={{.VERSION}} -d SOURCE=./bin/{{.BINARY_NAME}} \ No newline at end of file