Skip to content

Commit

Permalink
Self installation support
Browse files Browse the repository at this point in the history
* Make dmg able to install the app

* Auto-start at login

* Add docker download & install steps

* Codesign the app and notarize
  • Loading branch information
Zensey authored Sep 23, 2021
1 parent 5936eb2 commit 1f6f903
Show file tree
Hide file tree
Showing 23 changed files with 254 additions and 62 deletions.
58 changes: 54 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
jobs:
releases-macos-amd64:
name: Release
runs-on: macos-latest
runs-on: macos-11

steps:
- uses: actions/checkout@v2
Expand All @@ -31,14 +31,64 @@ jobs:
cd gobridge; sh -c ./mk.sh
cd ..
echo "Make dmg >>>"
sh -c ./make_dmg.sh
echo "Make app build >>>"
sh -c ./make_build.sh
- name: Codesign app
env:
MACOS_CERTIFICATE: ${{ secrets.MACOS_CERTIFICATE }}
MACOS_CERTIFICATE_PWD: ${{ secrets.MACOS_CERTIFICATE_PWD }}
MACOS_CERTIFICATE_ID: ${{ secrets.MACOS_CERTIFICATE_ID }}
KEYCHAIN_TMP_PWD: tmppassword
KEY_CHAIN: build.keychain
APPLE_ID: ${{ secrets.NOTARIZE_EMAIL }}
run: |
echo $MACOS_CERTIFICATE | base64 --decode > certificate.p12
security delete-keychain $KEY_CHAIN || echo ""
security create-keychain -p $KEYCHAIN_TMP_PWD $KEY_CHAIN
security default-keychain -s $KEY_CHAIN
security set-keychain-settings -t 4200 -u $KEY_CHAIN
security unlock-keychain -p $KEYCHAIN_TMP_PWD $KEY_CHAIN
echo "Import"
security import certificate.p12 -k $KEY_CHAIN -P $MACOS_CERTIFICATE_PWD -A # -T /usr/bin/codesign
echo "Set Key"
security set-key-partition-list -S apple-tool:,apple:,codesign: -s -k $KEYCHAIN_TMP_PWD $KEY_CHAIN
# echo "Find identity"
# security find-identity -p codesigning -s $KEY_CHAIN
echo "Codesign"
/usr/bin/codesign --force -s "$MACOS_CERTIFICATE_ID" --timestamp ./build/MysteriumLauncher/Mysterium\ Launcher.app/Contents/MacOS/Mysterium\ Launcher
echo "Codesign dylib"
/usr/bin/codesign --force -s "$MACOS_CERTIFICATE_ID" --timestamp -o runtime ./build/MysteriumLauncher/Mysterium\ Launcher.app/Contents/Frameworks/gobridge.dylib
echo "Codesign whole build"
/usr/bin/codesign --force -s "$MACOS_CERTIFICATE_ID" --timestamp -o runtime ./build/MysteriumLauncher/Mysterium\ Launcher.app/
# dmg
hdiutil create -format UDZO -srcfolder build/MysteriumLauncher mysterium_launcher_macos_amd64.dmg
- name: Notarize
env:
PRIMARY_BUNDLE_ID: com.mysterium.launcher
APPLE_ID: ${{ secrets.NOTARIZE_EMAIL }}
TARGET_BINARY: ./mysterium_launcher_macos_amd64.dmg
APP_SPECIFIC_PASSWORD: ${{ secrets.NOTARIZE_APP_SPEC_PWD }}

run: |
# notarize
sh -c ./notarize.sh
#echo Verify
#/usr/bin/codesign -vvvv ./mysterium_launcher_macos_amd64.dmg
- name: Upload
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/')
with:
files: |
myst_launcher_macos_amd64.dmg
mysterium_launcher_macos_amd64.dmg
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 6 additions & 0 deletions codesign.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
MACOS_CERTIFICATE_ID="(KPKW2HX458)"

/usr/bin/codesign --force -s "$MACOS_CERTIFICATE_ID" --timestamp ./build/MysteriumLauncher/Mysterium\ Launcher.app/Contents/MacOS/Mysterium\ Launcher
/usr/bin/codesign --force -s "$MACOS_CERTIFICATE_ID" --timestamp -o runtime ./build/MysteriumLauncher/Mysterium\ Launcher.app/Contents/Frameworks/gobridge.dylib

#hdiutil create -format UDZO -srcfolder build/MysteriumLauncher mysterium_launcher_macos_amd64.dmg
1 change: 0 additions & 1 deletion gobridge/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ require (
github.com/moby/term v0.0.0-20210619224110-3f7ff695adc6 // indirect
github.com/mysteriumnetwork/myst-launcher v0.0.0
github.com/stretchr/testify v1.7.0 // indirect
github.com/winlabs/gowin32 v0.0.0-20210302152218-c9e40aa88058 // indirect
golang.org/x/net v0.0.0-20210813160813-60bc85c4be6d // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
google.golang.org/grpc v1.40.0 // indirect
Expand Down
2 changes: 2 additions & 0 deletions gobridge/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx2
github.com/bugsnag/bugsnag-go v0.0.0-20141110184014-b1d153021fcd/go.mod h1:2oa8nejYd4cQ/b0hMIopN0lCRxU0bueqREvZLWFrtK8=
github.com/bugsnag/osext v0.0.0-20130617224835-0dd3f918b21b/go.mod h1:obH5gd0BsqsP2LwDJ9aOkm/6J86V6lyAXCoQWGw3K50=
github.com/bugsnag/panicwrap v0.0.0-20151223152923-e2c28503fcd0/go.mod h1:D/8v3kj0zr8ZAKg1AQ6crr+5VwKN5eIywRkfhyM/+dE=
github.com/cavaliercoder/grab v2.0.0+incompatible h1:wZHbBQx56+Yxjx2TCGDcenhh3cJn7cCLMfkEPmySTSE=
github.com/cavaliercoder/grab v2.0.0+incompatible/go.mod h1:tTBkfNqSBfuMmMBFaO2phgyhdYhiZQ/+iXCZDzcDsMI=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
Expand Down
44 changes: 39 additions & 5 deletions gobridge/gobridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import "C"

import (
"fmt"
"io/ioutil"
"log"
"os"

"github.com/mysteriumnetwork/myst-launcher/app"
"github.com/mysteriumnetwork/myst-launcher/model"
Expand All @@ -29,8 +31,39 @@ var (

func init() {
fmt.Println("gobridge init>")
ap = app.NewApp()
}

func copyFile(sourceFile, destinationFile string) {
input, err := ioutil.ReadFile(sourceFile)
if err != nil {
fmt.Println(err)
return
}

err = ioutil.WriteFile(destinationFile, input, 0644)
if err != nil {
fmt.Println("Error creating", destinationFile)
fmt.Println(err)
return
}
}

//export GoInit
func GoInit(res_path *C.char) {
cfg.ResourcePath = C.GoString(res_path)
fmt.Println("resPath >", cfg.ResourcePath)

fileName := "com.mysterium.launcher.plist"

targetDir := os.Getenv("HOME") + "/Library/LaunchAgents/"
os.MkdirAll(targetDir, 0755)
copyFile(cfg.ResourcePath+"/"+fileName, targetDir+fileName)
}

//export GoStart
func GoStart() {
fmt.Println("GoStart >")
ap = app.NewApp()
mod = model.NewUIModel()
sendConfig()

Expand Down Expand Up @@ -66,6 +99,8 @@ func sendState() {
// instllation state
st.checkVTx = C.bool(mod.CheckVTx)
st.checkDocker = C.bool(mod.CheckDocker)
st.downloadFiles = C.bool(mod.DownloadFiles)
st.installDocker = C.bool(mod.InstallDocker)

C.macSendState(&st)
}
Expand Down Expand Up @@ -96,11 +131,10 @@ func GoDialogueComplete() {

//export GoOnAppExit
func GoOnAppExit() {
fmt.Println("OnAppExit >")
ap.TriggerAction("stop")

ap.TriggerAction("stop")
// wait for SuperviseDockerNode to finish its work
ap.WaitGroup.Wait()
// wait for SuperviseDockerNode to finish its work
ap.WaitGroup.Wait()
}

//export GoSetStateAndConfig
Expand Down
2 changes: 2 additions & 0 deletions gobridge/gobridge.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ typedef struct { void *data; GoInt len; GoInt cap; } GoSlice;
extern "C" {
#endif

extern void GoInit(char* res_path);
extern void GoStart();
extern void GoSetModalResult(int rc);
extern void GoDialogueComplete();
extern void GoOnAppExit();
Expand Down
2 changes: 2 additions & 0 deletions gobridge/interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ typedef struct _NSState {

bool checkVTx;
bool checkDocker;
bool downloadFiles;
bool installDocker;
} NSState;

typedef struct _NSConfig {
Expand Down
12 changes: 4 additions & 8 deletions gobridge/interface.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@


void macSendState(NSState *s) {
NSLog(@"macSendState >>>1");

id dict = @{
@"imageName": [[NSString alloc] initWithUTF8String:s->imageName],
@"latestVersion": [[NSString alloc] initWithUTF8String:s->latestVersion],
Expand All @@ -15,6 +13,8 @@ void macSendState(NSState *s) {
// instllation state
@"checkVTx": @(s->checkVTx),
@"checkDocker": @(s->checkDocker),
@"downloadFiles": @(s->downloadFiles),
@"installDocker": @(s->installDocker),
};

// free strings
Expand All @@ -29,8 +29,6 @@ void macSendState(NSState *s) {
}

void macSendConfig(NSConfig *s) {
NSLog(@"macSendConfig >>>");

id dict = @{
@"enabled": @(s->enabled),
@"enablePortForwarding": @(s->enablePortForwarding),
Expand All @@ -46,8 +44,6 @@ void macSendConfig(NSConfig *s) {
}

void macSendModal(NSModal *s) {
NSLog(@"macSendNodal >>>");

id dict = @{
@"title": @(s->title),
@"msg": @(s->msg),
Expand All @@ -65,7 +61,7 @@ void macSendModal(NSModal *s) {
}

void macSendMode(int s) {
NSLog(@"macSendMode >>>");
// NSLog(@"macSendMode >>>");

id dict = @{
@"mode": @(s),
Expand All @@ -77,7 +73,7 @@ void macSendMode(int s) {
}

void macSendLog(char *s) {
NSLog(@"macSendLog >>>");
// NSLog(@"macSendLog >>>");

id dict = @{
@"msg": [[NSString alloc] initWithUTF8String:s],
Expand Down
1 change: 1 addition & 0 deletions gobridge/mk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ CC=clang go build -o gobridge.dylib -buildmode=c-shared *.go
# set proper LC_ID_DYLIB. @rpath - means a library could be found in runtime path.
# otherwise app (dynamic linker) wont be be able to find it during start.
# by default there's no @rpath prefix

install_name_tool -id "@rpath/gobridge.dylib" gobridge.dylib
28 changes: 17 additions & 11 deletions launcher.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
9A63DEE026E605A800594C0B /* MainWindowDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A63DEDE26E605A800594C0B /* MainWindowDelegate.m */; };
9A6FB69E26E8E82500069932 /* Label.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A6FB69D26E8E82500069932 /* Label.m */; };
9A6FB6A126E8EA4200069932 /* NSAttributedString.m in Sources */ = {isa = PBXBuildFile; fileRef = 9A6FB6A026E8EA4200069932 /* NSAttributedString.m */; };
9A725ABE26F0CC6C00E0A64A /* com.mysterium.launcher.plist in Resources */ = {isa = PBXBuildFile; fileRef = 9A725ABD26F0CC6C00E0A64A /* com.mysterium.launcher.plist */; };
9A93390526EF6856004D9F30 /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 9AC8756F26C919D400A99070 /* Info.plist */; };
9AC8756B26C919D400A99070 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 9AC8756A26C919D400A99070 /* Assets.xcassets */; };
9AC8756E26C919D400A99070 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 9AC8756C26C919D400A99070 /* MainMenu.xib */; };
Expand Down Expand Up @@ -74,7 +75,8 @@
9A6FB69D26E8E82500069932 /* Label.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Label.m; sourceTree = "<group>"; };
9A6FB69F26E8EA1000069932 /* NSAttributedString.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSAttributedString.h; sourceTree = "<group>"; };
9A6FB6A026E8EA4200069932 /* NSAttributedString.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = NSAttributedString.m; sourceTree = "<group>"; };
9AC8756426C919CB00A99070 /* Launcher.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Launcher.app; sourceTree = BUILT_PRODUCTS_DIR; };
9A725ABD26F0CC6C00E0A64A /* com.mysterium.launcher.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = com.mysterium.launcher.plist; sourceTree = "<group>"; };
9AC8756426C919CB00A99070 /* Mysterium Launcher.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Mysterium Launcher.app"; sourceTree = BUILT_PRODUCTS_DIR; };
9AC8756726C919CC00A99070 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
9AC8756826C919CC00A99070 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
9AC8756A26C919D400A99070 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
Expand Down Expand Up @@ -153,7 +155,7 @@
9AC8756526C919CB00A99070 /* Products */ = {
isa = PBXGroup;
children = (
9AC8756426C919CB00A99070 /* Launcher.app */,
9AC8756426C919CB00A99070 /* Mysterium Launcher.app */,
9AC8757726C919D400A99070 /* launcherTests.xctest */,
9AC8758226C919D400A99070 /* launcherUITests.xctest */,
);
Expand All @@ -163,6 +165,7 @@
9AC8756626C919CB00A99070 /* launcher */ = {
isa = PBXGroup;
children = (
9A725ABD26F0CC6C00E0A64A /* com.mysterium.launcher.plist */,
9AC8757026C919D400A99070 /* main.m */,
9A16EF8C26EA5EF20036447D /* utils.h */,
9A16EF8A26EA5EB00036447D /* utils.m */,
Expand Down Expand Up @@ -206,9 +209,9 @@
/* End PBXGroup section */

/* Begin PBXNativeTarget section */
9AC8756326C919CB00A99070 /* Launcher */ = {
9AC8756326C919CB00A99070 /* Mysterium Launcher */ = {
isa = PBXNativeTarget;
buildConfigurationList = 9AC8758B26C919D400A99070 /* Build configuration list for PBXNativeTarget "Launcher" */;
buildConfigurationList = 9AC8758B26C919D400A99070 /* Build configuration list for PBXNativeTarget "Mysterium Launcher" */;
buildPhases = (
9AC8756026C919CB00A99070 /* Sources */,
9AC8756226C919CB00A99070 /* Resources */,
Expand All @@ -219,9 +222,9 @@
);
dependencies = (
);
name = Launcher;
name = "Mysterium Launcher";
productName = launcher;
productReference = 9AC8756426C919CB00A99070 /* Launcher.app */;
productReference = 9AC8756426C919CB00A99070 /* Mysterium Launcher.app */;
productType = "com.apple.product-type.application";
};
9AC8757626C919D400A99070 /* launcherTests */ = {
Expand Down Expand Up @@ -295,7 +298,7 @@
projectDirPath = "";
projectRoot = "";
targets = (
9AC8756326C919CB00A99070 /* Launcher */,
9AC8756326C919CB00A99070 /* Mysterium Launcher */,
9AC8757626C919D400A99070 /* launcherTests */,
9AC8758126C919D400A99070 /* launcherUITests */,
);
Expand All @@ -312,6 +315,7 @@
9A63DEDA26E5D86E00594C0B /* ModalWindow.xib in Resources */,
9A93390526EF6856004D9F30 /* Info.plist in Resources */,
9AC8756E26C919D400A99070 /* MainMenu.xib in Resources */,
9A725ABE26F0CC6C00E0A64A /* com.mysterium.launcher.plist in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -369,12 +373,12 @@
/* Begin PBXTargetDependency section */
9AC8757926C919D400A99070 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 9AC8756326C919CB00A99070 /* Launcher */;
target = 9AC8756326C919CB00A99070 /* Mysterium Launcher */;
targetProxy = 9AC8757826C919D400A99070 /* PBXContainerItemProxy */;
};
9AC8758426C919D400A99070 /* PBXTargetDependency */ = {
isa = PBXTargetDependency;
target = 9AC8756326C919CB00A99070 /* Launcher */;
target = 9AC8756326C919CB00A99070 /* Mysterium Launcher */;
targetProxy = 9AC8758326C919D400A99070 /* PBXContainerItemProxy */;
};
/* End PBXTargetDependency section */
Expand Down Expand Up @@ -482,7 +486,7 @@
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEBUG_INFORMATION_FORMAT = "";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
GCC_C_LANGUAGE_STANDARD = gnu11;
Expand Down Expand Up @@ -510,6 +514,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = launcher/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -536,6 +541,7 @@
CODE_SIGN_STYLE = Automatic;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = "";
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = launcher/Info.plist;
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
Expand Down Expand Up @@ -637,7 +643,7 @@
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
9AC8758B26C919D400A99070 /* Build configuration list for PBXNativeTarget "Launcher" */ = {
9AC8758B26C919D400A99070 /* Build configuration list for PBXNativeTarget "Mysterium Launcher" */ = {
isa = XCConfigurationList;
buildConfigurations = (
9AC8758C26C919D400A99070 /* Debug */,
Expand Down
1 change: 1 addition & 0 deletions launcher/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@

- (IBAction)showMain:(id)sender;
- (IBAction)enableNode:(id)sender;
- (IBAction)openNodeUIAction:(id)sender;

@end

Expand Down
Loading

0 comments on commit 1f6f903

Please sign in to comment.