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
0 commit comments