-
Notifications
You must be signed in to change notification settings - Fork 1
331 lines (275 loc) · 8.47 KB
/
build.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
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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
name: "Publish to PyPI and release packages"
on:
pull_request:
workflow_call:
workflow_dispatch:
push:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
jobs:
# tests
build:
name: Run unit tests and build
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: nixbuild/nix-quick-install-action@v26
- name: Install
run: >-
nix develop
--impure
--accept-flake-config
.#ci
--command
poetry install
- name: Run unit tests
run: >-
nix develop
--impure
--accept-flake-config
.#ci
--command
poetry run python -m pytest
- name: Build
run: >-
nix develop
--impure
--accept-flake-config
.#ci
--command
poetry build
- name: Store the distribution packages
uses: actions/upload-artifact@v4
with:
name: python-package-distributions
path: dist/
if-no-files-found: error
# builds
build-linux-appimage:
name: Build Linux AppImage package
runs-on: ubuntu-22.04
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
needs:
- build
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: nixbuild/nix-quick-install-action@v26
- name: Install
run: >-
nix develop
--impure
--accept-flake-config
.#ci
--command
poetry install --with=appimage
- name: Build AppImage
run: |
echo ${{ github.workspace }} > appimage/requirements.txt
nix develop \
--impure \
--accept-flake-config \
.#ci \
--command \
poetry run python-appimage build app -p 3.10 appimage/
mv tbc-video-export-x86_64.AppImage tbc-video-export.AppImage
# AppImages require libfuse to run
- uses: awalsh128/cache-apt-pkgs-action@latest
with:
packages: fuse
version: 1.0
- name: Test AppImage
run: ./tbc-video-export.AppImage --version
- name: Store the AppImage binary
uses: actions/upload-artifact@v4
with:
name: linux-appimage
path: ./tbc-video-export.AppImage
if-no-files-found: error
build-windows-binary:
name: Build Windows binary with PyInstaller
runs-on: windows-latest
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
needs:
- build
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Setup Environment
run: |
pip install poetry
New-Item -ItemType Directory -Path .\build
- name: Setup dependencies
run: |
poetry install --with=pyinstaller
- name: Create PyInstaller binary
run: |
poetry run poetry-dynamic-versioning
poetry run python .\pyinstaller\build_windows.py
- name: Test binary
run: .\dist\tbc-video-export.exe --version
- name: Store the Windows binary
uses: actions/upload-artifact@v4
with:
name: windows-binary
path: .\dist\tbc-video-export.exe
if-no-files-found: error
build-macos-binary:
name: Build macOS binary with PyInstaller
runs-on: macos-12
if: startsWith(github.ref, 'refs/tags/v') || github.event_name == 'workflow_dispatch'
needs:
- build
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- uses: actions/setup-python@v5
with:
python-version: "3.11" # use 3.11+ for universal2
- name: Install utilities
run: brew install create-dmg
- name: Setup python environment
run: |
pip install poetry
- name: Setup dependencies
run: |
poetry install --with=pyinstaller
- name: Create PyInstaller binary
run: |
poetry run poetry-dynamic-versioning
poetry run python pyinstaller/build_macos.py
- name: Test binary
run: dist/tbc-video-export --version
- name: Build DMG file
run: >-
create-dmg
--volname "tbc-video-export"
--volicon "assets/icon.icns"
--window-pos 200 128
--window-size 600 300
--icon-size 100
--icon "tbc-video-export.app" 172 120
--app-drop-link 425 128
--skip-jenkins
--hide-extension "tbc-video-export.app"
"dist/tbc-video-export.dmg"
"dist/tbc-video-export.app"
- name: Store the macOS binary
uses: actions/upload-artifact@v4
with:
name: macos-binary
path: dist/tbc-video-export.dmg
if-no-files-found: error
# release
github-release:
name: Create GitHub Release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
needs:
- build
- build-linux-appimage
- build-windows-binary
- build-macos-binary
permissions:
contents: write # IMPORTANT: mandatory for making GitHub Releases
id-token: write # IMPORTANT: mandatory for sigstore
steps:
- name: Download all the artifacts
uses: actions/download-artifact@v4
- name: Sign the dists with Sigstore
uses: sigstore/gh-action-sigstore-python@v2.1.1
with:
inputs: >-
./python-package-distributions/*.tar.gz
./python-package-distributions/*.whl
- name: Create GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: >-
gh release create
'${{ github.ref_name }}'
--repo '${{ github.repository }}'
--title '${{ github.ref_name }}'
--notes ""
- name: Upload artifacts to GitHub Release
env:
GITHUB_TOKEN: ${{ github.token }}
run: |
# python distribution
gh release upload \
'${{ github.ref_name }}' \
./python-package-distributions/** \
--repo '${{ github.repository }}'
# linux appimage binary
gh release upload \
'${{ github.ref_name }}' \
'./linux-appimage/tbc-video-export.AppImage#tbc-video-export-${{ github.ref_name }}-amd64.AppImage' \
--repo '${{ github.repository }}'
# windows binary
gh release upload \
'${{ github.ref_name }}' \
'./windows-binary/tbc-video-export.exe#tbc-video-export-${{ github.ref_name }}-amd64.exe' \
--repo '${{ github.repository }}'
# macos binary
gh release upload \
'${{ github.ref_name }}' \
'./macos-binary/tbc-video-export.dmg#tbc-video-export-${{ github.ref_name }}-multiarch.dmg' \
--repo '${{ github.repository }}'
# pypi
# publish-to-testpypi:
# name: Publish to TestPyPI
# runs-on: ubuntu-latest
#
# if: github.ref == 'refs/heads/master'
# needs:
# - build
#
# environment:
# name: testpypi
# url: https://test.pypi.org/p/tbc-video-export
#
# permissions:
# id-token: write # IMPORTANT: mandatory for trusted publishing
#
# steps:
# - name: Download all the dists
# uses: actions/download-artifact@v4
# with:
# name: python-package-distributions
# path: dist/
# - name: Publish distribution TestPyPI
# uses: pypa/gh-action-pypi-publish@release/v1
# with:
# repository-url: https://test.pypi.org/legacy/
publish-to-pypi:
name: Publish to PyPI
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/v')
needs:
- github-release
environment:
name: pypi
url: https://pypi.org/p/tbc-video-export
permissions:
id-token: write # IMPORTANT: mandatory for trusted publishing
steps:
- name: Download all the dists
uses: actions/download-artifact@v4
with:
name: python-package-distributions
path: dist/
- name: Publish distribution package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1