Skip to content

Commit e687957

Browse files
author
Cosmo Myzrail Gorynych
committed
Merge commit 'd1944f2afa277ae69c92697c2fcbca03a46e21a6'
2 parents 59d4d98 + d1944f2 commit e687957

File tree

12 files changed

+2102
-4716
lines changed

12 files changed

+2102
-4716
lines changed

.github/workflows/main.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ jobs:
2525
path: './'
2626
spec: 'ctjsWebInstaller.spec'
2727

28+
- name: Sign the installer
29+
run: gulp sign
30+
env:
31+
SIGN_PFX: ${{ secrets.SIGN_PFX }}
32+
SIGN_PASSWORD: ${{ secrets.SIGN_PASSWORD }}
33+
2834
- name: Bump version and push tag
2935
id: tag_version
3036
uses: mathieudutour/[email protected]

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@ dist
33
*.map
44
assets/bundle.css
55
assets/index.html
6-
node_modules
6+
node_modules
7+
*.pfx

README.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,11 @@ pip install -r requirements.txt
88
## Running
99

1010
```sh
11-
gulp
12-
python ./start.py
11+
gulp && python ./start.py
1312
```
1413

1514
## Building (On Windows)
1615

1716
```sh
18-
./build.sh
17+
npm run build
1918
```

build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
pyinstaller start.py -w -F --add-data "./assets;/" --icon "./icon.ico" --name "ctjsWebInstaller"
1+
python -m PyInstaller start.py -w -F --add-data "./assets;./" --icon "./icon.ico" --name "ctjsWebInstaller" --exclude-module PyQt5 --exclude-module QtPy

ctjsWebInstaller.spec

Lines changed: 39 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,39 @@
1-
# -*- mode: python ; coding: utf-8 -*-
2-
3-
4-
block_cipher = None
5-
6-
7-
a = Analysis(
8-
['start.py'],
9-
pathex=[],
10-
binaries=[],
11-
datas=[('./assets', '/')],
12-
hiddenimports=[],
13-
hookspath=[],
14-
hooksconfig={},
15-
runtime_hooks=[],
16-
excludes=[],
17-
win_no_prefer_redirects=False,
18-
win_private_assemblies=False,
19-
cipher=block_cipher,
20-
noarchive=False,
21-
)
22-
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
23-
24-
exe = EXE(
25-
pyz,
26-
a.scripts,
27-
a.binaries,
28-
a.zipfiles,
29-
a.datas,
30-
[],
31-
name='ctjsWebInstaller',
32-
debug=False,
33-
bootloader_ignore_signals=False,
34-
strip=False,
35-
upx=True,
36-
upx_exclude=[],
37-
runtime_tmpdir=None,
38-
console=False,
39-
disable_windowed_traceback=False,
40-
argv_emulation=False,
41-
target_arch=None,
42-
codesign_identity=None,
43-
entitlements_file=None,
44-
icon='icon.ico',
45-
)
1+
# -*- mode: python ; coding: utf-8 -*-
2+
3+
4+
a = Analysis(
5+
['start.py'],
6+
pathex=[],
7+
binaries=[],
8+
datas=[('./assets', './')],
9+
hiddenimports=[],
10+
hookspath=[],
11+
hooksconfig={},
12+
runtime_hooks=[],
13+
excludes=['PyQt5', 'QtPy'],
14+
noarchive=False,
15+
optimize=0,
16+
)
17+
pyz = PYZ(a.pure)
18+
19+
exe = EXE(
20+
pyz,
21+
a.scripts,
22+
a.binaries,
23+
a.datas,
24+
[],
25+
name='ctjsWebInstaller',
26+
debug=False,
27+
bootloader_ignore_signals=False,
28+
strip=False,
29+
upx=True,
30+
upx_exclude=[],
31+
runtime_tmpdir=None,
32+
console=False,
33+
disable_windowed_traceback=False,
34+
argv_emulation=False,
35+
target_arch=None,
36+
codesign_identity=None,
37+
entitlements_file=None,
38+
icon=['icon.ico'],
39+
)

gulpfile.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

gulpfile.mjs

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
import fs from 'fs-extra';
2+
import { src, dest, parallel, series } from 'gulp';
3+
import stylus from 'gulp-stylus';
4+
import pug from 'gulp-pug';
5+
import log from 'gulplog';
6+
import resedit from 'resedit-cli';
7+
import {read} from 'read';
8+
9+
const buildStylus = () =>
10+
src('./src/bundle.styl')
11+
.pipe(stylus({
12+
compress: true,
13+
'include css': true
14+
}))
15+
.pipe(dest('./assets/'));
16+
17+
const buildPug = () =>
18+
src('./src/index.pug')
19+
.pipe(pug({
20+
pretty: false
21+
}))
22+
.pipe(dest('./assets/'));
23+
24+
export const build = parallel(buildStylus, buildPug);
25+
26+
27+
const dumpPfx = () => {
28+
if (!process.env.SIGN_PFX) {
29+
log.warn('❔ \'dumpPfx\': Cannot find PFX certificate in environment variables. Provide it as a local file at ./CoMiGoGames.pfx or set the environment variable SIGN_PFX.');
30+
return Promise.resolve();
31+
}
32+
return fs.writeFile(
33+
'./CoMiGoGames.pfx',
34+
Buffer.from(process.env.SIGN_PFX, 'base64')
35+
);
36+
};
37+
38+
const exePatch = {
39+
sign: true,
40+
p12: './CoMiGoGames.pfx'
41+
};
42+
if (process.env.SIGN_PASSWORD) {
43+
exePatch.password = process.env.SIGN_PASSWORD.replace(/_/g, '');
44+
}
45+
46+
const signInstaller = async () => {
47+
if (!(await fs.pathExists(exePatch.p12))) {
48+
log.warn('⚠️ \'signInstaller\': Cannot find PFX certificate. Continuing without signing.');
49+
delete exePatch.p12;
50+
exePatch.sign = false;
51+
} else if (!process.env.SIGN_PASSWORD) {
52+
log.warn('❔ \'signInstaller\': Cannot find PFX password in the SIGN_PASSWORD environment variable. Assuming manual input.');
53+
const pass = await read({
54+
prompt: 'Enter PFX password: (not shown. timing out in 60 seconds.)',
55+
silent: true,
56+
timeout: 1000 * 60
57+
});
58+
if (!pass) {
59+
log.warn('⚠️ \'signInstaller\': Cannot find PFX password in the SIGN_PASSWORD environment variable. Continuing without signing.');
60+
delete exePatch.p12;
61+
exePatch.sign = false;
62+
} else {
63+
exePatch.password = pass;
64+
}
65+
}
66+
if (!exePatch.sign) {
67+
throw new Error('Cannot find PFX certificate or PFX password.');
68+
}
69+
await resedit({
70+
in: `./dist/ctjsWebInstaller.exe`,
71+
out: `./dist/ctjsWebInstaller.exe`,
72+
...exePatch
73+
});
74+
};
75+
76+
export const sign = series(dumpPfx, signInstaller);
77+
78+
export default build;

0 commit comments

Comments
 (0)