Skip to content

Commit 9e5bd14

Browse files
committed
added automated builds with python-package.yml
1 parent 54b3b49 commit 9e5bd14

File tree

3 files changed

+133
-0
lines changed

3 files changed

+133
-0
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# /.github/workflows/python-package.yml
2+
# https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Deploy
5+
6+
on: [push, pull_request]
7+
8+
defaults:
9+
run:
10+
shell: bash
11+
12+
env:
13+
python-version: "3.8"
14+
pyinstaller-version: "4.3"
15+
project-name: python-rl
16+
17+
jobs:
18+
package:
19+
runs-on: ${{ matrix.os }}
20+
strategy:
21+
fail-fast: false
22+
matrix:
23+
include:
24+
- os: windows-2019
25+
platform-name: windows.x64
26+
- os: macos-10.15
27+
platform-name: macos.x64
28+
- os: ubuntu-20.04
29+
platform-name: linux.x64
30+
steps:
31+
- name: Checkout code
32+
# fetch-depth=0 and v1 are needed for 'git describe' to work correctly.
33+
uses: actions/checkout@v1
34+
with:
35+
fetch-depth: 0
36+
- name: Set archive name
37+
run: |
38+
ARCHIVE_NAME=${{ env.project-name }}-`git describe --always`-${{ matrix.platform-name }}
39+
echo "Archive name set to: $ARCHIVE_NAME"
40+
echo "archive-name=$ARCHIVE_NAME" >> $GITHUB_ENV
41+
- name: Set up Python ${{ env.python-version }}
42+
uses: actions/setup-python@v2
43+
with:
44+
python-version: ${{ env.python-version }}
45+
- name: Install APT dependencies
46+
if: runner.os == 'Linux'
47+
run: |
48+
sudo apt-get update
49+
sudo apt-get install libsdl2-dev
50+
- name: Install Python dependencies
51+
run: |
52+
python -m pip install --upgrade pip
53+
python -m pip install PyInstaller==${{ env.pyinstaller-version }} -r requirements.txt
54+
- name: Run PyInstaller
55+
env:
56+
PYTHONOPTIMIZE: 1 # Enable optimizations as if the -O flag is given.
57+
PYTHONHASHSEED: 42 # Try to ensure deterministic results.
58+
run: |
59+
pyinstaller build.spec
60+
# This step exists for debugging. Such as checking if data files were included correctly by PyInstaller.
61+
- name: List distribution files
62+
run: |
63+
find dist
64+
# Archive the PyInstaller build using the appropriate tool for the platform.
65+
- name: Tar files
66+
if: runner.os != 'Windows'
67+
run: |
68+
tar --format=ustar -czvf ${{ env.archive-name }}.tar.gz dist/*/
69+
- name: Archive files
70+
if: runner.os == 'Windows'
71+
shell: pwsh
72+
run: |
73+
Compress-Archive dist/*/ ${{ env.archive-name }}.zip
74+
# Upload archives as artifacts, these can be downloaded from the GitHub actions page.
75+
- name: "Upload Artifact"
76+
uses: actions/upload-artifact@v2
77+
with:
78+
name: automated-builds
79+
path: ${{ env.archive-name }}.*
80+
retention-days: 7
81+
if-no-files-found: error
82+
# If a tag is pushed then a new archives are uploaded to GitHub Releases automatically.
83+
- name: Upload release
84+
if: startsWith(github.ref, 'refs/tags/')
85+
uses: svenstaro/upload-release-action@v2
86+
with:
87+
repo_token: ${{ secrets.GITHUB_TOKEN }}
88+
file: ${{ env.archive-name }}.*
89+
file_glob: true
90+
tag: ${{ github.ref }}
91+
overwrite: true

build.spec

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# -*- mode: python ; coding: utf-8 -*-
2+
# https://pyinstaller.readthedocs.io/en/stable/spec-files.html
3+
block_cipher = None
4+
PROJECT_NAME = "PythonRl"
5+
6+
a = Analysis(
7+
["main.py"],
8+
binaries=[],
9+
datas=[("data", "data")], # Include all files in the 'data' directory.
10+
hiddenimports=[],
11+
hookspath=[],
12+
runtime_hooks=[],
13+
excludes=[],
14+
win_no_prefer_redirects=False,
15+
win_private_assemblies=False,
16+
cipher=block_cipher,
17+
noarchive=False,
18+
)
19+
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
20+
exe = EXE(
21+
pyz,
22+
a.scripts,
23+
[],
24+
exclude_binaries=True,
25+
name=PROJECT_NAME, # Name of the executable.
26+
debug=False,
27+
bootloader_ignore_signals=False,
28+
strip=False,
29+
upx=True,
30+
console=True, # Set to False to disable the Windows terminal.
31+
icon="icon.ico", # Windows icon file.
32+
)
33+
coll = COLLECT(
34+
exe,
35+
a.binaries,
36+
a.zipfiles,
37+
a.datas,
38+
strip=False,
39+
upx=True,
40+
upx_exclude=[],
41+
name=PROJECT_NAME, # Name of the distribution directory.
42+
)

icon.ico

110 KB
Binary file not shown.

0 commit comments

Comments
 (0)