-
Notifications
You must be signed in to change notification settings - Fork 0
207 lines (187 loc) · 7.42 KB
/
build-and-release.yaml
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
on: push
defaults:
run:
shell: bash
jobs:
build-windows:
runs-on: 'windows-2022'
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: "3.10"
cache: 'pip'
- name: Run set_version script
uses: ./.github/actions/run-set_version_script
with:
venv-bin-dir: Scripts # idk why windows does this different
- run: mkdir dist/
- name: Download python embedded
run: curl -L "https://www.python.org/ftp/python/3.10.7/python-3.10.7-embed-amd64.zip" -o python-embedded.zip
- name: Unzip python embedded
run: unzip python-embedded.zip -d dist/.python_local
- name: Weird DLL workaround so that pip can see all default embedded python modules
# See https://github.com/python/cpython/issues/100399#issuecomment-1381486117
run: |
mkdir dist/.python_local/DLLs
GLOBIGNORE="dist/.python_local/python3*.dll"
mv -v dist/.python_local/*.{dll,pyd} dist/.python_local/DLLs
- name: Modify python embedded to allow pip to run # See https://stackoverflow.com/questions/42666121/pip-with-embedded-python
run: rm -v dist/.python_local/python310._pth
- name: Download get-pip.py
run: curl -L "https://bootstrap.pypa.io/get-pip.py" -o "get-pip.py"
working-directory: dist/.python_local
- name: Run get-pip.py
run: ./python.exe ./get-pip.py
working-directory: dist/.python_local
- name: Install requirements
run: dist/.python_local/python.exe -m pip install --requirement requirements.txt
- name: Download portable git
run: curl -L "https://github.com/git-for-windows/git/releases/download/v2.41.0.windows.3/PortableGit-2.41.0.3-64-bit.7z.exe" -o "PortableGit.7z"
- name: Extract PortableGit
run: 7z x PortableGit.7z -o./dist/.portable_git
- name: PortableGit before size
run: du -sh ./dist/.portable_git
- name: Prune unused PortableGit dirs
run: |
while read -r line; do
del_path="./dist/.portable_git/${line//$'\r'}" # Remove trailing carriage return
if [ -d "$del_path" ]; then
rm -rv "$del_path"
else
echo "Cannot find dir:$del_path"
ls -l "./dist/.portable_git"
ls -l "$del_path"
exit 1
fi
done < ./bundle_pruning/PortableGit_dirs.txt
- name: Prune unused PortableGit files
run: |
while read -r line; do
del_path="./dist/.portable_git/${line//$'\r'}" # Remove trailing carriage return
if [ -f "$del_path" ]; then
rm -v "$del_path"
else
echo "Cannot find file:$del_path"
ls -l "./dist/.portable_git"
ls -l "$del_path"
exit 1
fi
done < ./bundle_pruning/PortableGit_files.txt
- name: PortableGit after size
run: du -sh ./dist/.portable_git
- name: Copy sourcecode into dist
run: cp -rv OATFWGUI/ dist/
- name: Copy bootstrap script into dist
run: cp -v scripts/OATFWGUI_Windows.bat dist/
- name: Prune unused windows files
run: |
rm -v ./dist/.python_local/Lib/site-packages/PySide6/lupdate.exe
rm -v ./dist/.python_local/Lib/site-packages/PySide6/Qt*Quick*
rm -v ./dist/.python_local/Lib/site-packages/PySide6/Qt*Qml*
rm -v ./dist/.python_local/Lib/site-packages/PySide6/Qt*Sql*
rm -v ./dist/.python_local/Lib/site-packages/PySide6/Qt*DBus*
rm -v ./dist/.python_local/Lib/site-packages/PySide6/linguist.exe
rm -v ./dist/.python_local/Lib/site-packages/PySide6/designer.exe
rm -v ./dist/.python_local/Lib/site-packages/PySide6/qmllint.exe
rm -rv ./dist/.python_local/Lib/site-packages/PySide6/translations
rm -rv ./dist/.python_local/Lib/site-packages/PySide6/qml
rm -rv ./dist/.python_local/Lib/site-packages/PySide6/include
- name: Smoke test
run: ./dist/OATFWGUI_Windows.bat --no-gui
- name: Retrieve version
id: version
run: echo "OATFWGUI_VERSION=$(./dist/OATFWGUI_Windows.bat --version | tail -1)" >> $GITHUB_ENV
- name: Output version
run: echo "Version is ${{ env.OATFWGUI_VERSION }}"
- name: Remove smoke test artifacts
run: |
rm -rv ./dist/logs
rm -rv ./dist/OATFWGUI/__pycache__
- name: Set artifact name
run: echo "ARTIFACT_ZIP_NAME=OATFWGUI_${{ env.OATFWGUI_VERSION }}_${{ runner.os }}" >> $GITHUB_ENV
- name: Rename and Zip artifacts
run: mv dist $ARTIFACT_ZIP_NAME && 7z a -tzip $ARTIFACT_ZIP_NAME.zip $ARTIFACT_ZIP_NAME/
env:
ARTIFACT_ZIP_NAME: ${{ env.ARTIFACT_ZIP_NAME }}
- name: Upload artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_ZIP_NAME }}
path: ${{ env.ARTIFACT_ZIP_NAME }}.zip
build-virtualenv:
runs-on: 'ubuntu-20.04'
strategy:
matrix:
py_version: [ "3.7", "3.8", "3.9", "3.10", "3.11" ]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v4
with:
python-version: ${{ matrix.py_version }}
cache: 'pip'
- name: Run set_version script
uses: ./.github/actions/run-set_version_script
# Fixes a bug when running the smoke test
# https://stackoverflow.com/a/67205123
- name: Install OpenGL
run: sudo apt-get install freeglut3 freeglut3-dev
- run: mkdir dist/
- run: cp -rv OATFWGUI/ dist/
- run: cp -v scripts/OATFWGUI_Linux.sh dist/
- run: cp -v requirements.txt dist/
- name: Smoke test
run: QT_QPA_PLATFORM=offscreen ./dist/OATFWGUI_Linux.sh --no-gui
- name: Retrieve version
id: version
run: echo "OATFWGUI_VERSION=$(./dist/OATFWGUI_Linux.sh --version | tail -1)" >> $GITHUB_ENV
- name: Output version
run: echo "Version is ${{ env.OATFWGUI_VERSION }}"
- name: Remove smoke test artifacts
run: |
rm -rv ./dist/logs
rm -rv ./dist/.venv_*
rm -rv ./dist/OATFWGUI/__pycache__
- name: Set artifact name
run: echo "ARTIFACT_ZIP_NAME=OATFWGUI_${{ env.OATFWGUI_VERSION }}_${{ runner.os }}" >> $GITHUB_ENV
- name: Rename and Zip artifacts
run: mv dist $ARTIFACT_ZIP_NAME && 7z a -tzip $ARTIFACT_ZIP_NAME.zip $ARTIFACT_ZIP_NAME/
env:
ARTIFACT_ZIP_NAME: ${{ env.ARTIFACT_ZIP_NAME }}
- name: Upload artifact
if: ${{ matrix.py_version }} == "3.10" # Only publish one artifact
uses: actions/upload-artifact@v3
with:
name: ${{ env.ARTIFACT_ZIP_NAME }}
path: ${{ env.ARTIFACT_ZIP_NAME }}.zip
publish-release:
# only publish release on tags
if: ${{ startsWith(github.ref, 'refs/tags/') == true }}
needs: [build-windows, build-virtualenv]
runs-on: 'ubuntu-20.04'
permissions:
# See https://github.com/softprops/action-gh-release/issues/236#issuecomment-1150530128
contents: write
steps:
- name: Download all artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Show artifact contents
run: |
tree .
for zip_dist in artifacts/*/*.zip; do
echo "$zip_dist contains:"
zip -sf $zip_dist
done
- name: Publish GitHub release
uses: softprops/action-gh-release@v1
with:
name: ${{ github.ref_name }}
generate_release_notes: true
fail_on_unmatched_files: true
files: artifacts/*/*.zip