Skip to content

Commit

Permalink
migrating builds to electron-builder
Browse files Browse the repository at this point in the history
  • Loading branch information
olsender committed May 3, 2020
1 parent 2274cbe commit 2ddd896
Show file tree
Hide file tree
Showing 10 changed files with 12,034 additions and 61 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Build/release

on:
push:
tags:
- "v1*"

env:
API_KEY_ID: ${{ secrets.api_key_id }}
API_KEY_ISSUER_ID: ${{ secrets.api_key_issuer_id }}

jobs:
release:
runs-on: ${{ matrix.os }}

strategy:
matrix:
os: [macos-latest, ubuntu-latest, windows-latest]

steps:
- name: Check out Git repository
uses: actions/checkout@v1

- name: Install Node.js, NPM and Yarn
uses: actions/setup-node@v1
with:
node-version: 10

- name: Prepare for app notarization
if: startsWith(matrix.os, 'macos')
# Import Apple API key for app notarization on macOS
run: |
mkdir -p ~/private_keys/
echo '${{ secrets.api_key }}' > ~/private_keys/AuthKey_${{ secrets.api_key_id }}.p8
- name: Build/release Electron app
uses: samuelmeuli/action-electron-builder@v1
with:
# GitHub token, automatically provided to the action
# (No need to define this secret in the repo settings)
github_token: ${{ secrets.github_token }}

# If the commit is tagged with a version (e.g. "v1.0.0"),
# release the app after building
release: ${{ startsWith(github.ref, 'refs/tags/v') }}
mac_certs: ${{ secrets.mac_certs }}
mac_certs_password: ${{ secrets.mac_certs_password }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
SQL Tabs.app
build/*
.build
dist
node_modules/*
sqltabs.dmg
.idea
4 changes: 3 additions & 1 deletion .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#disturl=https://atom.io/download/atom-shell
arch=x64
runtime=electron
target=4.1.0
target_arch=x64
78 changes: 42 additions & 36 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,30 @@ function isDev() {
return process.argv[2] == '--dev';
}

if (process.platform == 'linux'){
var mkdirp = require('mkdirp');
mkdirp(process.env.HOME+'/.local/share/icons', function(err){console.log(err)});
mkdirp(process.env.HOME+'/.local/share/applications');
var fs = require('fs');
fs.open(process.env.HOME+"/.local/share/applications/sqltabs.desktop", "wx", function(err){
if (err){
return;
}
fs.writeFile(process.env.HOME+"/.local/share/applications/sqltabs.desktop", "Icon=sqltabs", function(err) {
if(err) {
return console.log(err);
}
});
});
fs.open(process.env.HOME+"/.local/share/icons/sqltabs.png", "wx", function(err){
if(err){
return;
}
fs.createReadStream('logo.png').pipe(fs.createWriteStream(process.env.HOME+'/.local/share/icons/sqltabs.png'));
});
}
//if (process.platform == 'linux'){
// var mkdirp = require('mkdirp');
// mkdirp(process.env.HOME+'/.local/share/icons', function(err){console.log(err)});
// mkdirp(process.env.HOME+'/.local/share/applications');
// var fs = require('fs');
// fs.open(process.env.HOME+"/.local/share/applications/sqltabs.desktop", "wx", function(err){
// if (err){
// return;
// }
// fs.writeFile(process.env.HOME+"/.local/share/applications/sqltabs.desktop", "Icon=sqltabs", function(err) {
// if(err) {
// return console.log(err);
// }
// });
// });
// fs.open(process.env.HOME+"/.local/share/icons/sqltabs.png", "wx", function(err){
// if(err){
// return;
// }
// fs.createReadStream('logo.png').pipe(fs.createWriteStream(process.env.HOME+'/.local/share/icons/sqltabs.png'));
// });
//}

var electron = require('electron');
var config = require('./build/Config');

if (isDev()){
require('electron-reload')(__dirname);
Expand Down Expand Up @@ -74,6 +73,12 @@ app.on('open-file', function(event, path){
});

app.on('ready', function() {

if (!isDev()){
const { autoUpdater } = require("electron-updater");
autoUpdater.checkForUpdatesAndNotify();
}

createWindow();
if (files2open.length != 0){
var contents = mainWindow.webContents;
Expand All @@ -88,25 +93,26 @@ app.on('ready', function() {
contents.on('did-finish-load', emit_open_file);
}
}

if (urlToOpen) {
mainWindow.webContents.on('did-finish-load', function () {
mainWindow.webContents.send('open-url', urlToOpen);
});
}

if (!app.isDefaultProtocolClient('postgres') && !config.getNoProtocolDialog()) {
electron.dialog.showMessageBox({
type: 'question',
buttons: ['Yes', 'No'],
cancelId: 1,
message: 'Do you want to set SQL Tabs as the default postgres client?'
}, function (button) {
config.saveNoProtocolDialog(true); // prevent protocol dialog on next start even if No has bee chosen
if (button === 0 ) {
app.setAsDefaultProtocolClient('postgres');
}
})
}
//if (!app.isDefaultProtocolClient('postgres') && !config.getNoProtocolDialog()) {
// electron.dialog.showMessageBox({
// type: 'question',
// buttons: ['Yes', 'No'],
// cancelId: 1,
// message: 'Do you want to set SQL Tabs as the default postgres client?'
// }, function (button) {
// config.saveNoProtocolDialog(true); // prevent protocol dialog on next start even if No has bee chosen
// if (button === 0 ) {
// app.setAsDefaultProtocolClient('postgres');
// }
// })
//}
});

app.on('open-url', function (ev, url) {
Expand Down
Loading

0 comments on commit 2ddd896

Please sign in to comment.