-
-
Save dansanti/292803653c5c9506cf070dce60a3bb19 to your computer and use it in GitHub Desktop.
Revisions
-
Slauta revised this gist
Jul 29, 2017 . 1 changed file with 57 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,57 @@ // Inital app const electron = require("electron"); const updater = require("electron-updater"); const autoUpdater = updater.autoUpdater; ... /////////////////// // Auto upadater // /////////////////// autoUpdater.requestHeaders = { "PRIVATE-TOKEN": "Personal access Token" }; autoUpdater.autoDownload = true; autoUpdater.setFeedURL({ provider: "generic", url: "https://gitlab.com/_example_repo_/-/jobs/artifacts/master/raw/dist?job=build" }); autoUpdater.on('checking-for-update', function () { sendStatusToWindow('Checking for update...'); }); autoUpdater.on('update-available', function (info) { sendStatusToWindow('Update available.'); }); autoUpdater.on('update-not-available', function (info) { sendStatusToWindow('Update not available.'); }); autoUpdater.on('error', function (err) { sendStatusToWindow('Error in auto-updater.'); }); autoUpdater.on('download-progress', function (progressObj) { let log_message = "Download speed: " + progressObj.bytesPerSecond; log_message = log_message + ' - Downloaded ' + parseInt(progressObj.percent) + '%'; log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')'; sendStatusToWindow(log_message); }); autoUpdater.on('update-downloaded', function (info) { sendStatusToWindow('Update downloaded; will install in 1 seconds'); }); autoUpdater.on('update-downloaded', function (info) { setTimeout(function () { autoUpdater.quitAndInstall(); }, 1000); }); autoUpdater.checkForUpdates(); function sendStatusToWindow(message) { console.log(message); } ... -
Slauta revised this gist
Jul 29, 2017 . 3 changed files with 4 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,14 +4,12 @@ variables: stages: - build build: image: slauta93/electron-builder-win stage: build artifacts: paths: - $CI_PROJECT_DIR/dist/*.* script: - sed "s/0.0.0/${VERSION_ID}/g" package.json > _package.json && mv _package.json package.json - npm install && npm run build This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,6 @@ This repo contains the **bare minimum code** to have an auto-updating Electron a Install Xcode (from the App Store), then follow [these instructions](https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingCertificates/MaintainingCertificates.html#//apple_ref/doc/uid/TP40012582-CH31-SW6) to make sure you have a "Mac Developer" certificate. If you'd like to export the certificate (for automated building, for instance) [you can](https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingCertificates/MaintainingCertificates.html#//apple_ref/doc/uid/TP40012582-CH31-SW7). You would then follow [these instructions](https://github.com/electron-userland/electron-builder/wiki/Code-Signing). 2. Setting you Gitlab-CI and edit package.json build scripts fron your platforms 3. Pushing new code, and install last build 4. Open the installed version of the app and see that it updates itself. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ "scripts": { "start": "electron .", "pack": "node_modules/.bin/electron-builder --dir", "build": "node_modules/.bin/electron-builder --win", "postinstall": "", "install": "node-gyp install", }, -
Slauta revised this gist
Jul 29, 2017 . 3 changed files with 66 additions and 36 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,17 @@ variables: VERSION_ID: '1.0.$CI_PIPELINE_ID' stages: - build build:win32: image: slauta93/electron-builder-win stage: build artifacts: paths: - $CI_PROJECT_DIR/dist/*.* before_script: - npm install -g bower script: - sed "s/0.0.0/${VERSION_ID}/g" package.json > package2.json && mv package2.json package.json - npm install && npm run build This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,40 +1,9 @@ This repo contains the **bare minimum code** to have an auto-updating Electron app using [`electron-updater`](https://github.com/electron-userland/electron-builder/tree/master/packages/electron-updater) with releases stored on a plain HTTP server. 1. For macOS, you will need a code-signing certificate. Install Xcode (from the App Store), then follow [these instructions](https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingCertificates/MaintainingCertificates.html#//apple_ref/doc/uid/TP40012582-CH31-SW6) to make sure you have a "Mac Developer" certificate. If you'd like to export the certificate (for automated building, for instance) [you can](https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingCertificates/MaintainingCertificates.html#//apple_ref/doc/uid/TP40012582-CH31-SW7). You would then follow [these instructions](https://github.com/electron-userland/electron-builder/wiki/Code-Signing). 2. Setting you CI 3. Pushing new code, and install last build 4. Open the installed version of the app and see that it updates itself. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,46 @@ { "name": "electron-updater-gitlab", "version": "0.0.0", "main": "main.js", "scripts": { "start": "electron .", "pack": "node_modules/.bin/electron-builder --dir", "dist": "node_modules/.bin/electron-builder --win", "postinstall": "", "install": "node-gyp install", }, "build": { "appId": "com.electron.app", "publish": [ { "provider": "generic", "url": "https://gitlab.com" } ], "win": { "target": [ "nsis" ], "verifyUpdateCodeSignature": false }, "mac": { "category": "public.app-category.productivity", "identity": "Mac Developer: username (XXXXXXXX)", "target": [ "dmg" ] }, "linux": { "target": [ "AppImage" ] } }, "dependencies": { "electron-updater": "^2.7.2" }, "devDependencies": { "electron": "1.6.11", "electron-builder": "^19.16.2" } } -
Slauta created this gist
Jul 29, 2017 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ build: This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ This repo contains the **bare minimum code** to have an auto-updating Electron app using [`electron-updater`](https://github.com/electron-userland/electron-builder/tree/master/packages/electron-updater) with releases stored on a plain HTTP server. This example uses `localhost` as the release server. 1. For macOS, you will need a code-signing certificate. Install Xcode (from the App Store), then follow [these instructions](https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingCertificates/MaintainingCertificates.html#//apple_ref/doc/uid/TP40012582-CH31-SW6) to make sure you have a "Mac Developer" certificate. If you'd like to export the certificate (for automated building, for instance) [you can](https://developer.apple.com/library/content/documentation/IDEs/Conceptual/AppDistributionGuide/MaintainingCertificates/MaintainingCertificates.html#//apple_ref/doc/uid/TP40012582-CH31-SW7). You would then follow [these instructions](https://github.com/electron-userland/electron-builder/wiki/Code-Signing). 2. Install necessary dependencies with: yarn or npm install 3. Build your app with: node_modules/.bin/build --win --mac --x64 --ia32 4. Copy the files in the `dist/` directory to your webserver. Here's how to do it on a Linux system: mkdir -p wwwroot cp dist/*.json wwwroot/ cp dist/*.yml wwwroot/ cp dist/mac/*.zip wwwroot/ cp dist/mac/*.dmg wwwroot/ cp dist/*.exe wwwroot/ 5. Serve `wwwroot` over HTTP: node_modules/.bin/http-server wwwroot/ -p 8080 6. Download and install the app from <http://127.0.0.1:8080> 7. Update the version in `package.json`. 8. Do steps 3 and 4 again. 9. Open the installed version of the app and see that it updates itself. This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ const electron = require("electron"); This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ {}