-
Notifications
You must be signed in to change notification settings - Fork 654
855 lines (758 loc) · 26.3 KB
/
ci.yml
File metadata and controls
855 lines (758 loc) · 26.3 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
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
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
name: Build & Publish
on:
push:
branches:
- '**'
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
- 'v[0-9]+.[0-9]+.[0-9]+.dev[0-9]+'
paths:
- '.github/workflows/ci.yml'
- '.github/scripts/**'
- 'client/**'
- 'sdk/python/packages/**'
- 'sdk/python/templates/**'
- 'packages/flet/**'
- 'tools/crocodocs/**'
- 'website/**'
- '.fvmrc'
pull_request:
paths:
- '.github/workflows/ci.yml'
- '.github/scripts/**'
- 'client/**'
- 'sdk/python/packages/**'
- 'sdk/python/templates/**'
- 'packages/flet/**'
- 'tools/crocodocs/**'
- 'website/**'
- '.fvmrc'
workflow_dispatch:
permissions:
id-token: write
contents: write
concurrency:
group: ci-${{ github.workflow }}-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
ROOT: "${{ github.workspace }}"
SDK_PYTHON: "${{ github.workspace }}/sdk/python"
SCRIPTS: "${{ github.workspace }}/.github/scripts"
UV_PYTHON: "3.12.7"
jobs:
# ============
# Python tests
# ============
python_tests:
name: Python ${{ matrix.python-version }} tests
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: [ "3.10", "3.11", "3.12", "3.13", "3.14" ]
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup uv
uses: astral-sh/setup-uv@v6
with:
python-version: ${{ matrix.python-version }}
- name: Run tests
shell: bash
working-directory: ${{ env.SDK_PYTHON }}
run: |
uv run --no-dev --group test pytest packages/flet/tests
uv run --no-dev --group test pytest packages/flet-cli/tests
- name: Run docs-coverage
if: matrix.python-version == '3.12'
shell: bash
working-directory: ${{ env.SDK_PYTHON }}
run: |
exec > docstr_coverage.log 2>&1
status=0
for pkg in packages/*; do
if [ -f "$pkg/pyproject.toml" ] && [ -d "$pkg/src" ]; then
pkg_name=$(basename "$pkg")
echo "====== $pkg ======"
uv run --no-dev --group docs-coverage docstr-coverage -C .docstr.yaml "$pkg/src" --badge="../../website/static/docs/assets/badges/docs-coverage/${pkg_name}.svg" || status=$?
echo
fi
done
exit $status
- name: Upload docs-coverage logs
if: matrix.python-version == '3.12'
uses: actions/upload-artifact@v4
with:
name: docs-coverage
path: sdk/python/docstr_coverage.log
# ==========
# Docs build
# ==========
docs_build:
name: Build Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Enable Corepack
run: corepack enable
- name: Setup uv
uses: astral-sh/setup-uv@v6
- name: Build website
run: |
cd website
yarn install
yarn build
# ===========================
# Build Flet Flutter package
# ===========================
build_flet_package:
name: Build Flet Flutter package
runs-on: ubuntu-latest
permissions:
id-token: write # Required for authentication using OIDC
outputs:
PKG_VER: ${{ steps.versions.outputs.PKG_VER }}
BUILD_NUM: ${{ steps.versions.outputs.BUILD_NUM }}
PYPI_VER: ${{ steps.versions.outputs.PYPI_VER }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0 # fetch all history
fetch-tags: true # ensure tags are available
- name: Setup uv
uses: astral-sh/setup-uv@v6
- name: Compute versions
id: versions
run: source "${SCRIPTS}/update_build_version.sh"
- name: Setup Dart (OIDC for pub.dev)
uses: dart-lang/setup-dart@e630b99d28a3b71860378cafdc2a067c71107f94
- name: Setup Flutter
uses: kuhnroyal/flutter-fvm-config-action/setup@v3
with:
path: '.fvmrc'
cache: true
- name: Run tests
shell: bash
working-directory: packages/flet
run: flutter test
- name: Publish to pub.dev (Dry Run)
shell: bash
working-directory: packages/flet
run: dart pub publish --dry-run
- name: Publish to pub.dev
if: ${{ github.ref_type == 'tag' && !contains(github.ref_name, '.dev') }}
shell: bash
working-directory: packages/flet
run: dart pub publish -f
# ==================
# Package templates
# ==================
build_templates:
name: Package templates
runs-on: ubuntu-latest
needs: build_flet_package
env:
PKG_VER: ${{ needs.build_flet_package.outputs.PKG_VER }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup uv
uses: astral-sh/setup-uv@v6
- name: Patch build template flet version
shell: bash
run: |
PUBSPEC="sdk/python/templates/build/{{cookiecutter.out_dir}}/pubspec.yaml"
if [[ "$GITHUB_REF" == refs/tags/* && "$GITHUB_REF" != *".dev"* ]]; then
uv run "$SCRIPTS/patch_pubspec_version.py" \
"$PUBSPEC" "$PKG_VER" --dependencies-only --exact
else
uv run "$SCRIPTS/patch_pubspec_version.py" \
"$PUBSPEC" --dependencies-only \
--git-ref "$GITHUB_SHA" \
--git-url "https://github.com/flet-dev/flet.git" \
--git-path "packages/flet"
fi
- name: Create template zips
shell: bash
run: |
cd sdk/python/templates
zip -r "$GITHUB_WORKSPACE/flet-build-template.zip" build/
zip -r "$GITHUB_WORKSPACE/flet-app-templates.zip" app/
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: template-artifacts
path: |
flet-build-template.zip
flet-app-templates.zip
# =============================
# Build Flet Client for Windows
# =============================
build_windows:
name: Build Flet Client for Windows
runs-on: windows-latest
needs:
- python_tests
- build_flet_package
env:
PKG_VER: ${{ needs.build_flet_package.outputs.PKG_VER }}
BUILD_NUM: ${{ needs.build_flet_package.outputs.BUILD_NUM }}
PYPI_VER: ${{ needs.build_flet_package.outputs.PYPI_VER }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup uv
uses: astral-sh/setup-uv@v6
- name: Setup Flutter
uses: kuhnroyal/flutter-fvm-config-action/setup@v3
with:
path: '.fvmrc'
cache: true
- name: Build Flutter Windows client
env:
RUNNER_DIR: ${{ env.ROOT }}/client/build/windows/x64/runner
RELEASE_DIR: ${{ env.ROOT }}/client/build/windows/x64/runner/Release
shell: bash
working-directory: client
run: |
flutter build windows --build-name="$PKG_VER" --build-number="$BUILD_NUM"
# Copy needed runtime DLLs
cp "${WINDIR}/system32/msvcp140.dll" "$RELEASE_DIR"
cp "${WINDIR}/system32/vcruntime140.dll" "$RELEASE_DIR"
cp "${WINDIR}/system32/vcruntime140_1.dll" "$RELEASE_DIR"
# Rename Release folder to flet
mv "$RELEASE_DIR" "${RUNNER_DIR}/flet"
# Zip up the runner
cd "$RUNNER_DIR"
7z a "${ROOT}/client/flet-windows.zip" "flet"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: windows-artifacts
if-no-files-found: error
path: |
client/flet-windows.zip
# ===========================
# Build Flet Client for macOS
# ===========================
build_macos:
name: Build Flet Client for macOS
runs-on: macos-26
needs:
- python_tests
- build_flet_package
env:
PKG_VER: ${{ needs.build_flet_package.outputs.PKG_VER }}
BUILD_NUM: ${{ needs.build_flet_package.outputs.BUILD_NUM }}
PYPI_VER: ${{ needs.build_flet_package.outputs.PYPI_VER }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup uv
uses: astral-sh/setup-uv@v6
- name: Setup Flutter
uses: kuhnroyal/flutter-fvm-config-action/setup@v3
with:
path: '.fvmrc'
cache: true
- name: Build Flutter macOS client
shell: bash
working-directory: client
run: |
flutter build macos --build-name="$PKG_VER" --build-number="$BUILD_NUM"
tar -czvf flet-macos.tar.gz -C build/macos/Build/Products/Release Flet.app
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: macos-artifacts
if-no-files-found: error
path: |
client/flet-macos.tar.gz
# ===========================
# Build Flet Client for Linux
# ===========================
build_linux:
name: Build Flet Client for Linux ${{ matrix.title }}
runs-on: ${{ matrix.runner }}
container:
image: ${{ matrix.container }}
needs:
- python_tests
- build_flet_package
strategy:
matrix:
include:
- distro_id: debian10
container: debian:10
manylinux_tag: manylinux_2_28
arch: amd64
runner: ubuntu-24.04
build_arch: x64
platform_arch: x86_64
rive_enabled: false
title: Debian 10 AMD64
- distro_id: debian10
container: debian:10
manylinux_tag: manylinux_2_28
arch: arm64
runner: ubuntu-24.04-arm
build_arch: arm64
platform_arch: aarch64
rive_enabled: false
title: Debian 10 ARM64
- distro_id: debian12
container: debian:12
manylinux_tag: manylinux_2_36
arch: amd64
runner: ubuntu-24.04
build_arch: x64
platform_arch: x86_64
rive_enabled: false
title: Debian 12 AMD64
- distro_id: debian12
container: debian:12
manylinux_tag: manylinux_2_36
arch: arm64
runner: ubuntu-24.04-arm
build_arch: arm64
platform_arch: aarch64
rive_enabled: false
title: Debian 12 ARM64
- distro_id: ubuntu20.04
container: ubuntu:20.04
manylinux_tag: manylinux_2_31
arch: amd64
runner: ubuntu-24.04
build_arch: x64
platform_arch: x86_64
rive_enabled: false
title: Ubuntu 20.04 AMD64
- distro_id: ubuntu20.04
container: ubuntu:20.04
manylinux_tag: manylinux_2_31
arch: arm64
runner: ubuntu-24.04-arm
build_arch: arm64
platform_arch: aarch64
rive_enabled: false
title: Ubuntu 20.04 ARM64
- distro_id: ubuntu22.04
container: ubuntu:22.04
manylinux_tag: manylinux_2_35
arch: amd64
runner: ubuntu-24.04
build_arch: x64
platform_arch: x86_64
rive_enabled: false
title: Ubuntu 22.04 AMD64
- distro_id: ubuntu22.04
container: ubuntu:22.04
manylinux_tag: manylinux_2_35
arch: arm64
runner: ubuntu-24.04-arm
build_arch: arm64
platform_arch: aarch64
rive_enabled: false
title: Ubuntu 22.04 ARM64
- distro_id: ubuntu24.04
container: ubuntu:24.04
manylinux_tag: manylinux_2_39
arch: amd64
runner: ubuntu-24.04
build_arch: x64
platform_arch: x86_64
rive_enabled: true
title: Ubuntu 24.04 AMD64
- distro_id: ubuntu24.04
container: ubuntu:24.04
manylinux_tag: manylinux_2_39
arch: arm64
runner: ubuntu-24.04-arm
build_arch: arm64
platform_arch: aarch64
rive_enabled: false
title: Ubuntu 24.04 ARM64
env:
PKG_VER: ${{ needs.build_flet_package.outputs.PKG_VER }}
BUILD_NUM: ${{ needs.build_flet_package.outputs.BUILD_NUM }}
PYPI_VER: ${{ needs.build_flet_package.outputs.PYPI_VER }}
ARCH: ${{ matrix.arch }}
BUILD_ARCH: ${{ matrix.build_arch }}
PLATFORM_ARCH: ${{ matrix.platform_arch }}
DISTRO_ID: ${{ matrix.distro_id }}
MANYLINUX_TAG: ${{ matrix.manylinux_tag }}
RIVE_ENABLED: ${{ matrix.rive_enabled }}
steps:
- name: Install base packages
shell: bash
run: |
export DEBIAN_FRONTEND=noninteractive
export TZ=Etc/UTC
if [[ "$DISTRO_ID" == "debian10" ]]; then
printf '%s\n' \
'deb http://archive.debian.org/debian buster main' \
'deb http://archive.debian.org/debian buster-updates main' \
'deb http://archive.debian.org/debian-security buster/updates main' \
> /etc/apt/sources.list
echo 'Acquire::Check-Valid-Until "false";' > /etc/apt/apt.conf.d/99no-check-valid-until
fi
apt-get update
apt-get install -y git curl unzip xz-utils zip ca-certificates jq tzdata
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup uv
uses: astral-sh/setup-uv@v6
- name: Get Flutter version from ".fvmrc"
uses: kuhnroyal/flutter-fvm-config-action/config@v3
id: fvm-config-action
with:
path: '.fvmrc'
- name: Setup Flutter
uses: subosito/flutter-action@v2
with:
flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }}
channel: ${{ matrix.arch == 'arm64' && 'master' || 'stable' }} # https://github.com/subosito/flutter-action/issues/345#issuecomment-2657332687
cache: true
- name: Mark git safe directories
shell: bash
run: |
git config --global --add safe.directory "$GITHUB_WORKSPACE"
if [[ -n "${FLUTTER_ROOT:-}" ]]; then
git config --global --add safe.directory "$FLUTTER_ROOT"
fi
- name: Install dependencies
shell: bash
run: |
if [[ -f /etc/apt/sources.list ]]; then
sed -i.bak '/apt.postgresql.org/s/^/# /' /etc/apt/sources.list
fi
apt-get update --allow-releaseinfo-change
LINUX_DEPS="$(uv run --project sdk/python/packages/flet python -c 'from flet.utils.linux_deps import linux_dependencies; print(" ".join(linux_dependencies))')"
apt-get install -y $LINUX_DEPS
- name: Build Flutter Linux clients
shell: bash
working-directory: client
run: |
STAGING_DIR="${RUNNER_TEMP:-/tmp}/flet_tars_${ARCH}"
STAGING_DIR="${STAGING_DIR}_${DISTRO_ID}"
echo "STAGING_DIR=$STAGING_DIR" >> "$GITHUB_ENV"
mkdir -p "$STAGING_DIR"
build_flutter() {
local PACKAGE_NAME="$1"
local SUFFIX=""
local FLAVOR="full"
if [[ "$PACKAGE_NAME" == "flet-desktop-light" ]]; then
SUFFIX="-light"
FLAVOR="light"
fi
echo "::group::($PACKAGE_NAME) Preparing sources"
# Reset Flutter app files so light edits don't leak into full or vice-versa
git checkout -- pubspec.yaml lib/main.dart || true
if [[ "$PACKAGE_NAME" == "flet-desktop-light" ]]; then
# Strip FAT_CLIENT blocks for the light flavor
sed -i '/--FAT_CLIENT_START--/,/--FAT_CLIENT_END--/d' pubspec.yaml
sed -i '/--FAT_CLIENT_START--/,/--FAT_CLIENT_END--/d' lib/main.dart
fi
if [[ "$RIVE_ENABLED" != "true" ]]; then
# flet_rive is excluded unless explicitly enabled
sed -i '/--RIVE_CLIENT_START--/,/--RIVE_CLIENT_END--/d' pubspec.yaml
sed -i '/--RIVE_IMPORT_START--/,/--RIVE_IMPORT_END--/d' lib/main.dart
sed -i '/--RIVE_EXTENSION_START--/,/--RIVE_EXTENSION_END--/d' lib/main.dart
fi
echo "::endgroup::"
echo "::group::($PACKAGE_NAME) Flutter build"
flutter build linux --build-name="$PKG_VER" --build-number="$BUILD_NUM"
# Remove any previous build output, so mv below works as expected
rm -rf "build/linux/${BUILD_ARCH}/release/flet"
# Rename Flutter's default "bundle" output directory to "flet"
mv "build/linux/${BUILD_ARCH}/release/bundle" "build/linux/${BUILD_ARCH}/release/flet"
# Create a compressed tarball of the "flet" directory for distribution
tar -czvf "flet-linux-${DISTRO_ID}${SUFFIX}-${ARCH}.tar.gz" -C "build/linux/${BUILD_ARCH}/release" flet
# Stage the archive
cp -f "flet-linux-${DISTRO_ID}${SUFFIX}-${ARCH}.tar.gz" "${STAGING_DIR}/flet-linux-${DISTRO_ID}-${FLAVOR}-${ARCH}.tar.gz"
echo "::endgroup::"
}
build_flutter "flet-desktop-light"
build_flutter "flet-desktop"
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: linux-${{ matrix.distro_id }}-${{ matrix.arch }}-artifacts
if-no-files-found: error
path: |
client/flet-linux*.tar.gz
# =========================
# Build Flet Client for Web
# =========================
build_web:
name: Build Flet Client for Web
runs-on: ubuntu-latest
needs:
- python_tests
- build_flet_package
env:
PYPI_VER: ${{ needs.build_flet_package.outputs.PYPI_VER }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup uv
uses: astral-sh/setup-uv@v6
- name: Setup Flutter
uses: kuhnroyal/flutter-fvm-config-action/setup@v3
with:
path: '.fvmrc'
cache: true
- name: Patch Python and Flutter versions
shell: bash
working-directory: ${{ env.SDK_PYTHON }}
run: |
source "$SCRIPTS/common.sh"
patch_python_package_versions
- name: Get Pyodide version
shell: bash
working-directory: ${{ env.SDK_PYTHON }}
run: |
PYODIDE_VERSION="$( uv run python -c 'import flet.version; print(flet.version.pyodide_version)' )"
echo "PYODIDE_VERSION=$PYODIDE_VERSION" >> "$GITHUB_ENV"
echo "Pyodide version: $PYODIDE_VERSION"
- name: Build Web client
shell: bash
working-directory: client
run: |
# Compute Pyodide URLs
PYODIDE_URL="https://github.com/pyodide/pyodide/releases/download/${PYODIDE_VERSION}/pyodide-core-${PYODIDE_VERSION}.tar.bz2"
PYODIDE_CDN_URL="https://cdn.jsdelivr.net/pyodide/v${PYODIDE_VERSION}/full"
FLET_WEB="${SDK_PYTHON}/packages/flet-web/src/flet_web"
flutter build web --wasm
cp -R "build/web" "${FLET_WEB}"
# Safari mobile workaround: https://github.com/flutter/flutter/issues/145111#issuecomment-2714599139
FLUTTER_JS_DIR="$(dirname "$(command -v flutter)")/cache/flutter_web_sdk/flutter_js"
cp "$FLUTTER_JS_DIR/flutter.js.map" "${FLET_WEB}/web"
# Download the Pyodide tarball and extract its contents into the web build folder
curl -L "$PYODIDE_URL" | tar -xj -C "${FLET_WEB}/web"
# Download the prebuilt pyodide wheels
for wheel in "packaging-24.2-py3-none-any.whl" "micropip-0.8.0-py3-none-any.whl"; do
curl -L "${PYODIDE_CDN_URL}/${wheel}" -o "${FLET_WEB}/web/pyodide/${wheel}"
done
# Archive the web client into a gzipped tarball
tar -czvf "flet-web.tar.gz" -C "build/web" .
- name: Build flet-web Python package
shell: bash
working-directory: ${{ env.SDK_PYTHON }}
run: |
uv build --package flet-web --wheel
rm -rf "packages/flet-web/src/flet_web/web"
uv build --package flet-web --sdist
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: web-artifacts
if-no-files-found: error
path: |
client/flet-web.tar.gz
sdk/python/dist/*.whl
sdk/python/dist/*.tar.gz
# ============================================
# Build Flet extension Python packages
# ============================================
build_flet_extensions:
name: Build Flet extensions
runs-on: ubuntu-latest
needs:
- python_tests
- build_flet_package
env:
PYPI_VER: ${{ needs.build_flet_package.outputs.PYPI_VER }}
PKG_VER: ${{ needs.build_flet_package.outputs.PKG_VER }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
fetch-tags: true
- name: Setup uv
uses: astral-sh/setup-uv@v6
- name: Setup Flutter
uses: kuhnroyal/flutter-fvm-config-action/setup@v3
with:
path: '.fvmrc'
cache: true
- name: Analyze and Build Flutter & Python packages
shell: bash
working-directory: ${{ env.SDK_PYTHON }}
run: |
set -euo pipefail
PACKAGES=(
flet-ads
flet-audio
flet-audio-recorder
flet-camera
flet-charts
flet-code-editor
flet-color-pickers
flet-datatable2
flet-flashlight
flet-geolocator
flet-lottie
flet-map
flet-permission-handler
flet-rive
flet-secure-storage
flet-video
flet-webview
)
source "$SCRIPTS/common.sh"
for PACKAGE in "${PACKAGES[@]}"; do
echo "::group::Processing ${PACKAGE}"
FLUTTER_PACKAGE="${PACKAGE//-/_}"
FLUTTER_DIR="${SDK_PYTHON}/packages/${PACKAGE}/src/flutter/${FLUTTER_PACKAGE}"
pushd "$FLUTTER_DIR"
flutter pub get
dart analyze
popd
patch_toml_versions "packages/${PACKAGE}/pyproject.toml" "$PYPI_VER"
uv build --package "$PACKAGE"
echo "::endgroup::"
done
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: flet-python-extensions
if-no-files-found: error
path: |
sdk/python/dist/*.whl
sdk/python/dist/*.tar.gz
# =====================================
# Build flet, flet-cli and flet-desktop
# =====================================
build_flet_cli_desktop:
name: Build flet, flet-cli and flet-desktop Python packages
runs-on: ubuntu-latest
env:
PYPI_VER: ${{ needs.build_flet_package.outputs.PYPI_VER }}
needs:
- python_tests
- build_flet_package
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup uv
uses: astral-sh/setup-uv@v6
- name: Build Python packages
shell: bash
working-directory: ${{ env.SDK_PYTHON }}
run: |
source "$SCRIPTS/common.sh"
patch_python_package_versions
uv build --package flet-cli
uv build --package flet
uv build --package flet-desktop
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: flet-cli-desktop-python-distribution
path: |
sdk/python/dist/*.whl
sdk/python/dist/*.tar.gz
# ==============
# GitHub Release
# ==============
release:
name: Publish GitHub Release
runs-on: ubuntu-latest
needs:
- python_tests
- docs_build
- build_flet_package
- build_windows
- build_macos
- build_linux
- build_web
- build_templates
- build_flet_extensions
- build_flet_cli_desktop
if: ${{ startsWith(github.ref, 'refs/tags/') }}
steps:
- name: Detect pre-release
id: prerelease
run: |
if [[ "${{ github.ref_name }}" == *".dev"* ]]; then
echo "is_prerelease=true" >> $GITHUB_OUTPUT
else
echo "is_prerelease=false" >> $GITHUB_OUTPUT
fi
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Create/Update GitHub Release
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
name: ${{ github.ref_name }}
tag_name: ${{ github.ref_name }}
prerelease: ${{ steps.prerelease.outputs.is_prerelease == 'true' }}
generate_release_notes: true
preserve_order: true
overwrite_files: true
fail_on_unmatched_files: true
files: |
dist/**/*.whl
dist/**/*.tar.gz
dist/**/*.zip
# ===============
# Python publish
# ===============
py_publish:
name: Publish Python packages to PyPI
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
needs:
- release
steps:
- name: Setup uv
uses: astral-sh/setup-uv@v6
with:
ignore-empty-workdir: true
cache-dependency-glob: ""
- name: Download artifacts
uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true
- name: Publish packages to PyPI
run: |
# remove client to avoid glob conflicts with its contents
rm -rf dist/client
for pkg in \
flet \
flet_cli \
flet_desktop \
flet_web \
flet_ads \
flet_audio \
flet_audio_recorder \
flet_camera \
flet_charts \
flet_code_editor \
flet_color_pickers \
flet_datatable2 \
flet_flashlight \
flet_geolocator \
flet_lottie \
flet_map \
flet_permission_handler \
flet_rive \
flet_secure_storage \
flet_video \
flet_webview; do
uv publish dist/**/${pkg}-*
done