-
Notifications
You must be signed in to change notification settings - Fork 22
/
action.yml
150 lines (130 loc) · 4.95 KB
/
action.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
147
148
149
150
name: Versatile PyInstaller
author: '@sayyid5416'
description: Customisable GitHub Action to package python scripts into executables for different OS's
branding:
icon: hard-drive
color: yellow
inputs:
spec:
description: >
path of your '.py' or '.spec' file.
- This file will be used to create executable.
- If .py: Generated spec file will also be uploaded as artifact
required: true
default: ''
requirements:
description: path of your requirements.txt file
default: ''
options:
description: >
Options to set for pyinstaller command
Ex: options: '--onedir, -F' (seperated by comma and space)
- Supported options: Check readme
default: ''
python_ver:
description: specific python version you want to use
default: '3.10'
python_arch:
description: specific python architecture you want to use
default: 'x64'
pyinstaller_ver:
description: specific pyinstaller version you want to use
default: ''
exe_path:
description: Path on runner-os, where generated executable files are stored
default: './dist'
upload_exe_with_name:
description: If passed, uploads executable artifact with this name. Else, artifact won't be uploaded.
default: ''
clean_checkout:
description: 'If true, perform a clean checkout; if false, skip cleaning. Cleaning will remove all existing local files not in the repository during checkout. If you use utilities like pyinstaller-versionfile, set this to false.'
default: true
lfs:
description: Whether to download Git-LFS files (passed to actions/checkout)
default: false
compression_level:
description: 'Level of compression for archive (between 0 and 9). 0 = No compression, 9 = Max compression.'
default: 6
outputs:
executable_path:
description: path on runner-os, where generated executable files are stored
value: ${{ inputs.exe_path }}
is_uploaded:
description: true, if packaged executable has been uploaded as artifact
value: ${{ steps.exe_uploading.outputs.uploaded }}
runs:
using: 'composite'
steps:
- name: (Install) python
uses: actions/setup-python@v5
with:
python-version: ${{ inputs.python_ver }}
architecture: ${{ inputs.python_arch }}
- name: (Install) python dev tools
shell: bash
run: python -m pip install pip wheel setuptools
- name: checks for inputs
shell: bash
run: python "${{ github.action_path }}/src/checks.py"
env:
spec: ${{ inputs.spec }}
upload_exe_with_name: ${{ inputs.upload_exe_with_name }}
- name: (Set) modified outputs
id: mods
shell: bash
run: python "${{ github.action_path }}/src/mods.py"
env:
spec: ${{ inputs.spec }}
options: ${{ inputs.options }}
- name: Checkout repository
uses: actions/checkout@v4
with:
clean: ${{ inputs.clean_checkout }}
lfs: ${{ inputs.lfs }}
- name: (Install) dependencies
if: inputs.requirements != ''
run: python -m pip install -r "${{ inputs.requirements }}"
shell: bash
- name: (Install) pyinstaller
shell: bash
run: pip install pyinstaller${{ inputs.pyinstaller_ver }}
- name: (Create) Executable
shell: bash
run: |
pyinstaller \
--clean \
--noconfirm \
--dist ${{ inputs.exe_path }} \
${{ steps.mods.outputs.supported_options }} \
"${{ inputs.spec }}"
echo "✔️ Executable created successfully at _'${{ inputs.exe_path }}'_" >> $GITHUB_STEP_SUMMARY
echo " - Python version used: '${{ inputs.python_ver }}'" >> $GITHUB_STEP_SUMMARY
echo " - Python architecture used: '${{ inputs.python_arch }}'" >> $GITHUB_STEP_SUMMARY
- name: (Upload) Executable
id: artifact_upload
if: inputs.upload_exe_with_name != ''
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.upload_exe_with_name }}
path: ${{ inputs.exe_path }}
compression-level: ${{ inputs.compression_level }}
- name: (Upload) generated spec file - if .py
if: endsWith(inputs.spec, '.py')
uses: actions/upload-artifact@v4
with:
name: Generated spec file ${{ inputs.upload_exe_with_name }}
path: ${{ steps.mods.outputs.spec_name }}.spec
- name: If executable upload success
id: exe_uploading
if: steps.artifact_upload.conclusion == 'success'
shell: bash
run: |
echo "✔️ Executable **_(${{ inputs.upload_exe_with_name }})_** uploaded successfully" >> $GITHUB_STEP_SUMMARY
echo "uploaded='true'" >> $GITHUB_OUTPUT
- name: If executable upload fails
if: failure() && steps.artifact_upload.conclusion == 'failure'
shell: bash
run: |
echo "::warning title=Failed-Upload::\
Executable couldn't upload. \
Check available storage at: 'settings > billing > Storage for Actions and Packages'."