-
Notifications
You must be signed in to change notification settings - Fork 93
147 lines (134 loc) · 4.36 KB
/
build_pyinstaller.yml
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# Workflow for building pyinstaller packages for windows, MacOS and Ubuntu and
# creating a (pre-)release
# see https://data-dive.com/multi-os-deployment-in-cloud-using-pyinstaller-and-github-actions
#
# The workflow runs:
# - for push events on the main branch or when manually triggered,
# creating a "latest" pre-release
# - for tagged release events, creating a versioned release
#
# The latter requires a workflow like:
#
# * <update version.py> # PyPI version number is created from this
# * git tag v0.4.5 # create new local tag
# * git push # push to origin (without tag)
# * git push origin --tags # push tag to origin
# * <draft a release on Github from tag, select prerelease or release>
#
# Tags can be deleted with:
#
# git tag -d <tag_name>
# git push --delete origin <tag_name>
# or git push origin :<tag_name>
---
name: build_pyinstaller
on:
push:
branches: main
release:
types: [published]
workflow_dispatch:
# workflow_run:
# workflows: ['build_flatpak']
# types:
# - completed
jobs:
build:
name: Build packages
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
# ---
- os: windows-latest
# ---
TARGET: windows
CMD_BUILD: >
pyinstaller pyfdax.spec &&
mv dist/pyfdax.exe dist/pyfdax_win.exe
OUT_FILE_NAME: pyfdax_win.exe
ASSET_MIME: application/vnd.microsoft.portable-executable
# ---
- os: macos-latest
# ---
TARGET: macos
CMD_BUILD: >
pyinstaller pyfdax.spec &&
mv dist/pyfdax dist/pyfdax_osx
OUT_FILE_NAME: pyfdax_osx # .app # pyfda.zip
ASSET_MIME: application/zip
# ---
- os: ubuntu-latest
# ---
TARGET: ubuntu
CMD_BUILD: >
pyinstaller pyfdax.spec &&
mv dist/pyfdax dist/pyfdax_ubuntu
OUT_FILE_NAME: pyfdax_ubuntu
ASSET_MIME: application/x-executable
steps:
- name: Infos about github trigger event and ref
run: |
echo github.event_name: ${{ github.event_name }}
echo github.ref: ${{ github.ref }}
echo github.ref_type: ${{ github.ref_type }}
echo github.ref_name: ${{ github.ref_name }}
# Example result for tagged release:
# github.event_name: release
# github.ref: refs/tags/v0.8.0a3
# github.ref_type: tag
# github.ref_name: v0.8.0a3
- uses: actions/checkout@v4
with:
ref: main # enforce using main branch
- name: Set up Python 3.10
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install pyinstaller pyinstaller-hooks-contrib
- name: Build with pyinstaller for ${{matrix.TARGET}}
run: ${{matrix.CMD_BUILD}}
- name: Upload builds as artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.OUT_FILE_NAME}}
path: ./dist/${{ matrix.OUT_FILE_NAME}}
release:
name: Release packages
needs: build
runs-on: ubuntu-latest
steps:
- name: Download all artifacts
uses: actions/download-artifact@v4.1.7
with:
path: ./dist
# not specifying the file names downloads all artifacts. However,
# an individual directory is created for each file identical to its name
- name: Display structure of downloaded files
run: ls -R
- name: Update Github prerelease latest
if: success() && github.ref_type != 'tag'
uses: pyTooling/Actions/releaser@main
with:
tag: latest
rm: true
token: ${{ secrets.GITHUB_TOKEN }}
files: |
./dist/pyfdax_win.exe/pyfdax_win.exe
./dist/pyfdax_osx/pyfdax_osx
./dist/pyfdax_ubuntu/pyfdax_ubuntu
- name: Update versioned release
if: success() && github.ref_type == 'tag'
uses: pyTooling/Actions/releaser@main
with:
tag: ${{ github.ref_name }}
rm: false
token: ${{ secrets.GITHUB_TOKEN }}
files: |
./dist/pyfdax_win.exe/pyfdax_win.exe
./dist/pyfdax_osx/pyfdax_osx
./dist/pyfdax_ubuntu/pyfdax_ubuntu