Skip to content

Commit 6c57d88

Browse files
Merge pull request #2 from nbusseneau/pr/pyinstaller-build-workflow
Add PyInstaller build workflow
2 parents 865700e + 2de8967 commit 6c57d88

3 files changed

Lines changed: 122 additions & 0 deletions

File tree

.github/workflows/build.yaml

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
name: Build
2+
3+
on: workflow_dispatch
4+
5+
env:
6+
pyinstaller-version: "4.0"
7+
name: modimporter
8+
9+
jobs:
10+
archive-and-upload-python-artifacts:
11+
name: Archive and upload Python artifacts
12+
runs-on: ubuntu-latest
13+
env:
14+
artifacts-python: modimporter-python
15+
license: LICENSE
16+
readme: README.md
17+
sjson: sjson
18+
steps:
19+
- name: Checkout files
20+
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
21+
with:
22+
ref: ${{ github.sha }}
23+
submodules: true
24+
25+
- name: Remove `.git` folder from submodules
26+
run: |
27+
rm -r ${{ env.sjson }}/.git
28+
29+
- name: Upload artifacts to workflow
30+
uses: actions/upload-artifact@27121b0bdffd731efa15d66772be8dc71245d074
31+
with:
32+
name: ${{ env.artifacts-python }}
33+
path: |
34+
${{ env.name }}.py
35+
${{ env.sjson }}
36+
${{ env.license }}
37+
${{ env.readme }}
38+
retention-days: 1
39+
40+
build-and-upload-binaries:
41+
name: Build and upload binaries
42+
runs-on: ${{ matrix.os }}
43+
strategy:
44+
matrix:
45+
os: [windows-latest, macos-latest, ubuntu-latest]
46+
include:
47+
- os: windows-latest
48+
pip-cache-path: ~\AppData\Local\pip\Cache
49+
artifacts: modimporter-windows
50+
- os: macos-latest
51+
pip-cache-path: ~/Library/Caches/pip
52+
artifacts: modimporter-macos
53+
- os: ubuntu-latest
54+
pip-cache-path: ~/.cache/pip
55+
artifacts: modimporter-linux
56+
steps:
57+
- name: Checkout files
58+
uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f
59+
with:
60+
ref: ${{ github.sha }}
61+
submodules: true
62+
63+
- name: Set up Python
64+
uses: actions/setup-python@dc73133d4da04e56a135ae2246682783cc7c7cb6
65+
with:
66+
python-version: 3.9
67+
68+
- name: Retrieve pip dependencies from cache
69+
uses: actions/cache@c64c572235d810460d0d6876e9c705ad5002b353
70+
with:
71+
path: |
72+
${{ env.pythonLocation }}\lib\site-packages
73+
${{ matrix.pip-cache-path }}
74+
key: ${{ runner.os }}-pip-cache-${{ env.pyinstaller-version }}
75+
76+
- name: Install pip dependencies
77+
run: python -m pip install pyinstaller==${{ env.pyinstaller-version }}
78+
79+
- name: Build binaries with PyInstaller
80+
run: python -m PyInstaller --onefile ${{ env.name }}.py --name ${{ env.name }}
81+
82+
- name: Upload artifacts to workflow
83+
uses: actions/upload-artifact@27121b0bdffd731efa15d66772be8dc71245d074
84+
with:
85+
name: ${{ matrix.artifacts }}
86+
path: dist/*
87+
retention-days: 1

.gitignores

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# PyInstaller
7+
build/
8+
dist/
9+
*.spec

README.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,29 @@
22
For SuperGiantGames's games (To be replaced by SGGMI)
33

44
https://www.nexusmods.com/hades/mods/26
5+
6+
## Development
7+
8+
Binaries can be built from GitHub Actions runners using the build workflow
9+
available [here](https://github.com/SGG-Modding/sgg-mod-modimporter/actions/workflows/build.yaml).
10+
11+
To build binaries locally:
12+
13+
- Install [PyInstaller](https://pypi.org/project/pyinstaller/):
14+
15+
```bat
16+
python -m pip install pyinstaller==4.0
17+
```
18+
19+
> Note that we use version 4.0 instead of the latest version to avoid getting
20+
flagged by too many antivirus solutions due to PyInstaller's
21+
pre-compiled bootloader. Older versions are less susceptible to this as AV
22+
solutions had more time to properly recognize and whitelist them, in particular
23+
from Microsoft antivirus (which is the single most important one not to get
24+
flagged by).
25+
26+
- Build binaries:
27+
28+
```bat
29+
python -m PyInstaller --onefile modimporter.py --name modimporter
30+
```

0 commit comments

Comments
 (0)