Skip to content

Commit 5f05b9a

Browse files
author
k9ert
authored
Electron Bug Fixes and Miscellaneous Changes (#2441)
* migrate the downloadpage generation script to this repo * tiny docs fix * fix 2 electron issues * support intel platform * fix save preferences bug
1 parent d58232c commit 5f05b9a

18 files changed

+6194
-60
lines changed

docs/release-guide.md

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,55 @@
11
# Release Guide
22

33
## Creating release notes
4+
45
### Pre-requisites
6+
57
- You need the correct upstream master. You should see
6-
```bash
7-
git remote -v | grep upstream
8+
9+
```bash
10+
git remote -v | grep upstream
811
upstream [email protected]:cryptoadvance/specter-desktop.git (fetch)
912
upstream [email protected]:cryptoadvance/specter-desktop.git (push)
1013
```
14+
1115
- You need a GitHub token:
12-
If you don't have one, get one here https://github.com/settings/tokens and make sure to tick the boxes for repo and workflow as below:
16+
If you don't have one, get one here https://github.com/settings/tokens and make sure to tick the boxes for repo and workflow as below:
1317

1418
![](./images/release-guide/github-token.png)
1519

1620
Using the new token, run
17-
```bash
18-
export GH_TOKEN=YOURTOKEN
19-
```
21+
22+
```bash
23+
export GH_TOKEN=YOURTOKEN
24+
```
25+
2026
- You need Docker running
2127
- Checkout the master branch and ensure a clean workspace.
2228

2329
Now, you can run
30+
2431
```bash
2532
./utils/release.sh --release-notes
2633
```
34+
2735
Or, if you want to directly set the new version:
36+
2837
```bash
2938
./utils/release.sh --new-version v1.13.1 --release-notes
3039
```
40+
3141
## Creating a new tag
42+
3243
Update your master branch after the release notes PR ([example](https://github.com/cryptoadvance/specter-desktop/commit/65ff6959d7fd85cba745e4d454b30031839f857f/)) has been merged and then run:
44+
3345
```bash
3446
git tag v1.13.1 && git push upstream v1.13.1
3547
```
48+
3649
## GitLab - releasing stage
37-
Creating a tag triggers the release process of the GitLab runners.
38-
There exists a mirror of the GitHub repo on GitLab, but only when a tag is created on GitHub will the release part of the runners execute. You can check the status here:
50+
51+
Creating a tag triggers the release process of the GitLab runners.
52+
There exists a mirror of the GitHub repo on GitLab, but only when a tag is created on GitHub will the release part of the runners execute. You can check the status here:
3953
https://gitlab.com/cryptoadvance/specter-desktop/-/pipelines
4054

4155
There are three stages:
@@ -50,14 +64,17 @@ The first relevant stage is "releasing". Here, the Windows, Linux and pip releas
5064
- specter_desktop-v1.13.1-x86_64-linux-gnu.tar.gz
5165

5266
The three jobs in more detail:
67+
5368
- release_binary_windows: is creating a binary for specterd and for Windows (Windows runner)
5469
- release_electron_linux_windows: Creates a specterd for Linux, an AppImage for Linux and an executable for Windows (Linux runner).
55-
- release_pip: Is releasing a pypi package on [pypi](https://pypi.org/project/cryptoadvance.specter/) and creates a tarball of the pip package for the GitHub release page (Linux runner).
70+
- release_pip: Is releasing a pypi package on [pypi](https://pypi.org/project/cryptoadvance.specter/) and creates a tarball of the pip package for the GitHub release page (Linux runner).
5671

5772
For details look at `.gitlab-ci.yml`
5873

5974
## MacOS
75+
6076
Ideally, directly after the tag is created, start with the MacOS release. This has to be done manually, for now. There is a script for this:
77+
6178
```bash
6279
./utils/build-osx.sh --version v1.13.1 --appleid "Satoshi Nakamoto (appleid)" --mail "[email protected]" make-hash specterd electron sign upload
6380
```
@@ -70,54 +87,37 @@ This script also runs `github.py upload `, so two more binares and the hash and
7087
- SHA256SUMS-macos.asc
7188

7289
## GitLab - post releasing
73-
Back to GitLab, the final stage is "post releasing".
90+
91+
Back to GitLab, the final stage is "post releasing".
7492

7593
In this stage, the invididual SHA256-hashes and signatures are combined into two final files:
94+
7695
- SHA256SUMS
7796
- SHA256SUMS.asc
7897

7998
Everything, apart from the MacOS files, are pulled from the GitLab environment, the MacOS files from GitHub.
8099
Don't forget to delete the two MacOS files (`SHA256SUMS-macos` and `SHA256SUMS-macos.asc`) on the GitHub release page in the end.
81100

82101
## Trouble shooting
102+
83103
If the MacOS signatures are missing, it can happen that the following Exception will be raised:
104+
84105
```bash
85106
File "/builds/cryptoadvance/specter-desktop/utils/github.py", line 295, in download_artifact
86107
raise Exception(
87108
Exception: Status-cod04 for url ... )
88109
```
110+
89111
In any case, if the macOS binaries arrive on GitHub too late, you have to manually delete the already created `SHA256SUMS` and `SHA256SUMS.asc`, otherwise the upload to GitHub will fail if you rerun the release signatures job on GitLab - for details see ([this PR](https://github.com/cryptoadvance/specter-desktop/pull/689)). The green arrow in the screenshot is where you rerun the release signatures job on GitLab:
90112

91113
![](./images/release-guide/rerun-release-signatures.png)
92114

93-
## Editing the text on the GitHub release page
94-
We are running a script here to create a markdown file that can be used for copy and paste. The script uses the latest release on GitHub to create links to the artifacts in the release, so it only makes sense to run it once the previous step has been completed.
95-
- Checkout this repo: `[email protected]:cryptoadvance/corp-notes.git`
96-
- `cd download-page`
97-
- Run `./build.sh`
98-
99-
The result `gh_page.md` can be found in the build directory.
100-
Edit the release on GitHub and paste the md-file there along with the release notes from `release-notes.md`.
101-
102-
## Website
103-
The above script also produces html files for the website (in the same directory). The second item needs to have the release notes on GitHub, otherwise the content for the details button is missing. So, you need to re-run `./build.sh` after the release notes on GitHub are done.
104-
- `download-page_current.html`
105-
- `download-page_releases.html`
106-
107-
Login into: https://specter.solutions/wp-login.php
108-
109-
- Go to "Pages"
110-
- Hover over "Specter Desktop - Elementor" and choose `Edit with Elementor`
111-
- Click somewhere on area 1 (see screenshot), then somewhere on area 2, select all, delete, and paste: `download-page_current.html`
112-
113-
![](./images/release-guide/website-1.png)\
114-
- Then click `update`
115-
Note: If you see jinja tags, you probably pasted some templates.
116-
117-
Do the same for the "Specter Releases" part, just, in this case, replace with:\
118-
`download-page_releases.html`
119-
120-
![](./images/release-guide/website-2.png)\
115+
## GitHub release page and download page
121116

122-
You can then just exit the editing with Elementor.
117+
This is handled by the script `./utils/generate_downloadpage.sh`. As a prerequisite, you need to clone the `specter-static` repo which contains the specter website. Clone it on the same level than specter-desktop.
118+
Running that script will:
123119

120+
- install the prerequisites (basically markdown, see pyproject.toml)
121+
- generate the GH-page and the download-page based on the `utils/templates`.
122+
- Asks whether it should replace/update/initialize the Github Release page for the latest version
123+
- copies over the new download-pages and asks whether it should commit/push those

docs/self-signed-certificates.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
# SSL Certificate
2+
23
## Why a certificate is important
34

45
Browsers require secure communication with the server to use camera API. Without it we can't use QR code scanning.
56

6-
If you are running a VPS it's easy - you just [issue a new certificate](./reverse-proxy#adding-https) with Letsencrypt.
7+
If you are running a VPS it's easy - you just [issue a new certificate](./reverse-proxy.md#adding-https) with Letsencrypt.
78

89
If you are only using the node at home and want to use it from your local network and via camera, you need to run it via SSL.
910

1011
## Easy solution
1112

1213
The easiest solution is to simply add `--ssl` to the serve-command and the certificate will get created automatically in the specter-home-folder.
14+
1315
```
1416
python3 -m cryptoadance.specter server --ssl
1517
```
1618

1719
## Manual creation
1820

19-
2021
A second way, which provides more customization, is to run the [`gen-certificate.sh`](gen-certificate.sh) script in this folder with your node's IP address as an argument:
2122

2223
```sh
@@ -33,7 +34,7 @@ Provide these files to Specter as arguments:
3334
python -m cryptoadvance.specter server --cert=./cert.pem --key=./key.pem
3435
```
3536

36-
*Note:* Adding `--tor=your-tor-password` will create a tor hidden service with https.
37+
_Note:_ Adding `--tor=your-tor-password` will create a tor hidden service with https.
3738

3839
### Specter with Nginx
3940

@@ -53,7 +54,7 @@ The config should look like this:
5354
server{
5455
listen 80 default_server;
5556
listen 443 ssl http2;
56-
57+
5758
server_name your_domain_or_ip;
5859
5960
ssl_certificate /etc/ssl/certs/cert.pem;

pyinstaller/electron/basic_auth.html

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,9 @@ <h2>The server at '<span id="server">...</span>' is prompting for authorization<
3333
const fs = require('fs')
3434
const { ipcRenderer } = require('electron')
3535
const helpers = require('./helpers')
36-
const getAppSettings = helpers.getAppSettings
37-
const appSettingsPath = helpers.appSettingsPath
36+
const config = require('./config')
37+
const getAppSettings = config.getAppSettings
38+
const appSettingsPath = config.appSettingsPath
3839

3940
function cancel() {
4041
window.close();

pyinstaller/electron/main.js

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,11 @@ const contextMenu = require('electron-context-menu')
88
const { appSettingsPath, specterdDirPath, appSettings, platformName, appNameLower } = require('./src/config.js')
99
const { logger } = require('./src/logging.js')
1010
const downloadloc = require('./downloadloc')
11-
const { downloadSpecterd } = require('./src/download.js')
11+
const { downloadSpecterd, destroyProgressbar } = require('./src/download.js')
1212
const getDownloadLocation = downloadloc.getDownloadLocation
1313
const { startSpecterd, quitSpecterd } = require('./src/specterd.js')
14-
const { getFileHash, getAppSettings, versionData, isDev, devFolder, isMac } = require('./src/helpers.js')
14+
const { getFileHash, versionData, isDev, devFolder, isMac } = require('./src/helpers.js')
15+
const { getAppSettings } = require('./src/config.js')
1516
const { showError, updatingLoaderMsg, initMainWindow, loadUrl, initTray } = require('./src/uiHelpers.js')
1617

1718
// Quit again if there is no version-data in dev
@@ -191,13 +192,7 @@ app.on('before-quit', (event) => {
191192
quitted = true
192193
quitSpecterd()
193194
if (mainWindow && !mainWindow.isDestroyed()) {
194-
if (progressBar) {
195-
// You can only destroy the progress bar if it hadn't been closed before
196-
if (progressBar.browserWindow) {
197-
progressBar.destroy()
198-
}
199-
progressBar = null
200-
}
195+
destroyProgressbar()
201196
mainWindow.destroy()
202197
mainWindow = null
203198
prefWindow = null

pyinstaller/electron/package.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,15 @@
3232
"entitlements": "./build/entitlements.mac.plist",
3333
"hardenedRuntime": true,
3434
"icon": "./icons/icon.icns",
35-
"provisioningProfile": "/Users/kim/Specter_Desktop_vanilla.provisionprofile"
35+
"provisioningProfile": "/Users/kim/Specter_Desktop_vanilla.provisionprofile",
36+
"target": [
37+
{
38+
"target": "dmg",
39+
"arch": [
40+
"universal"
41+
]
42+
}
43+
]
3644
},
3745
"win": {
3846
"icon": "./icons/icon.ico"

pyinstaller/electron/settings.html

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,10 +115,11 @@ <h3 class="mt-8">Use a custom specterd file</h3>
115115
const fs = require("fs");
116116
const path = require("path");
117117
const { ipcRenderer } = require("electron");
118-
const helpers = require("./helpers");
118+
const helpers = require("./src/helpers");
119+
const config = require("./src/config");
119120
const getFileHash = helpers.getFileHash;
120-
const getAppSettings = helpers.getAppSettings;
121-
const appSettingsPath = helpers.appSettingsPath;
121+
const getAppSettings = config.getAppSettings;
122+
const appSettingsPath = config.appSettingsPath;
122123
const specterdDirPath = helpers.specterdDirPath;
123124

124125
function toggleAdvanced() {

pyinstaller/electron/src/config.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ module.exports = {
104104
specterAppLogPath,
105105
versionDataPath,
106106
versionData,
107+
getAppSettings,
107108
isDev: isDev,
108109
devFolder,
109110
}

pyinstaller/electron/src/download.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ const ProgressBar = require('electron-progressbar')
1010
const { updateSpecterdStatus, updatingLoaderMsg, createProgressBar } = require('./uiHelpers.js')
1111
const { startSpecterd } = require('./specterd.js')
1212

13+
let progressBar
14+
1315
// The standard quit item cannot be replaced / modified and it is not triggering the
1416
// before-quit event on MacOS if a child window is open
1517
const dockMenuWithforceQuit = Menu.buildFromTemplate([
@@ -85,7 +87,7 @@ const download = (uri, filename, callback) => {
8587
let receivedBytes = 0
8688
const totalBytes = res.headers['content-length']
8789
logger.info(`Total size to download: ${totalBytes}`)
88-
const progressBar = createProgressBar(totalBytes)
90+
progressBar = createProgressBar(totalBytes)
8991
// Add Force Quit item during download for MacOS dock
9092
if (isMac) {
9193
app.dock.setMenu(dockMenuWithforceQuit)
@@ -139,7 +141,18 @@ const download = (uri, filename, callback) => {
139141
})
140142
}
141143

144+
const destroyProgressbar = () => {
145+
if (progressBar) {
146+
// You can only destroy the progress bar if it hadn't been closed before
147+
if (progressBar.browserWindow) {
148+
progressBar.destroy()
149+
}
150+
progressBar = null
151+
}
152+
}
153+
142154
module.exports = {
143155
downloadSpecterd: downloadSpecterd,
144156
download: download,
157+
destroyProgressbar,
145158
}

pyinstaller/electron/src/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const crypto = require('crypto')
55
const readLastLines = require('read-last-lines')
66
const isMac = process.platform === 'darwin'
77

8-
const { versionData, appSettingsPath, specterAppLogPath } = require('./config.js')
8+
const { versionData, specterAppLogPath } = require('./config.js')
99
const { logger } = require('./logging.js')
1010

1111
// Use different version-data.jsons

pyinstaller/electron/src/uiHelpers.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ const { logger } = require('./logging')
44
const { appSettings, isDev, platformName } = require('./config')
55
const ProgressBar = require('electron-progressbar')
66
const { isMac } = require('./helpers')
7+
const { shell } = require('electron')
78

89
// Initialized with initMainWindow
910
let mainWindow

0 commit comments

Comments
 (0)