Skip to content

Commit

Permalink
Merge pull request #77 from mysteriumnetwork/installer-msi
Browse files Browse the repository at this point in the history
MSI installer package
  • Loading branch information
Zensey committed Nov 28, 2022
2 parents 2cf9421 + 6e51b7e commit fff34f0
Show file tree
Hide file tree
Showing 28 changed files with 1,012 additions and 99 deletions.
28 changes: 27 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,16 @@ jobs:
with:
go-version: 1.17

- name: Choco help
uses: crazy-max/ghaction-chocolatey@v2
with:
args: -h

- name: Build
run: |
go run cmd/resource/resource.go
go build -v -trimpath -ldflags "-s -w -H windowsgui" -o bin/myst-launcher-amd64.exe github.com/mysteriumnetwork/myst-launcher/cmd/app
go build -v -trimpath -ldflags "-s -w -H windowsgui" -o bin/myst-launcher-updater.exe github.com/mysteriumnetwork/myst-launcher/cmd/updater
env:
GOARCH: amd64
GOOS: windows
Expand All @@ -38,13 +44,33 @@ jobs:
folder: 'bin'
recursive: true

- name: Build
run: |
choco install iconsext
choco install wix
$env:PATH=$env:PATH+";C:\Program Files (x86)\WiX Toolset v3.11\bin;C:\Program Files (x86)\NirSoft\IconsExtract"
iconsext.exe /save "bin\myst-launcher-amd64.exe" "installer\" -icons
candle installer\installer.wxs installer\licenseDialogue.wxs -arch x64 -out installer\
light installer\installer.wixobj installer\licenseDialogue.wixobj -dcl:high -ext WixUIExtension.dll -ext WixUtilExtension.dll -out installer\myst-launcher-x64.msi
- name: Sign
uses: mysteriumnetwork/code-sign-action@v7
with:
certificate: '${{ secrets.WINDOWS_CERTS }}'
password: '${{ secrets.WINDOWS_CERTS_PASSWORD }}'
certificatesha1: '${{ secrets.WINDOWS_CERTS_THUMBPRINT }}'
certificatename: '${{ secrets.WINDOWS_CERTS_NAME }}'
folder: 'installer'
recursive: true

- name: Upload
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
prerelease: true
files: |
bin/myst-launcher-amd64.exe
bin/myst-launcher-updater.exe
installer/myst-launcher-x64.msi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
44 changes: 34 additions & 10 deletions cmd/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ import (
"fmt"
"log"
"os"
"time"

"github.com/gonutz/w32"

"github.com/mysteriumnetwork/myst-launcher/app"
_const "github.com/mysteriumnetwork/myst-launcher/const"
"github.com/mysteriumnetwork/myst-launcher/controller"
"github.com/mysteriumnetwork/myst-launcher/controller/docker"
"github.com/mysteriumnetwork/myst-launcher/controller/native"
gui_win32 "github.com/mysteriumnetwork/myst-launcher/gui-win32"
ipc_ "github.com/mysteriumnetwork/myst-launcher/ipc"
"github.com/mysteriumnetwork/myst-launcher/model"
"github.com/mysteriumnetwork/myst-launcher/updates"
"github.com/mysteriumnetwork/myst-launcher/utils"
)

Expand All @@ -35,12 +37,21 @@ func main() {
switch v {
case _const.FlagInstall,
_const.FlagUninstall,
_const.FlagInstallFirewall:
_const.FlagInstallFirewall,
_const.FlagStop:
cmd = v
case _const.FlagDebug:
debugMode = true
}
}
if debugMode {
utils.AllocConsole(false)
defer func() {
fmt.Println("Press 'Enter' to continue...")
bufio.NewReader(os.Stdin).ReadBytes('\n')
}()
}

if cmd != "" {
switch cmd {
case _const.FlagInstall:
Expand All @@ -50,16 +61,26 @@ func main() {
case _const.FlagUninstall:
ipc.SendStopApp()
utils.UninstallExe()

// for older versions e.g <=1.0.30
// it should be shutdown forcefully with a related docker container

native.KillPreviousLauncher()
if err := docker.UninstallMystContainer(); err != nil {
fmt.Println("UninstallMystContainer failed:", err)
return
}

case _const.FlagStop:
ipc.SendStopApp()
time.Sleep(1 * time.Second) // wait for main process to finish, this is important for MSI to finish
return

case _const.FlagInstallFirewall:
native.CheckAndInstallFirewallRules()
return
}
}
if debugMode {
utils.AllocConsole(false)
}

mod := model.NewUIModel()
mod.SetApp(ap)
Expand All @@ -85,16 +106,23 @@ func main() {
ui := gui_win32.NewGui(mod)

// skip update if IsUserAnAdmin
if !w32.SHIsUserAnAdmin() && updates.UpdateLauncherFromNewBinary(ui, ipc) {
if !w32.SHIsUserAnAdmin() && controller.UpdateLauncherFromNewBinary(ui, ipc) {
return
}

// exit if another instance is running already
if controller.PopupFirstInstance(ui, ipc) {
return
}

ap.SetModel(mod)
log.SetOutput(ap)

ui.CreateNotifyIcon(mod)
ui.CreateMainWindow()
ap.SetUI(ui)

go controller.CheckLauncherUpdates(mod)
ap.StartAppController()
ipc.Listen(ui)

Expand All @@ -103,8 +131,4 @@ func main() {
gui_win32.ShutdownGDIPlus()
ap.StopAppController()

if debugMode {
fmt.Println("Press 'Enter' to continue...")
bufio.NewReader(os.Stdin).ReadBytes('\n')
}
}
4 changes: 2 additions & 2 deletions cmd/resource/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ import (

var (
// fixed non-string version. used for launcher version checks
intVersion = [4]uint16{1, 0, 36, 0}
intVersion = [4]uint16{1, 0, 37, 0}
// display version
strVersion = "1.0.36"
strVersion = "1.0.37"
)

func getIcon(path string) *winres.Icon {
Expand Down
27 changes: 27 additions & 0 deletions cmd/updater/app.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* Copyright (c) 2021 BlockDev AG
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/

package main

import (
"bufio"
"fmt"
"os"

"github.com/mysteriumnetwork/myst-launcher/controller"
"github.com/mysteriumnetwork/myst-launcher/utils"
)

func main() {
utils.AllocConsole(false)
defer func() {
fmt.Println("Press Enter to exit ..")
bufio.NewReader(os.Stdin).ReadBytes('\n')
}()

controller.CheckLauncherUpdatesCli()
}
1 change: 1 addition & 0 deletions const/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ const (
FlagUninstall = "-uninstall"
FlagInstallFirewall = "-install-fw"
FlagDebug = "-debug"
FlagStop = "-stop" //v1.0.36+
)
2 changes: 1 addition & 1 deletion controller/docker/install_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (c *Controller) tryInstallDocker() bool {
c.lg.Println("Downloading Docker desktop: ", url)
err = utils.DownloadFile(utils.GetTmpDir()+name, url, func(progress int) {
if progress%10 == 0 {
c.lg.Println(fmt.Sprintf("%s - %d%%", name, progress))
c.lg.Printf("%s - %d%%\n", name, progress)
}
})
if err != nil {
Expand Down
4 changes: 1 addition & 3 deletions controller/docker/install_win32.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,7 @@ func (c *Controller) tryInstallDocker() bool {
mdl.Config.InitialState = model.InitialStateStage2
mdl.Config.Save()

utils.CreateAutostartShortcut("")
utils.EnableAutorun(true)

utils.CreateDesktopShortcut("")
utils.CreateStartMenuShortcut("")
}
Expand Down Expand Up @@ -139,7 +137,7 @@ func (c *Controller) tryInstallDocker() bool {
if _, err := os.Stat(utils.GetTmpDir() + "\\" + v.name); err != nil {
err := utils.DownloadFile(utils.GetTmpDir()+"\\"+v.name, v.url, func(progress int) {
if progress%10 == 0 {
c.lg.Println(fmt.Sprintf("%s - %d%%", v.name, progress))
c.lg.Printf("%s - %d%%\n", v.name, progress)
}
})
if err != nil {
Expand Down
16 changes: 16 additions & 0 deletions controller/docker/uninstall.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package docker

import "github.com/mysteriumnetwork/myst-launcher/myst"

func UninstallMystContainer() error {
mystManager, err := myst.NewManager(nil)
if err != nil {
return err
}
err = mystManager.Stop()
if err != nil {
return err
}
err = mystManager.Remove()
return err
}

0 comments on commit fff34f0

Please sign in to comment.