-
Notifications
You must be signed in to change notification settings - Fork 1
125 lines (121 loc) · 4.25 KB
/
Copy pathpython-package.yml
File metadata and controls
125 lines (121 loc) · 4.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
name: Deploy
on: [push, pull_request]
defaults:
run:
shell: bash
env:
python-version: "3.11"
pyinstaller-version: "5.11.0"
project-name: python-tcod-engine-2023
archive-name: # Is set dynamcially
jobs:
package:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: windows-2022
platform-name: windows.x64
architecture: x64
- os: macos-12
platform-name: macos.x64
- os: ubuntu-22.04
platform-name: linux.x64
steps:
- name: Checkout code
# fetch-depth=0 and v1 are needed for 'git describe' to work correctly.
uses: actions/checkout@v3
with:
fetch-depth: 1000
lfs: true
- name: Set archive name
run: |
ARCHIVE_NAME=${{ env.project-name }}-`git describe --tags --always`-${{ matrix.platform-name }}
echo "Archive name set to: $ARCHIVE_NAME"
echo "archive-name=$ARCHIVE_NAME" >> $GITHUB_ENV
- name: Set up Python ${{ env.python-version }}
uses: actions/setup-python@v4
with:
python-version: ${{ env.python-version }}
architecture: ${{ matrix.architecture }}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
python -m pip install PyInstaller==${{ env.pyinstaller-version }} -r requirements.txt
- name: Run PyInstaller
env:
PYTHONOPTIMIZE: 1 # Enable optimizations as if the -O flag is given.
PYTHONHASHSEED: 0 # Try to ensure deterministic results.
run: |
pyinstaller build.spec
# This step exists for debugging. Such as checking if data files were included correctly by PyInstaller.
- name: List distribution files
run: |
find dist
# Archive the PyInstaller build using the appropriate tool for the platform.
- name: Tar files
if: runner.os != 'Windows'
working-directory: ./dist
run: |
tar --format=ustar -czvf "../${{ env.archive-name }}.tar.gz" */
- name: Archive files
if: runner.os == 'Windows'
shell: pwsh
run: |
Compress-Archive dist/*/ ${{ env.archive-name }}.zip
# Upload archives as artifacts, these can be downloaded from the GitHub actions page.
- name: "Upload Artifact"
uses: actions/upload-artifact@v3
with:
name: build-${{ matrix.platform-name }}
path: ${{ env.archive-name }}.*
retention-days: 7
if-no-files-found: error
# If a tag is pushed then a new archives are uploaded to GitHub Releases automatically.
- name: Upload release
if: startsWith(github.ref, 'refs/tags/')
uses: svenstaro/upload-release-action@v2
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
file: ${{ env.archive-name }}.*
file_glob: true
tag: ${{ github.ref }}
overwrite: true
butler:
needs: [package]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
environment:
name: release
url: https://hexdecimal.itch.io/python-tcod-engine-2023
strategy:
matrix:
platform-name: [windows.x64, macos.x64, linux.x64]
steps:
- uses: actions/download-artifact@v3
with:
name: build-${{ matrix.platform-name }}
- name: Unzip Archive
if: matrix.platform-name == 'windows.x64'
run: unzip ${{ env.project-name }}*.zip -d dist/
- name: Untar Archive
if: matrix.platform-name != 'windows.x64'
run: |
mkdir dist
tar --extract --gzip --file *.tar.gz --directory=dist/ --verbose
- name: Install Butler
if: github.ref == 'refs/heads/main'
run: |
mkdir ~/bin
cd ~/bin
curl -L -o butler.zip https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default
unzip butler.zip
chmod +x butler
echo "~/bin" >> $GITHUB_PATH
~/bin/butler -V
- name: Upload to Itch
if: github.ref == 'refs/heads/main'
env:
BUTLER_API_KEY: ${{ secrets.BUTLER_API_KEY }}
run: butler push dist/*/ hexdecimal/${{ env.project-name }}:${{ matrix.platform-name }}-latest